add pdocasts
This commit is contained in:
		@ -8,7 +8,8 @@ __all__ = ("BaseView", "BaseAPIView")
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
class BaseView(TemplateResponseMixin, ContextMixin):
 | 
					class BaseView(TemplateResponseMixin, ContextMixin):
 | 
				
			||||||
    header_template_name = "aircox/widgets/header.html"
 | 
					    header_template_name = "aircox/widgets/header.html"
 | 
				
			||||||
    related_count = 7
 | 
					    related_count = 4
 | 
				
			||||||
 | 
					    related_carousel_count = 8
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    @property
 | 
					    @property
 | 
				
			||||||
    def station(self):
 | 
					    def station(self):
 | 
				
			||||||
 | 
				
			|||||||
@ -13,7 +13,6 @@ class HomeView(AttachedToMixin, BaseView, ListView):
 | 
				
			|||||||
    attach_to_value = StaticPage.ATTACH_TO_HOME
 | 
					    attach_to_value = StaticPage.ATTACH_TO_HOME
 | 
				
			||||||
    model = Diffusion
 | 
					    model = Diffusion
 | 
				
			||||||
    queryset = Diffusion.objects.on_air().select_related("episode").order_by("-start")
 | 
					    queryset = Diffusion.objects.on_air().select_related("episode").order_by("-start")
 | 
				
			||||||
    log_diffusion_count = 3
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    publications_queryset = Page.objects.select_subclasses().published().order_by("-pub_date")
 | 
					    publications_queryset = Page.objects.select_subclasses().published().order_by("-pub_date")
 | 
				
			||||||
    podcasts_queryset = Episode.objects.published().with_podcasts().order_by("-pub_date")
 | 
					    podcasts_queryset = Episode.objects.published().with_podcasts().order_by("-pub_date")
 | 
				
			||||||
@ -25,12 +24,12 @@ class HomeView(AttachedToMixin, BaseView, ListView):
 | 
				
			|||||||
        today = date.today()
 | 
					        today = date.today()
 | 
				
			||||||
        # diffs = Diffusion.objects.on_air().date(today)
 | 
					        # diffs = Diffusion.objects.on_air().date(today)
 | 
				
			||||||
        object_list = self.object_list
 | 
					        object_list = self.object_list
 | 
				
			||||||
        diffs = list(object_list[: self.related_count - 3])
 | 
					        diffs = list(object_list[: self.related_count])
 | 
				
			||||||
        logs = Log.objects.on_air().date(today).filter(track__isnull=False)
 | 
					        logs = Log.objects.on_air().date(today).filter(track__isnull=False)
 | 
				
			||||||
        if diffs:
 | 
					        if diffs:
 | 
				
			||||||
            min_date = diffs[-1].start - timedelta(hours=1)
 | 
					            min_date = diffs[-1].start - timedelta(hours=1)
 | 
				
			||||||
            logs = logs.after(min_date)
 | 
					            logs = logs.after(min_date)
 | 
				
			||||||
        return Log.merge_diffusions(logs, object_list, diff_count=self.log_diffusion_count)
 | 
					        return Log.merge_diffusions(logs, object_list, diff_count=self.related_count)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_next_diffs(self):
 | 
					    def get_next_diffs(self):
 | 
				
			||||||
        now = tz.now()
 | 
					        now = tz.now()
 | 
				
			||||||
@ -40,7 +39,7 @@ class HomeView(AttachedToMixin, BaseView, ListView):
 | 
				
			|||||||
        if current_diff:
 | 
					        if current_diff:
 | 
				
			||||||
            diffs = [current_diff] + list(next_diffs.exclude(pk=current_diff.pk)[:9])
 | 
					            diffs = [current_diff] + list(next_diffs.exclude(pk=current_diff.pk)[:9])
 | 
				
			||||||
        else:
 | 
					        else:
 | 
				
			||||||
            diffs = next_diffs[: self.related_count]
 | 
					            diffs = next_diffs[: self.related_carousel_count]
 | 
				
			||||||
        return diffs
 | 
					        return diffs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_last_publications(self):
 | 
					    def get_last_publications(self):
 | 
				
			||||||
@ -58,7 +57,7 @@ class HomeView(AttachedToMixin, BaseView, ListView):
 | 
				
			|||||||
        return items
 | 
					        return items
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_last_podcasts(self):
 | 
					    def get_last_podcasts(self):
 | 
				
			||||||
        return self.podcasts_queryset.all()[: self.related_count]
 | 
					        return self.podcasts_queryset.all()[: self.related_carousel_count]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def get_context_data(self, **kwargs):
 | 
					    def get_context_data(self, **kwargs):
 | 
				
			||||||
        next_diffs = self.get_next_diffs()
 | 
					        next_diffs = self.get_next_diffs()
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user