Noc | nocni tema
Nakonec pouzit context_processor, ktery je k tomu urceny. Prida do contextu promenou noc tak, ze pokud je mezi 20. hodinou vecerni a 7. hodinou ranni, pak je noc True. Kdyz je noc True, pak se v base templeatu prida do header class prepona NOC. CSS-ko vuci tomu upraveno
This commit is contained in:
parent
225d5a6f6f
commit
b86685b3bb
5 changed files with 15 additions and 5 deletions
12
mamweb/context_processors.py
Normal file
12
mamweb/context_processors.py
Normal file
|
@ -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}
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
|
||||
from django.http import HttpResponse
|
||||
from datetime import datetime, date
|
||||
|
||||
class vzhled:
|
||||
|
|
|
@ -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 = (
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
<div class='row'>
|
||||
<div class='col-md-12'>
|
||||
<a href='/'>
|
||||
<div id="header" class="{% block noc %}{% if noc %}NOC{% endif %}{% endblock %}{% block header %}{% endblock %}">
|
||||
<div id="header" class="{% if noc %}NOC{% endif %}{% block header %}{% endblock %}">
|
||||
<img class="logo" src="{% static 'images/logo.png' %}" />
|
||||
<!--<h1>{% block nadpis1b %}Nadpis 1. úrovně{% endblock %}</h1>-->
|
||||
</div>
|
||||
|
|
|
@ -4,10 +4,7 @@
|
|||
{{ flatpage.title }}
|
||||
{% endblock %}{% endblock %}
|
||||
|
||||
{% block noc %}{% if flatpage.noc %}NOC{% endif %}{% endblock noc %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div>
|
||||
{{ flatpage.content }}
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue