forked from rc/aircox
#93 Co-authored-by: bkfox <thomas bkfox net> Reviewed-on: rc/aircox#95
This commit is contained in:
@ -1,7 +1,8 @@
|
||||
from . import admin
|
||||
from .article import ArticleDetailView, ArticleListView
|
||||
from .base import BaseAPIView, BaseView
|
||||
from .episode import DiffusionListView, EpisodeDetailView, EpisodeListView
|
||||
from .diffusion import DiffusionListView
|
||||
from .episode import EpisodeDetailView, EpisodeListView
|
||||
from .home import HomeView
|
||||
from .log import LogListAPIView, LogListView
|
||||
from .page import (
|
||||
|
30
aircox/views/diffusion.py
Normal file
30
aircox/views/diffusion.py
Normal file
@ -0,0 +1,30 @@
|
||||
import datetime
|
||||
|
||||
from django.views.generic import ListView
|
||||
|
||||
from aircox.models import Diffusion, StaticPage
|
||||
from .base import BaseView
|
||||
from .mixins import AttachedToMixin, GetDateMixin
|
||||
|
||||
__all__ = ("DiffusionListView",)
|
||||
|
||||
|
||||
class DiffusionListView(GetDateMixin, AttachedToMixin, BaseView, ListView):
|
||||
"""View for timetables."""
|
||||
|
||||
model = Diffusion
|
||||
has_filters = True
|
||||
redirect_date_url = "diffusion-list"
|
||||
attach_to_value = StaticPage.ATTACH_TO_DIFFUSIONS
|
||||
|
||||
def get_date(self):
|
||||
date = super().get_date()
|
||||
return date if date is not None else datetime.date.today()
|
||||
|
||||
def get_queryset(self):
|
||||
return super().get_queryset().date(self.date).order_by("start")
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
start = self.date - datetime.timedelta(days=self.date.weekday())
|
||||
dates = [start + datetime.timedelta(days=i) for i in range(0, 7)]
|
||||
return super().get_context_data(date=self.date, dates=dates, **kwargs)
|
@ -1,18 +1,11 @@
|
||||
import datetime
|
||||
|
||||
from django.views.generic import ListView
|
||||
|
||||
from ..filters import EpisodeFilters
|
||||
from ..models import Diffusion, Episode, Program, StaticPage
|
||||
from .base import BaseView
|
||||
from .mixins import AttachedToMixin, GetDateMixin
|
||||
from ..models import Episode, Program, StaticPage
|
||||
from .page import PageListView
|
||||
from .program import ProgramPageDetailView
|
||||
|
||||
__all__ = (
|
||||
"EpisodeDetailView",
|
||||
"EpisodeListView",
|
||||
"DiffusionListView",
|
||||
)
|
||||
|
||||
|
||||
@ -32,24 +25,3 @@ class EpisodeListView(PageListView):
|
||||
has_headline = True
|
||||
parent_model = Program
|
||||
attach_to_value = StaticPage.ATTACH_TO_EPISODES
|
||||
|
||||
|
||||
class DiffusionListView(GetDateMixin, AttachedToMixin, BaseView, ListView):
|
||||
"""View for timetables."""
|
||||
|
||||
model = Diffusion
|
||||
has_filters = True
|
||||
redirect_date_url = "diffusion-list"
|
||||
attach_to_value = StaticPage.ATTACH_TO_DIFFUSIONS
|
||||
|
||||
def get_date(self):
|
||||
date = super().get_date()
|
||||
return date if date is not None else datetime.date.today()
|
||||
|
||||
def get_queryset(self):
|
||||
return super().get_queryset().date(self.date).order_by("start")
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
start = self.date - datetime.timedelta(days=self.date.weekday())
|
||||
dates = [start + datetime.timedelta(days=i) for i in range(0, 7)]
|
||||
return super().get_context_data(date=self.date, dates=dates, **kwargs)
|
||||
|
Reference in New Issue
Block a user