Skip to content

Commit

Permalink
Refactor: Update current_stop_id retrieval in itinerary_overview
Browse files Browse the repository at this point in the history
  • Loading branch information
drikusroor committed Oct 6, 2024
1 parent c8b54c8 commit 536adc1
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/locations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ def itinerary_overview(request):
current_date = date.today()

# get the current_stop, aka the stop that is happening today, aka the stop that has the start_date <= current_date <= end_date
current_stop_id = (
itinerary.stops.filter(start_date__lte=current_date, end_date__gte=current_date)
.first()
.id
)
current_stop = itinerary.stops.filter(
start_date__lte=current_date, end_date__gte=current_date
).first()

# get the current_stop_id
current_stop_id = current_stop.id if current_stop else None

context = {
"itinerary": itinerary,
Expand Down

0 comments on commit 536adc1

Please sign in to comment.