diff --git a/mamweb/context_processors.py b/mamweb/context_processors.py new file mode 100644 index 00000000..ec6481df --- /dev/null +++ b/mamweb/context_processors.py @@ -0,0 +1,12 @@ + +from datetime import datetime, date + +def vzhled(request): + ''' Podle casu prida do templatu, zdali je nebo neni noc ''' + hodin = datetime.now().hour + if (hodin <= 6) or (hodin >= 20): + noc = True + else: + noc = False + return {'noc' : noc} + diff --git a/mamweb/middleware.py b/mamweb/middleware.py index 58d7584a..1bc0b4fa 100644 --- a/mamweb/middleware.py +++ b/mamweb/middleware.py @@ -1,4 +1,5 @@ +from django.http import HttpResponse from datetime import datetime, date class vzhled: diff --git a/mamweb/settings_common.py b/mamweb/settings_common.py index 0696c212..345bbc3b 100644 --- a/mamweb/settings_common.py +++ b/mamweb/settings_common.py @@ -65,7 +65,6 @@ MIDDLEWARE_CLASSES = ( 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', - 'mamweb.middleware.vzhled', ) TEMPLATE_CONTEXT_PROCESSORS = ( @@ -79,6 +78,7 @@ TEMPLATE_CONTEXT_PROCESSORS = ( 'django.core.context_processors.tz', 'sekizai.context_processors.sekizai', 'django.core.context_processors.static', + 'mamweb.context_processors.vzhled', ) INSTALLED_APPS = ( diff --git a/mamweb/templates/base.html b/mamweb/templates/base.html index 54e0f19c..a97d5168 100644 --- a/mamweb/templates/base.html +++ b/mamweb/templates/base.html @@ -48,7 +48,7 @@
-