Merge branch 'master' of github.com:northbaypython/website
This commit is contained in:
commit
c929e2fddd
5 changed files with 51 additions and 4 deletions
34
pinaxcon/middleware.py
Normal file
34
pinaxcon/middleware.py
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
import re
|
||||||
|
import warnings
|
||||||
|
|
||||||
|
from django import http
|
||||||
|
from django.conf import settings
|
||||||
|
from django.utils.deprecation import MiddlewareMixin
|
||||||
|
|
||||||
|
class UnprependWWWMiddleware(MiddlewareMixin):
|
||||||
|
""" Unprepends www if necessary. """
|
||||||
|
|
||||||
|
response_redirect_class = http.HttpResponsePermanentRedirect
|
||||||
|
|
||||||
|
def process_request(self, request):
|
||||||
|
"""
|
||||||
|
Rewrite the URL based on settings.UNPREPEND_WWW
|
||||||
|
"""
|
||||||
|
|
||||||
|
unprepend_www = getattr(settings, "UNPREPEND_WWW", False)
|
||||||
|
|
||||||
|
if not unprepend_www:
|
||||||
|
return
|
||||||
|
|
||||||
|
# Check for a redirect based on settings.UNPREPEND_WWW
|
||||||
|
host = request.get_host()
|
||||||
|
must_unprepend = unprepend_www and host and host.lower().startswith('www.')
|
||||||
|
wwwless_host = host[4:]
|
||||||
|
redirect_url = ('%s://%s' % (request.scheme, wwwless_host)) if must_unprepend else ''
|
||||||
|
|
||||||
|
path = request.get_full_path()
|
||||||
|
|
||||||
|
# Return a redirect if necessary
|
||||||
|
if redirect_url or path != request.get_full_path():
|
||||||
|
redirect_url += path
|
||||||
|
return self.response_redirect_class(redirect_url)
|
|
@ -15,12 +15,14 @@ DATABASES = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UNPREPEND_WWW = bool(os.environ.get("DJANGO_UNPREPEND_WWW", False))
|
||||||
|
|
||||||
# HEROKU: Update database configuration with $DATABASE_URL.
|
# HEROKU: Update database configuration with $DATABASE_URL.
|
||||||
import dj_database_url
|
import dj_database_url
|
||||||
db_from_env = dj_database_url.config()
|
db_from_env = dj_database_url.config()
|
||||||
DATABASES['default'].update(db_from_env)
|
DATABASES['default'].update(db_from_env)
|
||||||
|
|
||||||
ALLOWED_HOSTS = ["localhost", ".herokuapp.com", ".northbaypython.org"]
|
ALLOWED_HOSTS = [".localhost", ".herokuapp.com", ".northbaypython.org"]
|
||||||
|
|
||||||
# Local time zone for this installation. Choices can be found here:
|
# Local time zone for this installation. Choices can be found here:
|
||||||
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
|
||||||
|
@ -132,6 +134,7 @@ MIDDLEWARE_CLASSES = [
|
||||||
"reversion.middleware.RevisionMiddleware",
|
"reversion.middleware.RevisionMiddleware",
|
||||||
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
"django.middleware.clickjacking.XFrameOptionsMiddleware",
|
||||||
"ssl_redirect.middleware.SSLRedirectMiddleware",
|
"ssl_redirect.middleware.SSLRedirectMiddleware",
|
||||||
|
"pinaxcon.middleware.UnprependWWWMiddleware",
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -114,7 +114,7 @@
|
||||||
{% for level in levels %}
|
{% for level in levels %}
|
||||||
{% if level.sponsors %}
|
{% if level.sponsors %}
|
||||||
{% for sponsor in level.sponsors %}
|
{% for sponsor in level.sponsors %}
|
||||||
<div class="col-md-3">
|
<div class="sponsor">
|
||||||
{% if sponsor.website_logo %}
|
{% if sponsor.website_logo %}
|
||||||
<a href="{{ sponsor.external_url }}" title="{{ sponsor.name }}">
|
<a href="{{ sponsor.external_url }}" title="{{ sponsor.name }}">
|
||||||
<img src="{% thumbnail sponsor.website_logo '600x360' %}" alt="{{ sponsor.name }}">
|
<img src="{% thumbnail sponsor.website_logo '600x360' %}" alt="{{ sponsor.name }}">
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.conf.urls import include, url
|
from django.conf.urls import include, url
|
||||||
from django.conf.urls.static import static
|
from django.conf.urls.static import static
|
||||||
|
from django.contrib.staticfiles.templatetags.staticfiles import static as _static
|
||||||
from django.views.generic import TemplateView
|
from django.views.generic import TemplateView
|
||||||
from django.views.generic import RedirectView
|
from django.views.generic import RedirectView
|
||||||
|
|
||||||
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
import symposion.views
|
import symposion.views
|
||||||
|
@ -38,8 +40,8 @@ urlpatterns = [
|
||||||
url(r"^terms-and-conditions$", TemplateView.as_view(template_name="static_pages/terms_and_conditions.html"), name="terms-and-conditions"),
|
url(r"^terms-and-conditions$", TemplateView.as_view(template_name="static_pages/terms_and_conditions.html"), name="terms-and-conditions"),
|
||||||
|
|
||||||
# sponsor
|
# sponsor
|
||||||
url(r"^sponsors/prospectus$", RedirectView.as_view(url="/static/assets/northbaypython_prospectus.pdf"), name="sponsors/prospectus"),
|
url(r"^sponsors/prospectus$", RedirectView.as_view(url=_static("assets/northbaypython_prospectus.pdf")), name="sponsors/prospectus"),
|
||||||
url(r"^northbaypython_prospectus.pdf$", RedirectView.as_view(url="/static/assets/northbaypython_prospectus.pdf"), name="northbaypython_prospectus.pdf"),
|
url(r"^northbaypython_prospectus.pdf$", RedirectView.as_view(url=_static("assets/northbaypython_prospectus.pdf")), name="northbaypython_prospectus.pdf"),
|
||||||
url(r"^sponsors/become-a-sponsor$", TemplateView.as_view(template_name="static_pages/sponsors/become_a_sponsor.html"), name="sponsors/become-a-sponsor"),
|
url(r"^sponsors/become-a-sponsor$", TemplateView.as_view(template_name="static_pages/sponsors/become_a_sponsor.html"), name="sponsors/become-a-sponsor"),
|
||||||
|
|
||||||
# news
|
# news
|
||||||
|
|
|
@ -112,8 +112,16 @@ $homepage-block-min-height: 480px;
|
||||||
position: relative;
|
position: relative;
|
||||||
box-shadow: $box-shadow;
|
box-shadow: $box-shadow;
|
||||||
z-index: 3;
|
z-index: 3;
|
||||||
|
|
||||||
|
.sponsor {
|
||||||
|
@include make-xs-column(6);
|
||||||
|
@include make-sm-column(4);
|
||||||
|
@include make-md-column(3);
|
||||||
|
max-width: 600px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.homepage-block-content {
|
.homepage-block-content {
|
||||||
min-height: ($homepage-block-min-height - 80px);
|
min-height: ($homepage-block-min-height - 80px);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue