From 37b807b4034a100a29b7e6efb74160c862375c16 Mon Sep 17 00:00:00 2001 From: bkfox Date: Mon, 11 Jul 2016 11:43:26 +0200 Subject: [PATCH] schedule -- get queryset from routes.DateRoute --- cms/routes.py | 15 +++++++++++++++ notes.md | 8 ++++---- website/sections.py | 15 ++++----------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/cms/routes.py b/cms/routes.py index e356eb4..2a07c69 100644 --- a/cms/routes.py +++ b/cms/routes.py @@ -88,6 +88,9 @@ class DetailRoute(Route): @classmethod def get_object(cl, model, request, pk, **kwargs): + """ + * request is optional + """ return model.objects.get(pk = int(pk)) @@ -96,6 +99,9 @@ class AllRoute(Route): @classmethod def get_queryset(cl, model, request, **kwargs): + """ + * request is optional + """ return model.objects.all() @classmethod @@ -133,6 +139,9 @@ class ThreadRoute(Route): @classmethod def get_queryset(cl, model, request, thread_model, pk, **kwargs): + """ + * request is optional + """ thread = cl.get_thread(model, thread_model, pk) return model.get_siblings(thread_model = thread, thread_id = pk) @@ -161,6 +170,9 @@ class DateRoute(Route): @classmethod def get_queryset(cl, model, request, year, month, day, **kwargs): + """ + * request is optional + """ return model.objects.filter( date__year = int(year), date__month = int(month), @@ -188,6 +200,9 @@ class SearchRoute(Route): @classmethod def get_queryset(cl, model, request, q = None, **kwargs): + """ + * request is required if q is None + """ q = request.GET.get('q') or q or '' qs = None for search_field in model.search_fields or []: diff --git a/notes.md b/notes.md index 939b1ba..aa78beb 100644 --- a/notes.md +++ b/notes.md @@ -7,6 +7,7 @@ - programs: - schedule changes -> update later diffusions according to the new schedule - stream disable -> remote control on liquidsoap + - users - tests: - sound_monitor @@ -18,16 +19,15 @@ - config generation and sound diffusion - cms: - - empty content/list -> nothing - update documentation: - cms.script - cms.exposure; make it right, see nomenclature, + docstring - cms.actions; - admin cms + -> sections/actions and django decorator? + -> enhance calendar with possible actions? - website: - - render schedule does not get the correct list - -> postlistview has not the same queryset as website/sections/schedule - diffusions: - print program's name in lists / clean up that thing also a bit - article list with the focus @@ -45,7 +45,7 @@ - player support diffusions with multiple archive files - view as grid - actions -> noscript case, think of accessibility -- comments edit/remove by the poster +- comments -> remove/edit by the author diff --git a/website/sections.py b/website/sections.py index 4e72804..f677387 100644 --- a/website/sections.py +++ b/website/sections.py @@ -292,17 +292,10 @@ class Schedule(Diffusions): def get_object_list(self): date = self.date_or_default() - year, month, day = date.year, date.month, date.day - - diffs = [d.initial if d.initial else d - for d in programs.Diffusion.objects.filter( - start__year = year, - start__month = month, - start__day = day, - ) - ] - return models.Diffusion.objects.filter(related__in = diffs). \ - order_by('date') + return routes.DateRoute.get_queryset( + models.Diffusion, self.request, date.year, date.month, + date.day + ).order_by('date') def get_context_data(self, *args, **kwargs): context = super().get_context_data(*args, **kwargs)