Browse Source

Zobrazeni novinek na titulni strance

remotes/origin/vysl deploy-prod-2015-09-10-19-47-xlfd
Bc. Petr Pecha 9 years ago
parent
commit
301e47c701
  1. 9
      seminar/templates/seminar/novinky.html
  2. 45
      seminar/templates/seminar/titulnistrana.html
  3. 8
      seminar/views.py

9
seminar/templates/seminar/novinky.html

@ -1,9 +0,0 @@
{% block body %}
{% for novinka in object_list %}
<p>
Tady bude novinka.
{{ novinka.text }}
</p>
<img src='{{ novinka.obrazek.url }}'
{% endfor%}
{% endblock %}

45
seminar/templates/seminar/titulnistrana.html

@ -1,7 +1,46 @@
{% extends 'base.html' %} {% extends 'base.html' %}
HU!
{% block content %} {% block content %}
Tady bude nadpis pro novinky.
{% include 'seminar/novinky.html' %} {# Uvitaci text #}
<h2>
{% block nadpis1a %}{% block nadpis1b %}
Tož vitajte!
{% endblock %}{% endblock %}
</h2>
<p> Uvítací text či-co.</p>
{# Novinky #}
<h2>Novinky</h2>
{% for novinka in object_list %}
{# pripravene div-y na stylovani#}
<div>
{# datum #}
<div><b>{{novinka.datum}}</b></div>
{# text #}
{% autoescape off %}{{novinka.text}}{% endautoescape %}
{# obrazek #}
{% if novinka.obrazek %}
<div>
<img src='{{novinka.obrazek.url}}'
height='
{% if novinka.obrazek.height > 200 %} {# vyska obrazku natvrdo #}
200
{% else %}
{{novinka.obrazek.height}}
{% endif%}
'>
</div>
{% endif %}
{# autor #}
<div>{{novinka.autor.first_name}}
{% if novinka.autor.organizator.prezdivka%}
&bdquo;{{novinka.autor.organizator.prezdivka}}&ldquo;
{% endif %}
{{novinka.autor.last_name}}
</div>
</div>
{% endfor%}
{% endblock %} {% endblock %}

8
seminar/views.py

@ -43,11 +43,11 @@ class TitulniStranaView(generic.ListView):
model = Novinky model = Novinky
template_name='seminar/titulnistrana.html' template_name='seminar/titulnistrana.html'
pred_dvema_mesici = (date.today() - timedelta(2*365/12)) pred_dvema_mesici = (date.today() - timedelta(2*365/12))
queryset = Novinky.objects.filter(datum__range=(pred_dvema_mesici, date.today())) queryset = Novinky.objects.filter(datum__range=(pred_dvema_mesici, date.today())).filter(zverejneno=True).order_by('-datum')
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)
return context # return context
### Co je M&M ### Co je M&M

Loading…
Cancel
Save