From 852c7768793ffc3fb428fe624a38220b88866800 Mon Sep 17 00:00:00 2001 From: Matthias Nagel Date: Wed, 1 Oct 2025 14:11:39 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20Erweiterung=20der=20Dashboard-Anzeige?= =?UTF-8?q?=20f=C3=BCr=20Trainer=20um=20Spieler-Teilnahmestatus?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dashboard/__pycache__/views.cpython-313.pyc | Bin 2299 -> 3716 bytes dashboard/templates/dashboard/dashboard.html | 45 +++++++++++++------ dashboard/views.py | 28 ++++++++++-- 3 files changed, 56 insertions(+), 17 deletions(-) diff --git a/dashboard/__pycache__/views.cpython-313.pyc b/dashboard/__pycache__/views.cpython-313.pyc index 3470ac5e145de7d11996d21b37134796780459e3..541f399834a4102562e5a2da1baf668a8b40ef68 100644 GIT binary patch delta 2028 zcmZ`(OKcNI7@l1}Vmr3u$Hv65O`In$hBibHxT)v8i+sDKlML!muEFD;dja_GTJBpXu)n-`yLh^zTyqv|^_V)`V${CKd?AyOb#% z(=kTXMbXTf-Du_sLZXGW#DmI3YPi(8&|B9cl(2Lnw$+Wsc7E*oSr>E-8`hFAG{PU; z`N?|_f_Qxmo4s#*U~k{p%~1(jv<)NC4nBJ2IOU?_2WzFYk>v9Zi5@``4TW|>p$^s& zA8fepec^9-PipKqI_5{H6$O##1kW~zaTsE_SZ92=VYByTUGb4U387M5NVGQk6Wy#m z4gsEjSQqO~SR-@;pCF0>WF#$1ztG;oT3H)wPuL>*|M@(v`|M&HKrEH8H^ySrYJ`Fmo`%ufcG)jgG?vdlxez`sxj|rWD`BC2Yg=#U(3R4 zid7dVMW62q(lEfTBT5%xe8hcX2iyLVZuTXdP2G?0bgz4%J;SyqTut^j5gM(-#p)97 z2rYUS-e{D=q6EWw$94v;4<;c9ujn|1LhZ`O`d3RfS>SUVSIF`!0+uwtuq=pjfyZ(t znJMscCNFZ5Aah(%60l~GWYBPOCMP6!PC+dZ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&~G~ic4nM~CFBZo^9uzNBP+#Vk@`~5Z7bUdyBvCm zEGGqVn7k4a99AhwwuKC<;t*lQWl1Pv6XBWJ6|9h7V%NCK8>JGmOzf3Qg&Sh8`KM|OLM_oc3A6belyLf-fj*|0~odz5buBf~)^1x3q2 zj~v@e96Phfs_$CTH0=4=qJd3(kqUUa?KL{x3iv6tKhHnSSFY~`l*$bq(-QYl9`hW+4-d#Cf zm*a2sdjFjrdAy;3&eVYlBHepE=?2FteC6hm0Oa;+veuK^T;7sKYHcHjv>!me1d6?0 ockcks&

Your Events

- {% if events %} + {% if events_with_participation %}
- {% for event in events %} + {% for item in events_with_participation %}
-
{{ event.title }}
- {{ event.start_time|localize }} +
{{ item.event.title }}
+ {{ item.event.start_time|localize }}
-

{{ event.description }}

- Location: {{ event.location_address }} - View on Map - {% if user == event.team.head_coach or user in event.team.assistant_coaches.all %} - Edit - Delete +

{{ item.event.description }}

+ Location: {{ item.event.location_address }} + View on Map + {% if user == item.event.team.head_coach or user in item.event.team.assistant_coaches.all %} + Edit + Delete + +
+
Player Participation ({{ item.accepted_count }}/{{ item.required_players }})
+
+
    + {% for p in item.player_participations %} +
  • {{ p.player.first_name }} {{ p.player.last_name }}
  • + {% endfor %} +
+
+
{% endif %}
{% endfor %} @@ -79,4 +98,4 @@ {% endif %} {% endfor %} {% endif %} -{% endblock %} +{% endblock %} \ No newline at end of file diff --git a/dashboard/views.py b/dashboard/views.py index b32cb94..29beb00 100644 --- a/dashboard/views.py +++ b/dashboard/views.py @@ -6,7 +6,7 @@ from clubs.models import Team @login_required def dashboard(request): user = request.user - events = [] + events_with_participation = [] children_events = [] # Get user's own events @@ -18,7 +18,27 @@ def dashboard(request): from itertools import chain all_teams = list(set(chain(player_teams, coached_teams, assisted_teams))) if all_teams: - events = Event.objects.filter(team__in=all_teams).select_related('game', 'training').order_by('start_time') + events = Event.objects.filter(team__in=all_teams).select_related('game', 'training').prefetch_related('team__players', 'eventparticipation_set__user').order_by('start_time') + + for event in events: + participations = event.eventparticipation_set.all() + accepted_count = sum(1 for p in participations if p.status == 'attending') + required_players = event.game.min_players if hasattr(event, 'game') else 0 + + player_participations = [] + team_players = event.team.players.all() + participation_map = {p.user_id: p.status for p in participations} + + for player in team_players: + status = participation_map.get(player.id, 'maybe') + player_participations.append({'player': player, 'status': status}) + + events_with_participation.append({ + 'event': event, + 'accepted_count': accepted_count, + 'required_players': required_players, + 'player_participations': player_participations + }) # Get children's events if hasattr(user, 'children'): @@ -32,7 +52,7 @@ def dashboard(request): children_events.append({'child': child, 'events': child_events_list}) context = { - 'events': events, + 'events_with_participation': events_with_participation, 'children_events': children_events, } - return render(request, 'dashboard/dashboard.html', context) + return render(request, 'dashboard/dashboard.html', context) \ No newline at end of file