Skip to content

Commit

Permalink
fix(hearing): make open filter timezone aware
Browse files Browse the repository at this point in the history
Refs KER-366
  • Loading branch information
danipran committed May 28, 2024
1 parent 92ad624 commit 84b3084
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions democracy/views/hearing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import datetime
import django_filters
from collections import defaultdict
from django.conf import settings
Expand Down Expand Up @@ -64,14 +63,14 @@ def filter_following(self, queryset, name, value):
def filter_open(self, queryset, name, value):
if value:
return (
queryset.filter(close_at__gt=datetime.datetime.now())
.filter(open_at__lte=datetime.datetime.now())
queryset.filter(close_at__gt=timezone.now())
.filter(open_at__lte=timezone.now())
.filter(force_closed=False)
)
else:
return (
queryset.filter(close_at__lte=datetime.datetime.now())
| queryset.filter(open_at__gt=datetime.datetime.now())
queryset.filter(close_at__lte=timezone.now())
| queryset.filter(open_at__gt=timezone.now())
| queryset.filter(force_closed=True)
).distinct()

Expand Down

0 comments on commit 84b3084

Please sign in to comment.