diff --git a/apps/participation/forms.py b/apps/participation/forms.py index 0a7b4cc..86c58a2 100644 --- a/apps/participation/forms.py +++ b/apps/participation/forms.py @@ -129,3 +129,19 @@ class PoolForm(forms.ModelForm): class Meta: model = Pool fields = ('tournament', 'round', 'juries',) + widgets = { + "juries": forms.CheckboxSelectMultiple, + } + + +class PoolTeamsForm(forms.ModelForm): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.fields["participations"].queryset = self.instance.tournament.participations.all() + + class Meta: + model = Pool + fields = ('participations',) + widgets = { + "participations": forms.CheckboxSelectMultiple, + } diff --git a/apps/participation/templates/participation/pool_detail.html b/apps/participation/templates/participation/pool_detail.html index 94d9808..c13a2d1 100644 --- a/apps/participation/templates/participation/pool_detail.html +++ b/apps/participation/templates/participation/pool_detail.html @@ -1 +1,64 @@ {% extends "base.html" %} + +{% load i18n %} + +{% block content %} +
+
+

{{ pool }}

+
+
+
+
{% trans "Tournament:" %}
+
{{ pool.tournament }}
+ +
{% trans "Round:" %}
+
{{ pool.get_round_display }}
+ +
{% trans "Teams:" %}
+
+ {% for participation in pool.participations.all %} + {{ participation.team }}{% if not forloop.last %}, {% endif %} + {% endfor %} +
+ +
{% trans "Juries:" %}
+
{{ pool.juries.all|join:", " }}
+
+
+ {% if user.registration.is_admin %} + + {% endif %} +
+ + {% trans "Update pool" as modal_title %} + {% trans "Update" as modal_button %} + {% url "participation:pool_update" pk=pool.pk as modal_action %} + {% include "base_modal.html" with modal_id="updatePool" %} + + {% trans "Update teams" as modal_title %} + {% trans "Update" as modal_button %} + {% url "participation:pool_update_teams" pk=pool.pk as modal_action %} + {% include "base_modal.html" with modal_id="updateTeams" %} +{% endblock %} + +{% block extrajavascript %} + +{% endblock %} diff --git a/apps/participation/urls.py b/apps/participation/urls.py index e04784e..c3df0e7 100644 --- a/apps/participation/urls.py +++ b/apps/participation/urls.py @@ -6,8 +6,9 @@ from django.views.generic import TemplateView from .views import CreateTeamView, JoinTeamView, \ MyParticipationDetailView, MyTeamDetailView, ParticipationDetailView, PoolCreateView, PoolDetailView, \ - PoolUpdateView, TeamAuthorizationsView, TeamDetailView, TeamLeaveView, TeamListView, TeamUpdateView, \ - TournamentCreateView, TournamentDetailView, TournamentListView, TournamentUpdateView, SolutionUploadView + PoolUpdateView, PoolUpdateTeamsView, TeamAuthorizationsView, TeamDetailView, TeamLeaveView, TeamListView, \ + TeamUpdateView, TournamentCreateView, TournamentDetailView, TournamentListView, TournamentUpdateView, \ + SolutionUploadView app_name = "participation" @@ -31,5 +32,6 @@ urlpatterns = [ path("pools/create/", PoolCreateView.as_view(), name="pool_create"), path("pools//", PoolDetailView.as_view(), name="pool_detail"), path("pools//update/", PoolUpdateView.as_view(), name="pool_update"), + path("pools//update-teams/", PoolUpdateTeamsView.as_view(), name="pool_update_teams"), path("chat/", TemplateView.as_view(template_name="participation/chat.html"), name="chat") ] diff --git a/apps/participation/views.py b/apps/participation/views.py index f5731b6..253ef34 100644 --- a/apps/participation/views.py +++ b/apps/participation/views.py @@ -23,8 +23,8 @@ from tfjm.lists import get_sympa_client from tfjm.matrix import Matrix from tfjm.views import AdminMixin -from .forms import JoinTeamForm, ParticipationForm, PoolForm, RequestValidationForm, SolutionForm, TeamForm,\ - TournamentForm, ValidateParticipationForm +from .forms import JoinTeamForm, ParticipationForm, PoolForm, PoolTeamsForm, RequestValidationForm, SolutionForm, \ + TeamForm, TournamentForm, ValidateParticipationForm from .models import Participation, Team, Tournament, Solution, Pool from .tables import TeamTable, TournamentTable, ParticipationTable, PoolTable @@ -482,3 +482,8 @@ class PoolDetailView(AdminMixin, DetailView): class PoolUpdateView(AdminMixin, UpdateView): model = Pool form_class = PoolForm + + +class PoolUpdateTeamsView(AdminMixin, UpdateView): + model = Pool + form_class = PoolTeamsForm