Browse Source

Middleware, krery zjistuje jestli je NOC

Pokud je noc, prida do class header NOC
a tim se prepne sada fotek na nocni.
Funguje to jenom u generickych view.
Flatpages umim udelat, ale prepisu kus flatpages.
Jine nez genericka view se musi predelat tak,
aby pri postupu response procházelo idealne pres
process_template_response
remotes/origin/noc
Bc. Petr Pecha 9 years ago
parent
commit
225d5a6f6f
  1. 35
      mamweb/middleware.py
  2. 1
      mamweb/settings_common.py
  3. 8
      mamweb/static/css/mamweb.css
  4. BIN
      mamweb/static/images/header-bg-archiv-NOC.png
  5. BIN
      mamweb/static/images/header-bg-clanek-NOC.png
  6. BIN
      mamweb/static/images/header-bg-odevzdat-NOC.png
  7. BIN
      mamweb/static/images/header-bg-soustredeni-NOC.png
  8. BIN
      mamweb/static/images/header-bg-uvod-NOC.png
  9. BIN
      mamweb/static/images/header-bg-zadani-NOC.png
  10. 2
      mamweb/templates/base.html
  11. 2
      mamweb/templates/flatpages/default.html

35
mamweb/middleware.py

@ -0,0 +1,35 @@
from datetime import datetime, date
class vzhled:
def process_request(self, request):
return None
def process_view(self, request, view_func, view_args, view_kwargs):
#print "====== process_request ======"
#print view_func
#print view_args
#print view_kwargs
#print "============================="
return None
def process_template_response(self, request, response):
hodin = datetime.now().hour
if (hodin <= 6) or (hodin >= 14): # TODO 20
response.context_data['noc'] = True
else:
response.context_data['noc'] = False
return response
def process_response(self, request, response):
#hodin = datetime.now().hour
#if (hodin <= 6) or (hodin >= 14): # TODO 20
#response.context_data['noc'] = True
#else:
#response.context_data['noc'] = False
return response
##def process_exception(request, exception):
#pass

1
mamweb/settings_common.py

@ -65,6 +65,7 @@ MIDDLEWARE_CLASSES = (
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
'mamweb.middleware.vzhled',
)
TEMPLATE_CONTEXT_PROCESSORS = (

8
mamweb/static/css/mamweb.css

@ -63,12 +63,20 @@ h2 {
top: -1px;
}
#header.cojemam { background-image: url("../images/header-bg-uvod.png"); }
#header.soustredeni { background-image: url("../images/header-bg-soustredeni.png"); }
#header.zadani { background-image: url("../images/header-bg-zadani.png"); }
#header.clanky { background-image: url("../images/header-bg-clanek.png"); }
#header.archiv { background-image: url("../images/header-bg-archiv.png"); }
#header.NOC {background-image: url("../images/header-bg-uvod-NOC.png"); }
#header.NOCcojemam { background-image: url("../images/header-bg-uvod-NOC.png"); }
#header.NOCsoustredeni { background-image: url("../images/header-bg-soustredeni-NOC.png"); }
#header.NOCzadani { background-image: url("../images/header-bg-zadani-NOC.png"); }
#header.NOCclanky { background-image: url("../images/header-bg-clanek-NOC.png"); }
#header.NOCarchiv { background-image: url("../images/header-bg-archiv-NOC.png"); }
#header img.logo {
position: absolute;
top: 40px;

BIN
mamweb/static/images/header-bg-archiv-NOC.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 KiB

BIN
mamweb/static/images/header-bg-clanek-NOC.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

BIN
mamweb/static/images/header-bg-odevzdat-NOC.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 KiB

BIN
mamweb/static/images/header-bg-soustredeni-NOC.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 KiB

BIN
mamweb/static/images/header-bg-uvod-NOC.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 KiB

BIN
mamweb/static/images/header-bg-zadani-NOC.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

2
mamweb/templates/base.html

@ -48,7 +48,7 @@
<div class='row'>
<div class='col-md-12'>
<a href='/'>
<div id="header" class="{% block header %}{% endblock %}">
<div id="header" class="{% block noc %}{% if noc %}NOC{% endif %}{% endblock %}{% block header %}{% endblock %}">
<img class="logo" src="{% static 'images/logo.png' %}" />
<!--<h1>{% block nadpis1b %}Nadpis 1. úrovně{% endblock %}</h1>-->
</div>

2
mamweb/templates/flatpages/default.html

@ -4,6 +4,8 @@
{{ flatpage.title }}
{% endblock %}{% endblock %}
{% block noc %}{% if flatpage.noc %}NOC{% endif %}{% endblock noc %}
{% block content %}
<div>

Loading…
Cancel
Save