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
|
from datetime import datetime, date
|
||||||
|
|
||||||
class vzhled:
|
class vzhled:
|
||||||
|
|
|
@ -65,7 +65,6 @@ MIDDLEWARE_CLASSES = (
|
||||||
'django.contrib.messages.middleware.MessageMiddleware',
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
|
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
|
||||||
'mamweb.middleware.vzhled',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
TEMPLATE_CONTEXT_PROCESSORS = (
|
TEMPLATE_CONTEXT_PROCESSORS = (
|
||||||
|
@ -79,6 +78,7 @@ TEMPLATE_CONTEXT_PROCESSORS = (
|
||||||
'django.core.context_processors.tz',
|
'django.core.context_processors.tz',
|
||||||
'sekizai.context_processors.sekizai',
|
'sekizai.context_processors.sekizai',
|
||||||
'django.core.context_processors.static',
|
'django.core.context_processors.static',
|
||||||
|
'mamweb.context_processors.vzhled',
|
||||||
)
|
)
|
||||||
|
|
||||||
INSTALLED_APPS = (
|
INSTALLED_APPS = (
|
||||||
|
|
|
@ -48,7 +48,7 @@
|
||||||
<div class='row'>
|
<div class='row'>
|
||||||
<div class='col-md-12'>
|
<div class='col-md-12'>
|
||||||
<a href='/'>
|
<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' %}" />
|
<img class="logo" src="{% static 'images/logo.png' %}" />
|
||||||
<!--<h1>{% block nadpis1b %}Nadpis 1. úrovně{% endblock %}</h1>-->
|
<!--<h1>{% block nadpis1b %}Nadpis 1. úrovně{% endblock %}</h1>-->
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -4,10 +4,7 @@
|
||||||
{{ flatpage.title }}
|
{{ flatpage.title }}
|
||||||
{% endblock %}{% endblock %}
|
{% endblock %}{% endblock %}
|
||||||
|
|
||||||
{% block noc %}{% if flatpage.noc %}NOC{% endif %}{% endblock noc %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
{{ flatpage.content }}
|
{{ flatpage.content }}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue