diff --git a/dashboard/templates/dashboard/dashboard.html b/dashboard/templates/dashboard/dashboard.html index cb56979..3c6c195 100644 --- a/dashboard/templates/dashboard/dashboard.html +++ b/dashboard/templates/dashboard/dashboard.html @@ -8,6 +8,7 @@
{% if user.coached_teams.all or user.assisted_teams.all %} Create New Event + Player List {% endif %}
diff --git a/dashboard/templates/dashboard/player_list.html b/dashboard/templates/dashboard/player_list.html new file mode 100644 index 0000000..7b21f4a --- /dev/null +++ b/dashboard/templates/dashboard/player_list.html @@ -0,0 +1,63 @@ +{% extends "base.html" %} + +{% block content %} +
+

Player List

+ +
+
+ + +
+
+ + + + + + + + + + + {% for player in players %} + + + + + + {% endfor %} + +
NameTeamPlayer Number
{{ player.first_name }} {{ player.last_name }}{{ player.team.name }}{{ player.player_number }}
+
+ +{% block extra_js %} + +{% endblock %} +{% endblock %} diff --git a/dashboard/urls.py b/dashboard/urls.py index ca81b57..f92d1f8 100644 --- a/dashboard/urls.py +++ b/dashboard/urls.py @@ -3,4 +3,5 @@ from . import views urlpatterns = [ path('', views.dashboard, name='dashboard'), + path('players/', views.player_list, name='player_list'), ] \ No newline at end of file diff --git a/dashboard/views.py b/dashboard/views.py index 541a501..5191d5d 100644 --- a/dashboard/views.py +++ b/dashboard/views.py @@ -2,6 +2,7 @@ from django.shortcuts import render from django.contrib.auth.decorators import login_required from calendars.models import Event, EventParticipation from clubs.models import Team +from accounts.models import CustomUser from django.db.models import Q from django.utils import timezone import datetime @@ -109,3 +110,23 @@ def dashboard(request): 'now': timezone.now() } return render(request, 'dashboard/dashboard.html', context) + +@login_required +def player_list(request): + user = request.user + coached_teams = user.coached_teams.all() + assisted_teams = user.assisted_teams.all() + + all_coached_teams = list(coached_teams) + for team in coached_teams: + all_coached_teams.extend(get_all_child_teams(team)) + + all_teams = set(list(all_coached_teams) + list(assisted_teams)) + + players = CustomUser.objects.filter(team__in=all_teams).distinct() + + context = { + 'players': players, + 'teams': all_teams + } + return render(request, 'dashboard/player_list.html', context)