Skip to content

Commit

Permalink
Sort bars by start time + don't show old events
Browse files Browse the repository at this point in the history
  • Loading branch information
autoantwort committed Jun 13, 2024
1 parent 523c449 commit 40de256
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions main/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import datetime
from collections import defaultdict
from django.shortcuts import render
from rest_framework import viewsets, permissions
Expand Down Expand Up @@ -52,7 +53,7 @@ class Poster2x(ImageSpec):
# Create your views here.
def main_view(request):
bars_by_weekday = defaultdict(list)
for bar in Bar.objects.all():
for bar in Bar.objects.all().order_by('start_time'):
bars_by_weekday[bar.day].append(bar)
bars = []
for day in Weekday.choices[:-3]:
Expand All @@ -61,8 +62,8 @@ def main_view(request):
'title': 'Home',
'weekdays': Weekday.choices[:-3],
'bars_by_day': bars,
'bars': Bar.objects.all().order_by('day'),
'events': Event.objects.all().order_by('start_date'),
'bars': Bar.objects.all().order_by('day', 'start_time'),
'events': Event.objects.filter(start_date__gte=datetime.date.today()).order_by('start_date'),
'features': request.GET.get('features', '')
})

Expand Down

0 comments on commit 40de256

Please sign in to comment.