carousel, display logs
This commit is contained in:
@ -31,7 +31,5 @@ class EpisodeDetailView(ProgramPageDetailView):
|
||||
class EpisodeListView(PageListView):
|
||||
model = Episode
|
||||
filterset_class = EpisodeFilters
|
||||
item_template_name = "aircox/widgets/episode_item.html"
|
||||
has_headline = True
|
||||
parent_model = Program
|
||||
attach_to_value = StaticPage.ATTACH_TO_EPISODES
|
||||
|
@ -1,4 +1,4 @@
|
||||
from datetime import date
|
||||
from datetime import date, timedelta
|
||||
|
||||
from django.utils import timezone as tz
|
||||
from django.views.generic import ListView
|
||||
@ -12,7 +12,7 @@ class HomeView(AttachedToMixin, BaseView, ListView):
|
||||
template_name = "aircox/home.html"
|
||||
attach_to_value = StaticPage.ATTACH_TO_HOME
|
||||
model = Diffusion
|
||||
queryset = Diffusion.objects.on_air().select_related("episode")
|
||||
queryset = Diffusion.objects.on_air().select_related("episode").order_by("-start")
|
||||
logs_count = 5
|
||||
publications_count = 7
|
||||
|
||||
@ -21,9 +21,14 @@ class HomeView(AttachedToMixin, BaseView, ListView):
|
||||
|
||||
def get_logs(self, diffusions):
|
||||
today = date.today()
|
||||
logs = Log.objects.on_air().date(today).filter(track__isnull=False)
|
||||
# diffs = Diffusion.objects.on_air().date(today)
|
||||
return Log.merge_diffusions(logs, diffusions, self.logs_count)
|
||||
object_list = self.object_list
|
||||
diffs = list(object_list[: self.logs_count])
|
||||
logs = Log.objects.on_air().date(today).filter(track__isnull=False)
|
||||
if diffs:
|
||||
min_date = diffs[-1].start - timedelta(hours=1)
|
||||
logs = logs.after(min_date)
|
||||
return Log.merge_diffusions(logs, object_list, diff_count=self.logs_count)
|
||||
|
||||
def get_next_diffs(self):
|
||||
now = tz.now()
|
||||
|
@ -133,7 +133,7 @@ class PageDetailView(BasePageDetailView):
|
||||
template_name = None
|
||||
context_object_name = "page"
|
||||
|
||||
related_count = 3
|
||||
related_count = 7
|
||||
|
||||
def get_related_queryset(self):
|
||||
"""Return a queryset of related pages or None."""
|
||||
|
@ -33,7 +33,7 @@ class ProgramDetailView(BaseProgramMixin, PageDetailView):
|
||||
.published()
|
||||
.order_by("-pub_date")[:50]
|
||||
)
|
||||
return random.sample(list(queryset), self.related_count)
|
||||
return random.sample(list(queryset), min(len(queryset), self.related_count))
|
||||
|
||||
def get_related_url(self):
|
||||
return reverse("program-list") + f"?category__id={self.object.category_id}"
|
||||
|
Reference in New Issue
Block a user