|
@ -228,9 +228,15 @@ class AktualniZadaniView(TreeNodeView): |
|
|
### Titulni strana |
|
|
### Titulni strana |
|
|
|
|
|
|
|
|
class TitulniStranaView(generic.ListView): |
|
|
class TitulniStranaView(generic.ListView): |
|
|
model = Novinky |
|
|
|
|
|
template_name='seminar/titulnistrana.html' |
|
|
template_name='seminar/titulnistrana.html' |
|
|
queryset = Novinky.objects.order_by('-datum')[:5] |
|
|
|
|
|
|
|
|
def get_queryset(self): |
|
|
|
|
|
# Pro nepřihlášené uživatele chceme novinky jen veřejné |
|
|
|
|
|
# Využíváme líné vyhodnocování QuerySetů |
|
|
|
|
|
qs = Novinky.objects.all() |
|
|
|
|
|
if not self.request.user.is_authenticated: |
|
|
|
|
|
qs = qs.filter(zverejneno=True) |
|
|
|
|
|
return qs.order_by('-datum')[:5] |
|
|
|
|
|
|
|
|
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) |
|
|