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
@ -88,6 +88,9 @@ def dashboard(request):
|
||||
'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
|
||||
if hasattr(user, 'children'):
|
||||
print('haschild')
|
||||
@ -103,6 +106,9 @@ def dashboard(request):
|
||||
for event in child_events:
|
||||
participation, created = EventParticipation.objects.get_or_create(user=child, event=event)
|
||||
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})
|
||||
|
||||
context = {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user