From 25b6bfba7d9b658b545673760445730dd915c461 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Thu, 9 Mar 2017 18:15:11 +0100 Subject: Hotfix: datetime.now as callable for query sets to fix implicit 'caching' problem after switching to uwsgi diff --git a/program/admin.py b/program/admin.py index 413531e..eb55554 100644 --- a/program/admin.py +++ b/program/admin.py @@ -19,21 +19,21 @@ class ActivityFilter(admin.SimpleListFilter): def queryset(self, request, queryset): if self.parameter_name == 'has_timeslots': # active/inactive ProgramSlots if self.value() == 'yes': - return queryset.filter(until__gt=datetime.now()).distinct() + return queryset.filter(until__gt=datetime.now).distinct() if self.value() == 'no': - return queryset.filter(until__lt=datetime.now()).distinct() + return queryset.filter(until__lt=datetime.now).distinct() if self.parameter_name == 'has_programslots_timeslots': # active/inactive Shows if self.value() == 'yes': - return queryset.filter(programslots__until__gt=datetime.now()).distinct() + return queryset.filter(programslots__until__gt=datetime.now).distinct() if self.value() == 'no': - return queryset.filter(programslots__until__lt=datetime.now()).distinct() + return queryset.filter(programslots__until__lt=datetime.now).distinct() if self.parameter_name == 'has_shows_programslots_timeslots': # active/inactive Hosts if self.value() == 'yes': - return queryset.filter(shows__programslots__until__gt=datetime.now()).distinct() + return queryset.filter(shows__programslots__until__gt=datetime.now).distinct() if self.value() == 'no': - return queryset.filter(shows__programslots__until__lt=datetime.now()).distinct() + return queryset.filter(shows__programslots__until__lt=datetime.now).distinct() class ActiveProgramSlotsFilter(ActivityFilter): diff --git a/program/models.py b/program/models.py index 9945145..d52d1bf 100644 --- a/program/models.py +++ b/program/models.py @@ -226,7 +226,7 @@ class Host(models.Model): return reverse('host-detail', args=[str(self.id)]) def active_shows(self): - return self.shows.filter(programslots__until__gt=datetime.today()) + return self.shows.filter(programslots__until__gt=datetime.today) class Show(models.Model): @@ -404,16 +404,16 @@ class TimeSlotManager(models.Manager): @staticmethod def get_or_create_current(): try: - return TimeSlot.objects.get(start__lte=datetime.now(), end__gt=datetime.now()) + return TimeSlot.objects.get(start__lte=datetime.now, end__gt=datetime.now) except MultipleObjectsReturned: - return TimeSlot.objects.filter(start__lte=datetime.now(), end__gt=datetime.now())[0] + return TimeSlot.objects.filter(start__lte=datetime.now, end__gt=datetime.now)[0] except ObjectDoesNotExist: once = RRule.objects.get(pk=1) today = date.today().weekday() default = Show.objects.get(pk=1) - previous_timeslot = TimeSlot.objects.filter(end__lte=datetime.now()).order_by('-start')[0] - next_timeslot = TimeSlot.objects.filter(start__gte=datetime.now())[0] + previous_timeslot = TimeSlot.objects.filter(end__lte=datetime.now).order_by('-start')[0] + next_timeslot = TimeSlot.objects.filter(start__gte=datetime.now)[0] dstart, tstart = previous_timeslot.end.date(), previous_timeslot.end.time() until, tend = next_timeslot.start.date(), next_timeslot.start.time() diff --git a/program/templates/timeslot_detail.html b/program/templates/timeslot_detail.html index cfe2b7b..88749a2 100644 --- a/program/templates/timeslot_detail.html +++ b/program/templates/timeslot_detail.html @@ -13,7 +13,7 @@ {% if timeslot.note %}

{{ timeslot.note.title }}

{% endif %} - Sendung am {{ timeslot.start|date:"d.m. H:i" }} bis {{ timeslot.end|date:"H:i" }} + Sendung am {{ timeslot.start|date:"d.m.Y H:i" }} bis {{ timeslot.end|date:"H:i" }}
{% for si in timeslot.show.showinformation.all %} diff --git a/program/views.py b/program/views.py index 7f9b1ce..53467cd 100644 --- a/program/views.py +++ b/program/views.py @@ -15,7 +15,7 @@ from program.utils import tofirstdayinisoweek class HostListView(ListView): context_object_name = 'host_list' - queryset = Host.objects.filter(Q(is_always_visible=True) | Q(shows__programslots__until__gt=datetime.now())).distinct() + queryset = Host.objects.filter(Q(is_always_visible=True) | Q(shows__programslots__until__gt=datetime.now)).distinct() template_name = 'host_list.html' -- cgit v0.10.2