diff options
author | Christian Pointner <equinox@helsinki.at> | 2017-03-09 17:15:11 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2017-03-09 17:15:11 (GMT) |
commit | 25b6bfba7d9b658b545673760445730dd915c461 (patch) | |
tree | df7bda0dd08b6239ac7bc1010f42805c5e411d3a /program | |
parent | 5391d900e79faafd3ace600ef2fc7b4a6e7b5786 (diff) |
Hotfix: datetime.now as callable for query sets to fix implicit 'caching' problem after switching to uwsgi
Diffstat (limited to 'program')
-rw-r--r-- | program/admin.py | 12 | ||||
-rw-r--r-- | program/models.py | 10 | ||||
-rw-r--r-- | program/templates/timeslot_detail.html | 2 | ||||
-rw-r--r-- | program/views.py | 2 |
4 files changed, 13 insertions, 13 deletions
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 %} <h2>{{ timeslot.note.title }}</h2> {% endif %} - <strong>Sendung am {{ timeslot.start|date:"d.m. H:i" }} bis {{ timeslot.end|date:"H:i" }}</strong> + <strong>Sendung am {{ timeslot.start|date:"d.m.Y H:i" }} bis {{ timeslot.end|date:"H:i" }}</strong> <div class="show-abbrevs"> {% 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' |