work on design
This commit is contained in:
@ -43,7 +43,19 @@ class BasePageListView(AttachedToMixin, ParentMixin, BaseView, ListView):
|
||||
def get_context_data(self, **kwargs):
|
||||
kwargs.setdefault("item_template_name", self.item_template_name)
|
||||
kwargs.setdefault("has_headline", self.has_headline)
|
||||
return super().get_context_data(**kwargs)
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
||||
if not context.get("page") and not context.get("title"):
|
||||
model = self.model._meta.verbose_name_plural
|
||||
parent = context.get("parent")
|
||||
if parent:
|
||||
parent = parent.get_display_title()
|
||||
title = _("{model} of {parent}")
|
||||
else:
|
||||
title = _("{model}")
|
||||
context["title"] = title.format(model=model, parent=parent)
|
||||
|
||||
return context
|
||||
|
||||
|
||||
class BasePageDetailView(BaseView, DetailView):
|
||||
|
@ -1,6 +1,6 @@
|
||||
from django.urls import reverse
|
||||
|
||||
from ..models import Page, Program, StaticPage
|
||||
from ..models import Article, Page, Program, StaticPage, Episode
|
||||
from .mixins import ParentMixin
|
||||
from .page import PageDetailView, PageListView
|
||||
|
||||
@ -25,8 +25,20 @@ class BaseProgramMixin:
|
||||
class ProgramDetailView(BaseProgramMixin, PageDetailView):
|
||||
model = Program
|
||||
|
||||
def get_sidebar_queryset(self):
|
||||
return super().get_sidebar_queryset().filter(parent=self.program)
|
||||
def get_context_data(self, **kwargs):
|
||||
episodes = (
|
||||
Episode.objects.program(self.object)
|
||||
.published()
|
||||
.order_by("-pub_date")
|
||||
)
|
||||
articles = (
|
||||
Article.objects.parent(self.object)
|
||||
.published()
|
||||
.order_by("-pub_date")
|
||||
)
|
||||
return super().get_context_data(
|
||||
articles=articles, episodes=episodes, **kwargs
|
||||
)
|
||||
|
||||
|
||||
class ProgramListView(PageListView):
|
||||
|
Reference in New Issue
Block a user