Browse Source

Drobná oprava titulní strany

remotes/origin/vysl deploy-prod-2015-09-08-20-13-xlfd
Matěj Kocián 9 years ago
parent
commit
5543e368d2
  1. 8
      seminar/templates/seminar/novinky.html
  2. 5
      seminar/templates/seminar/titulnistrana.html
  3. 10
      seminar/views.py

8
seminar/templates/seminar/novinky.html

@ -1,13 +1,9 @@
{% extends 'titulnistrana.html'}
{% block body %} {% block body %}
{% for novinka in novinky %} {% for novinka in object_list %}
{% if novinka.datum > pred_2_mesici and novinka.zverejneno %}
<p> <p>
Tady bude novinka. Tady bude novinka.
{{ novinka.text }} {{ novinka.text }}
</p> </p>
<img src='{{ novinka.obrazek }}' <img src='{{ novinka.obrazek.url }}'
{% endif %}
{% endfor%} {% endfor%}
{% endblock %} {% endblock %}

5
seminar/templates/seminar/titulnistrana.html

@ -1,8 +1,7 @@
Trala!
{% extends 'base.html' %} {% extends 'base.html' %}
HU! HU!
{% block novinky %} {% block content %}
Tady bude nadpis pro novinky. Tady bude nadpis pro novinky.
{% include 'novinky.html' %} {% include 'seminar/novinky.html' %}
{% endblock %} {% endblock %}

10
seminar/views.py

@ -41,17 +41,11 @@ def TemataView(request):
class TitulniStranaView(generic.ListView): class TitulniStranaView(generic.ListView):
model = Novinky model = Novinky
template_name='seminar/titulnistrana.html' template_name='seminar/titulnistrana.html'
pred_dvema_mesici = (datetime.date.today() - datetime.timedelta(2*365/12))
queryset = Novinky.objects.filter(datum__range=(pred_dvema_mesici, datetime.date.today()))
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(TitulniStranaView, self).get_context_data(**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 return context
### Co je M&M ### Co je M&M

Loading…
Cancel
Save