Changeset - c929e2fddd46
[Not reviewed]
Merge
0 7 1
Joshua Simmons - 7 years ago 2017-08-16 05:16:16
i@joshuasimmons.name
Merge branch 'master' of github.com:northbaypython/website
5 files changed with 51 insertions and 4 deletions:
0 comments (0 inline, 0 general)
pinaxcon/middleware.py
Show inline comments
 
new file 100644
 
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)
pinaxcon/settings.py
Show inline comments
...
 
@@ -17,2 +17,4 @@ DATABASES = {
 

	
 
UNPREPEND_WWW = bool(os.environ.get("DJANGO_UNPREPEND_WWW", False))
 

	
 
# HEROKU: Update database configuration with $DATABASE_URL.
...
 
@@ -22,3 +24,3 @@ DATABASES['default'].update(db_from_env)
 

	
 
ALLOWED_HOSTS = ["localhost", ".herokuapp.com", ".northbaypython.org"]
 
ALLOWED_HOSTS = [".localhost", ".herokuapp.com", ".northbaypython.org"]
 

	
...
 
@@ -134,2 +136,3 @@ MIDDLEWARE_CLASSES = [
 
    "ssl_redirect.middleware.SSLRedirectMiddleware",
 
    "pinaxcon.middleware.UnprependWWWMiddleware",
 

	
pinaxcon/templates/static_pages/homepage.html
Show inline comments
...
 
@@ -116,3 +116,3 @@
 
              {% for sponsor in level.sponsors %}
 
                  <div class="col-md-3">
 
                  <div class="sponsor">
 
                      {% if sponsor.website_logo %}
pinaxcon/urls.py
Show inline comments
...
 
@@ -3,2 +3,3 @@ from django.conf.urls import include, url
 
from django.conf.urls.static import static
 
from django.contrib.staticfiles.templatetags.staticfiles import static as _static
 
from django.views.generic import TemplateView
...
 
@@ -6,2 +7,3 @@ from django.views.generic import RedirectView
 

	
 

	
 
from django.contrib import admin
...
 
@@ -40,4 +42,4 @@ urlpatterns = [
 
    # sponsor
 
    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"^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"^sponsors/become-a-sponsor$", TemplateView.as_view(template_name="static_pages/sponsors/become_a_sponsor.html"), name="sponsors/become-a-sponsor"),
static/scss/custom.scss
Show inline comments
...
 
@@ -114,4 +114,12 @@ $homepage-block-min-height: 480px;
 
  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 {
0 comments (0 inline, 0 general)