Fix: Chronologische Sortierung der Events im Dashboard
Stellt sicher, dass die Event-Listen ('Your Events' und 'Children Events')
im Dashboard konsistent chronologisch nach dem sortiert sind.
Obwohl die Datenbankabfragen bereits eine Sortierung enthielten, ging diese
durch die anschließende Verarbeitung in Python-Listen verloren. Die Listen
werden nun nach ihrer Erstellung explizit in Python sortiert.
Änderungen:
- Die -Liste wird nach ihrer Befüllung nach
sortiert.
- Die für jedes Kind wird ebenfalls nach
sortiert, bevor sie dem Kontext hinzugefügt wird.
This commit is contained in:
parent
20075fbe1f
commit
223dd65382
@ -87,6 +87,9 @@ def dashboard(request):
|
|||||||
'days_until_event': days_until_event,
|
'days_until_event': days_until_event,
|
||||||
'local_start_time_iso': local_start_time.isoformat()
|
'local_start_time_iso': local_start_time.isoformat()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# Sort the final list by event start time
|
||||||
|
events_with_participation.sort(key=lambda x: x['event'].start_time)
|
||||||
|
|
||||||
# Get children's events
|
# Get children's events
|
||||||
if hasattr(user, 'children'):
|
if hasattr(user, 'children'):
|
||||||
@ -103,6 +106,9 @@ def dashboard(request):
|
|||||||
for event in child_events:
|
for event in child_events:
|
||||||
participation, created = EventParticipation.objects.get_or_create(user=child, event=event)
|
participation, created = EventParticipation.objects.get_or_create(user=child, event=event)
|
||||||
child_events_list.append({'event': event, 'participation': participation})
|
child_events_list.append({'event': event, 'participation': participation})
|
||||||
|
|
||||||
|
# Sort each child's event list
|
||||||
|
child_events_list.sort(key=lambda x: x['event'].start_time)
|
||||||
children_events.append({'child': child, 'events': child_events_list})
|
children_events.append({'child': child, 'events': child_events_list})
|
||||||
|
|
||||||
context = {
|
context = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user