#56: améliorer la page d'accueil #63
|
@ -15,6 +15,7 @@ class HomeView(BaseView, ListView):
|
||||||
attach_to_value = StaticPage.ATTACH_TO_HOME
|
attach_to_value = StaticPage.ATTACH_TO_HOME
|
||||||
queryset = Diffusion.objects.on_air().select_related('episode')
|
queryset = Diffusion.objects.on_air().select_related('episode')
|
||||||
logs_count = 5
|
logs_count = 5
|
||||||
|
publications_count = 5
|
||||||
has_filters = False
|
has_filters = False
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
|
@ -37,8 +38,19 @@ class HomeView(BaseView, ListView):
|
||||||
return diffs
|
return diffs
|
||||||
|
|
||||||
def get_last_publications(self):
|
def get_last_publications(self):
|
||||||
return Page.objects.select_subclasses().published() \
|
# note: with postgres db, possible to use distinct()
|
||||||
|
qs = Page.objects.select_subclasses().published() \
|
||||||
.order_by('-pub_date')
|
.order_by('-pub_date')
|
||||||
|
parents = set()
|
||||||
|
items = []
|
||||||
|
for publication in qs:
|
||||||
|
parent_id = publication.parent_id
|
||||||
|
if parent_id is not None and parent_id in parents:
|
||||||
|
continue
|
||||||
|
items.append(publication)
|
||||||
|
if len(items) == self.publications_count:
|
||||||
|
break
|
||||||
|
return items
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user