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
This commit is contained in:
		
							parent
							
								
									48b4b42ad3
								
							
						
					
					
						commit
						225d5a6f6f
					
				
					 11 changed files with 47 additions and 1 deletions
				
			
		
							
								
								
									
										35
									
								
								mamweb/middleware.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								mamweb/middleware.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -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 | ||||||
|  | @ -65,6 +65,7 @@ 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 = ( | ||||||
|  |  | ||||||
|  | @ -63,12 +63,20 @@ h2 { | ||||||
| 	top: -1px; | 	top: -1px; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
| #header.cojemam { background-image: url("../images/header-bg-uvod.png"); } | #header.cojemam { background-image: url("../images/header-bg-uvod.png"); } | ||||||
| #header.soustredeni { background-image: url("../images/header-bg-soustredeni.png"); } | #header.soustredeni { background-image: url("../images/header-bg-soustredeni.png"); } | ||||||
| #header.zadani { background-image: url("../images/header-bg-zadani.png"); } | #header.zadani { background-image: url("../images/header-bg-zadani.png"); } | ||||||
| #header.clanky { background-image: url("../images/header-bg-clanek.png"); } | #header.clanky { background-image: url("../images/header-bg-clanek.png"); } | ||||||
| #header.archiv { background-image: url("../images/header-bg-archiv.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 { | #header img.logo { | ||||||
| 	position: absolute; | 	position: absolute; | ||||||
| 	top: 40px; | 	top: 40px; | ||||||
|  |  | ||||||
							
								
								
									
										
											BIN
										
									
								
								mamweb/static/images/header-bg-archiv-NOC.png
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								mamweb/static/images/header-bg-archiv-NOC.png
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 251 KiB | 
							
								
								
									
										
											BIN
										
									
								
								mamweb/static/images/header-bg-clanek-NOC.png
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								mamweb/static/images/header-bg-clanek-NOC.png
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 61 KiB | 
							
								
								
									
										
											BIN
										
									
								
								mamweb/static/images/header-bg-odevzdat-NOC.png
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								mamweb/static/images/header-bg-odevzdat-NOC.png
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 388 KiB | 
							
								
								
									
										
											BIN
										
									
								
								mamweb/static/images/header-bg-soustredeni-NOC.png
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								mamweb/static/images/header-bg-soustredeni-NOC.png
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 316 KiB | 
							
								
								
									
										
											BIN
										
									
								
								mamweb/static/images/header-bg-uvod-NOC.png
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								mamweb/static/images/header-bg-uvod-NOC.png
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 256 KiB | 
							
								
								
									
										
											BIN
										
									
								
								mamweb/static/images/header-bg-zadani-NOC.png
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								mamweb/static/images/header-bg-zadani-NOC.png
									
									
									
									
									
										Executable file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 204 KiB | 
|  | @ -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 header %}{% endblock %}"> |             <div id="header" class="{% block noc %}{% if noc %}NOC{% endif %}{% endblock %}{% 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,6 +4,8 @@ | ||||||
|   {{ flatpage.title }} |   {{ flatpage.title }} | ||||||
| {% endblock %}{% endblock %} | {% endblock %}{% endblock %} | ||||||
| 
 | 
 | ||||||
|  | {% block noc %}{% if flatpage.noc %}NOC{% endif %}{% endblock noc %} | ||||||
|  | 
 | ||||||
| {% block content %} | {% block content %} | ||||||
| 
 | 
 | ||||||
| <div> | <div> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Bc. Petr Pecha
						Bc. Petr Pecha