From dcbf9b6992a065f5b4731d5bae46598f39f693ab Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Tue, 31 Jan 2017 23:26:45 +0100 Subject: [PATCH] readd middleware with the 1.10 setting --- src/bornhack/environment_settings.py.dist | 1 + src/bornhack/settings.py | 11 ++++++++++- src/shop/context_processors.py | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/bornhack/environment_settings.py.dist b/src/bornhack/environment_settings.py.dist index d6817b53..3af1dbbc 100644 --- a/src/bornhack/environment_settings.py.dist +++ b/src/bornhack/environment_settings.py.dist @@ -50,6 +50,7 @@ BANKACCOUNT_IBAN='123' BANKACCOUNT_SWIFTBIC='123' BANKACCOUNT_REG='123' BANKACCOUNT_ACCOUNT='123' +TICKET_CATEGORY_NAME='Tickets' # schedule settings SCHEDULE_MIDNIGHT_OFFSET_HOURS=6 diff --git a/src/bornhack/settings.py b/src/bornhack/settings.py index e49ca207..e0941c82 100644 --- a/src/bornhack/settings.py +++ b/src/bornhack/settings.py @@ -96,11 +96,20 @@ BOOTSTRAP3 = { 'jquery_url': '/static/js/jquery.min.js', 'javascript_url': '/static/js/bootstrap.min.js' } +MIDDLEWARE = [ + 'django.middleware.security.SecurityMiddleware', + 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.common.CommonMiddleware', + 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.AuthenticationMiddleware', + 'django.contrib.messages.middleware.MessageMiddleware', + 'django.middleware.clickjacking.XFrameOptionsMiddleware', +] if DEBUG: EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' INSTALLED_APPS += ['debug_toolbar', ] - MIDDLEWARE = ['debug_toolbar.middleware.DebugToolbarMiddleware'] + MIDDLEWARE += ['debug_toolbar.middleware.DebugToolbarMiddleware'] LOGGING = { 'version': 1, diff --git a/src/shop/context_processors.py b/src/shop/context_processors.py index 0f55fba9..ffcab6d7 100644 --- a/src/shop/context_processors.py +++ b/src/shop/context_processors.py @@ -16,7 +16,7 @@ def current_order(request): def user_has_tickets(request): has_tickets = False if hasattr(request.user, 'orders') and request.user.orders.filter( - tickets__product__category__pk=settings.TICKET_CATEGORY_ID + tickets__product__category__name=settings.TICKET_CATEGORY_NAME ).exists(): has_tickets = True return {'has_tickets': has_tickets}