Příprava templatetu k novinkám. Funkčnost neověřena (nemám teď u sebe
přihlašovací údaje k adminu, takže nemohu přidat novinky ke své db), ale nepadá. Zvláštně nezobrazuje 'HU!' z titulnistrana.html, ale 'Trala' ano. Možná to je špatným odkazem u extends. A.
This commit is contained in:
		
							parent
							
								
									65e306f316
								
							
						
					
					
						commit
						8f1c450632
					
				
					 3 changed files with 35 additions and 1 deletions
				
			
		
							
								
								
									
										13
									
								
								seminar/templates/seminar/novinky.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								seminar/templates/seminar/novinky.html
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,13 @@ | |||
| {% extends 'titulnistrana.html'} | ||||
| 
 | ||||
| {% block body %} | ||||
| 	{% for novinka in novinky %} | ||||
| 		{% if novinka.datum > pred_2_mesici and novinka.zverejneno %} | ||||
| 			<p> | ||||
| 			Tady bude novinka. | ||||
| 			{{ novinka.text }} | ||||
| 			</p> | ||||
| 			<img src='{{ novinka.obrazek }}' | ||||
| 		{% endif %} | ||||
| 	{% endfor%} | ||||
| {% endblock %} | ||||
|  | @ -1 +1,8 @@ | |||
| Hurá! | ||||
| Trala! | ||||
| {% extends 'base.html' %} | ||||
| 
 | ||||
| HU! | ||||
| {% block novinky %} | ||||
| 	Tady bude nadpis pro novinky. | ||||
| 	{% include 'novinky.html' %} | ||||
| {% endblock %} | ||||
|  |  | |||
|  | @ -11,6 +11,8 @@ from .models import Problem, Cislo, Reseni, Nastaveni, Rocnik, Soustredeni, Orga | |||
| from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva | ||||
| from . import utils | ||||
| 
 | ||||
| import datetime | ||||
| 
 | ||||
| 
 | ||||
| def AktualniZadaniView(request): | ||||
|     nastaveni = get_object_or_404(Nastaveni) | ||||
|  | @ -40,6 +42,18 @@ class TitulniStranaView(generic.ListView): | |||
|     model = Novinky | ||||
|     template_name='seminar/titulnistrana.html' | ||||
| 
 | ||||
|     def get_context_data(self, **kwargs): | ||||
|         context = super(TitulniStranaView, self).get_context_data(**kwargs) | ||||
|         context['pred_2_mesici'] = (datetime.date.today() - datetime.timedelta(2*365/12)).isoformat() | ||||
|         #ulozi datum pred dvema mesici | ||||
|         #elegantneji mozne pomoci dateutil: | ||||
|         ''' | ||||
|         from dateutil.relativedelta import relativedelta | ||||
| 
 | ||||
|         date.today() + relativedelta(month=-2) | ||||
|         ''' | ||||
|         return context | ||||
| 
 | ||||
| ### Co je M&M | ||||
| 
 | ||||
| ## Organizatori | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 Aneta
						Aneta