Mercurial > public > sg101
changeset 991:4aadaf3bc234
Added SITE_SCHEME setting.
Configure site scheme to be either http or https based on SITE_SCHEME setting.
Updated code to use it.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 01 Nov 2015 15:56:05 -0600 |
parents | 81b96f3c9e59 |
children | 6816c5189525 |
files | accounts/forms.py bandmap/admin.py core/templatetags/core_tags.py forums/management/commands/topic_export.py forums/templatetags/forum_tags.py forums/views/subscriptions.py gcalendar/admin.py sg101/settings/base.py shoutbox/forms.py smiley/models.py |
diffstat | 10 files changed, 31 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/accounts/forms.py Sat Oct 31 17:36:31 2015 -0500 +++ b/accounts/forms.py Sun Nov 01 15:56:05 2015 -0600 @@ -205,7 +205,8 @@ site = Site.objects.get_current() admin_email = settings.DEFAULT_FROM_EMAIL - activation_link = 'http://%s%s' % ( + activation_link = '%s://%s%s' % ( + settings.SITE_SCHEME, site.domain, reverse('accounts-register_confirm', kwargs={'username': pending_user.username,
--- a/bandmap/admin.py Sat Oct 31 17:36:31 2015 -0500 +++ b/bandmap/admin.py Sun Nov 01 15:56:05 2015 -0600 @@ -49,7 +49,7 @@ data. """ - base_url = "http://maps.googleapis.com/maps/api/geocode/json?address=%s" + base_url = "https://maps.googleapis.com/maps/api/geocode/json?address=%s" ok_cnt = 0 for band in qs: url = base_url % urllib.quote_plus(band.location)
--- a/core/templatetags/core_tags.py Sat Oct 31 17:36:31 2015 -0500 +++ b/core/templatetags/core_tags.py Sun Nov 01 15:56:05 2015 -0600 @@ -91,7 +91,7 @@ """ if url.startswith('/'): - url = "http://%s%s" % (domain, url) + url = "%s://%s%s" % (settings.SITE_SCHEME, domain, url) return url @@ -110,7 +110,7 @@ props = { 'og:title': site.name, 'og:type': 'website', - 'og:url': 'http://%s' % site.domain, + 'og:url': '%s://%s' % (settings.SITE_SCHEME, site.domain), 'og:description': settings.OGP_SITE_DESCRIPTION, }
--- a/forums/management/commands/topic_export.py Sat Oct 31 17:36:31 2015 -0500 +++ b/forums/management/commands/topic_export.py Sun Nov 01 15:56:05 2015 -0600 @@ -9,6 +9,7 @@ from optparse import make_option import re +from django.conf import settings from django.core.management.base import LabelCommand, CommandError from django.template.loader import render_to_string, TemplateDoesNotExist @@ -16,7 +17,7 @@ SRC_RE = re.compile(r'src="/media/') -SRC_REPL = 'src="http://surfguitar101.com/media/' +SRC_REPL = 'src="{}://surfguitar101.com/media/'.format(settings.SITE_SCHEME) class Command(LabelCommand):
--- a/forums/templatetags/forum_tags.py Sat Oct 31 17:36:31 2015 -0500 +++ b/forums/templatetags/forum_tags.py Sun Nov 01 15:56:05 2015 -0600 @@ -3,10 +3,9 @@ """ import datetime -from pytz import timezone +from pytz import timezone, UnknownTimeZoneError from django import template from django.conf import settings -from django.core.cache import cache from forums.models import Forum from forums.models import Topic @@ -31,6 +30,7 @@ ) SERVER_TZ = timezone(settings.TIME_ZONE) +DEFAULT_TZ = timezone('US/Pacific') @register.inclusion_tag('forums/last_post_info.html', takes_context=True) @@ -76,7 +76,10 @@ if user.is_authenticated(): tz_prefs = get_time_prefs(user) - user_tz = timezone(tz_prefs[1]) + try: + user_tz = timezone(tz_prefs[1]) + except UnknownTimeZoneError: + user_tz = DEFAULT_TZ curr_time = curr_time.astimezone(user_tz) fmt = TIME_FMT_24 if tz_prefs[0] else TIME_FMT_12 else: @@ -97,7 +100,10 @@ date = SERVER_TZ.localize(date) if user.is_authenticated(): tz_prefs = get_time_prefs(user) - user_tz = timezone(tz_prefs[1]) + try: + user_tz = timezone(tz_prefs[1]) + except UnknownTimeZoneError: + user_tz = DEFAULT_TZ date = date.astimezone(user_tz) fmt = DATE_FMT_24 if tz_prefs[0] else DATE_FMT_12 else:
--- a/forums/views/subscriptions.py Sat Oct 31 17:36:31 2015 -0500 +++ b/forums/views/subscriptions.py Sun Nov 01 15:56:05 2015 -0600 @@ -33,7 +33,7 @@ if recipients: site = Site.objects.get_current() subject = "[%s] Topic Reply: %s" % (site.name, topic.name) - url_prefix = "http://%s" % site.domain + url_prefix = "%s://%s" % (settings.SITE_SCHEME, site.domain) post_url = url_prefix + post.get_absolute_url() unsubscribe_url = url_prefix + reverse("forums-manage_subscriptions") msg = render_to_string("forums/topic_notify_email.txt", {
--- a/gcalendar/admin.py Sat Oct 31 17:36:31 2015 -0500 +++ b/gcalendar/admin.py Sun Nov 01 15:56:05 2015 -0600 @@ -114,7 +114,9 @@ This view generates the authorization URL and redirects the user to it. """ site = Site.objects.get_current() - callback_url = 'http://%s%s' % (site.domain, + callback_url = '%s://%s%s' % ( + settings.SITE_SCHEME, + site.domain, reverse('admin:gcalendar-auth_return')) auth_url = oauth.get_auth_url(callback_url) return HttpResponseRedirect(auth_url)
--- a/sg101/settings/base.py Sat Oct 31 17:36:31 2015 -0500 +++ b/sg101/settings/base.py Sun Nov 01 15:56:05 2015 -0600 @@ -34,6 +34,9 @@ SITE_ID = 1 +# Site scheme; http or https. +SITE_SCHEME = 'http' + # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = False @@ -320,7 +323,7 @@ ####################################################################### # Open Graph Protocol related settings ####################################################################### -OGP_DEFAULT_IMAGE = 'http://surfguitar101.com/media/podcast/podcast_logo.jpg' +OGP_DEFAULT_IMAGE = SITE_SCHEME + '://surfguitar101.com/media/podcast/podcast_logo.jpg' OGP_FB_ID = '100001558124013' OGP_SITE_DESCRIPTION = ('The premier community website for friends and fans of' ' instrumental surf music. We have forums, podcasts, surf music news, an' @@ -336,13 +339,13 @@ 'js/jquery.imagesloaded.min.js', ], 'jquery': [ - 'http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', + 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js', ], 'jquery-jeditable': [ 'js/jquery.jeditable.mini.js', ], 'jquery-ui': [ - 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js', + 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/jquery-ui.min.js', ], 'markitup': [ 'js/markitup/jquery.markitup1.1.14.min.js', @@ -356,7 +359,7 @@ GPP_THIRD_PARTY_CSS = { 'jquery-ui': [ - 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/themes/redmond/jquery-ui.css', + 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.0/themes/redmond/jquery-ui.css', ], 'markitup': [ 'js/markitup/skins/markitup/style.css', @@ -364,6 +367,5 @@ ], } - # Turn off warning about test runner behavior change SILENCED_SYSTEM_CHECKS = ['1_6.W001']
--- a/shoutbox/forms.py Sat Oct 31 17:36:31 2015 -0500 +++ b/shoutbox/forms.py Sun Nov 01 15:56:05 2015 -0600 @@ -1,24 +1,7 @@ """ Forms for the Shoutbox application. """ - -import re from django import forms -url_re = re.compile('(' - r'^https?://' # http:// or https:// - r'(?:(?:[A-Z0-9-]+\.)+[A-Z]{2,6}|' #domain... - r'localhost|' #localhost... - r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # ...or ip - r'(?::\d+)?' # optional port - r'(?:/?|/\S+))', re.IGNORECASE) - - class ShoutBoxForm(forms.Form): msg = forms.CharField(label='', max_length=2048, required=True) - - def get_shout(self): - msg = self.cleaned_data['msg'] - msg = re.sub(url_re, r'<a href="\1">URL</a>', msg) - return msg -
--- a/smiley/models.py Sat Oct 31 17:36:31 2015 -0500 +++ b/smiley/models.py Sun Nov 01 15:56:05 2015 -0600 @@ -4,6 +4,7 @@ import re from django.db import models +from django.conf import settings from django.core.cache import cache from django.contrib.sites.models import Site @@ -99,6 +100,6 @@ self.title) else: site = Site.objects.get_current() - return (u'![%s](http://%s%s "%s")' % - (self.title, site.domain, self.image.url, self.title)) + return (u'![%s](%s://%s%s "%s")' % ( + self.title, settings.SITE_SCHEME, site.domain, self.image.url, self.title)) return u''