diff --git a/mamweb/settings_common.py b/mamweb/settings_common.py index 75a5493c..925d5961 100644 --- a/mamweb/settings_common.py +++ b/mamweb/settings_common.py @@ -78,6 +78,7 @@ TEMPLATES = [ 'django.contrib.messages.context_processors.messages', 'sekizai.context_processors.sekizai', 'header_fotky.context_processors.vzhled', + 'various.context_processors.april', ) }, }, @@ -132,6 +133,7 @@ INSTALLED_APPS = ( 'korektury', 'prednasky', 'header_fotky', + 'various', # Admin upravy: diff --git a/various/__init__.py b/various/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/various/admin.py b/various/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/various/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/various/apps.py b/various/apps.py new file mode 100644 index 00000000..c24a4428 --- /dev/null +++ b/various/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class VariousConfig(AppConfig): + name = 'various' diff --git a/various/context_processors.py b/various/context_processors.py new file mode 100644 index 00000000..c0be2975 --- /dev/null +++ b/various/context_processors.py @@ -0,0 +1,14 @@ +def april(req): + if 'X-April' in req.headers: + try: + year = int(req.headers['X-April']) + return {'april': year} + except: + pass # Fall-back to regular behaviour + + import datetime + today = datetime.date.today() + if today.day == 1 and today.month == 4: + return {'april': today.year} + return {} + diff --git a/various/migrations/__init__.py b/various/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/various/models.py b/various/models.py new file mode 100644 index 00000000..71a83623 --- /dev/null +++ b/various/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/various/tests.py b/various/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/various/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/various/views.py b/various/views.py new file mode 100644 index 00000000..91ea44a2 --- /dev/null +++ b/various/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here.