diff --git a/dashboard/__pycache__/views.cpython-313.pyc b/dashboard/__pycache__/views.cpython-313.pyc
index 3470ac5..541f399 100644
Binary files a/dashboard/__pycache__/views.cpython-313.pyc and b/dashboard/__pycache__/views.cpython-313.pyc differ
diff --git a/dashboard/templates/dashboard/dashboard.html b/dashboard/templates/dashboard/dashboard.html
index 6956b2e..2bccdec 100644
--- a/dashboard/templates/dashboard/dashboard.html
+++ b/dashboard/templates/dashboard/dashboard.html
@@ -12,28 +12,47 @@
- {% 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