From e53575d31d526262e94c08069fd8363b264e5dd2 Mon Sep 17 00:00:00 2001 From: Emmy D'Anello Date: Sun, 31 Mar 2024 13:30:19 +0200 Subject: [PATCH] Remove "Add passage" and "Udate pool teams" forms since they can lead to unwanted states. Pool teams and passages are managed by the draw system. If needed, use the admin interface Signed-off-by: Emmy D'Anello --- participation/forms.py | 18 -------- .../templates/participation/pool_detail.html | 14 ------ participation/urls.py | 6 +-- participation/views.py | 45 +------------------ 4 files changed, 3 insertions(+), 80 deletions(-) diff --git a/participation/forms.py b/participation/forms.py index 6b8627c..2c097d0 100644 --- a/participation/forms.py +++ b/participation/forms.py @@ -192,24 +192,6 @@ class PoolForm(forms.ModelForm): } -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.SelectMultiple(attrs={ - 'class': 'selectpicker', - 'data-live-search': 'true', - 'data-live-search-normalize': 'true', - 'data-width': 'fit', - }), - } - - class AddJuryForm(forms.ModelForm): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) diff --git a/participation/templates/participation/pool_detail.html b/participation/templates/participation/pool_detail.html index 55a2639..e9a5218 100644 --- a/participation/templates/participation/pool_detail.html +++ b/participation/templates/participation/pool_detail.html @@ -125,9 +125,7 @@ {% if user.registration.is_volunteer %} {% endif %} @@ -138,21 +136,11 @@ {% render_table passages %} - {% trans "Add passage" as modal_title %} - {% trans "Add" as modal_button %} - {% url "participation:passage_create" pk=pool.pk as modal_action %} - {% include "base_modal.html" with modal_id="addPassage" modal_button_type="success" %} - {% 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" %} - {% trans "Upload notes" as modal_title %} {% trans "Upload" as modal_button %} {% url "participation:pool_upload_notes" pk=pool.pk as modal_action %} @@ -163,8 +151,6 @@ diff --git a/participation/urls.py b/participation/urls.py index 2634262..45f4dca 100644 --- a/participation/urls.py +++ b/participation/urls.py @@ -5,9 +5,9 @@ from django.urls import path from django.views.generic import TemplateView from .views import CreateTeamView, FinalNotationSheetTemplateView, JoinTeamView, MyParticipationDetailView, \ - MyTeamDetailView, NotationSheetsArchiveView, NoteUpdateView, ParticipationDetailView, PassageCreateView, \ + MyTeamDetailView, NotationSheetsArchiveView, NoteUpdateView, ParticipationDetailView, \ PassageDetailView, PassageUpdateView, PoolCreateView, PoolDetailView, PoolJuryView, PoolNotesTemplateView, \ - PoolPresideJuryView, PoolRemoveJuryView, PoolUpdateTeamsView, PoolUpdateView, PoolUploadNotesView, \ + PoolPresideJuryView, PoolRemoveJuryView, PoolUpdateView, PoolUploadNotesView, \ ScaleNotationSheetTemplateView, SolutionsDownloadView, SolutionUploadView, SynthesisUploadView, \ TeamAuthorizationsView, TeamDetailView, TeamLeaveView, TeamListView, TeamUpdateView, \ TeamUploadMotivationLetterView, TournamentCreateView, TournamentDetailView, TournamentExportCSVView, \ @@ -60,13 +60,11 @@ urlpatterns = [ path("pools//notation/scale/", ScaleNotationSheetTemplateView.as_view(), name="pool_scale_note_sheet"), path("pools//notation/final/", FinalNotationSheetTemplateView.as_view(), name="pool_final_note_sheet"), path("pools//notation/sheets/", NotationSheetsArchiveView.as_view(), name="pool_notation_sheets"), - path("pools//update-teams/", PoolUpdateTeamsView.as_view(), name="pool_update_teams"), path("pools//jury/", PoolJuryView.as_view(), name="pool_jury"), path("pools//jury/remove//", PoolRemoveJuryView.as_view(), name="pool_remove_jury"), path("pools//jury/preside//", PoolPresideJuryView.as_view(), name="pool_preside"), path("pools//upload-notes/", PoolUploadNotesView.as_view(), name="pool_upload_notes"), path("pools//upload-notes/template/", PoolNotesTemplateView.as_view(), name="pool_notes_template"), - path("pools/passages/add//", PassageCreateView.as_view(), name="passage_create"), path("pools/passages//", PassageDetailView.as_view(), name="passage_detail"), path("pools/passages//update/", PassageUpdateView.as_view(), name="passage_update"), path("pools/passages//solution/", SynthesisUploadView.as_view(), name="upload_synthesis"), diff --git a/participation/views.py b/participation/views.py index 3ff477f..7963bb1 100644 --- a/participation/views.py +++ b/participation/views.py @@ -40,7 +40,7 @@ from tfjm.lists import get_sympa_client from tfjm.views import AdminMixin, VolunteerMixin from .forms import AddJuryForm, JoinTeamForm, MotivationLetterForm, NoteForm, ParticipationForm, PassageForm, \ - PoolForm, PoolTeamsForm, RequestValidationForm, SolutionForm, SynthesisForm, TeamForm, TournamentForm, \ + PoolForm, RequestValidationForm, SolutionForm, SynthesisForm, TeamForm, TournamentForm, \ UploadNotesForm, ValidateParticipationForm from .models import Note, Participation, Passage, Pool, Solution, Synthesis, Team, Tournament, Tweak from .tables import NoteTable, ParticipationTable, PassageTable, PoolTable, TeamTable, TournamentTable @@ -888,20 +888,6 @@ class PoolUpdateView(VolunteerMixin, UpdateView): return ret -class PoolUpdateTeamsView(VolunteerMixin, UpdateView): - model = Pool - form_class = PoolTeamsForm - - def dispatch(self, request, *args, **kwargs): - if not request.user.is_authenticated: - return self.handle_no_permission() - if request.user.registration.is_admin or request.user.registration.is_volunteer \ - and (self.get_object().tournament in request.user.registration.organized_tournaments.all() - or request.user.registration in self.get_object().juries.all()): - return super().dispatch(request, *args, **kwargs) - return self.handle_no_permission() - - class SolutionsDownloadView(VolunteerMixin, View): """ Download all solutions or syntheses as a ZIP archive. @@ -1881,35 +1867,6 @@ class NotationSheetsArchiveView(VolunteerMixin, DetailView): return response -class PassageCreateView(VolunteerMixin, CreateView): - model = Passage - form_class = PassageForm - - def dispatch(self, request, *args, **kwargs): - if not request.user.is_authenticated: - return self.handle_no_permission() - - qs = Pool.objects.filter(pk=self.kwargs["pk"]) - if not qs.exists(): - raise Http404 - self.pool = qs.get() - - if request.user.registration.is_admin or request.user.registration.is_volunteer \ - and (self.pool.tournament in request.user.registration.organized_tournaments.all() - or request.user.registration in self.pool.juries.all()): - return super().dispatch(request, *args, **kwargs) - - return self.handle_no_permission() - - def get_form(self, form_class=None): - form = super().get_form(form_class) - form.instance.pool = self.pool - form.fields["defender"].queryset = self.pool.participations.all() - form.fields["opponent"].queryset = self.pool.participations.all() - form.fields["reporter"].queryset = self.pool.participations.all() - return form - - class PassageDetailView(LoginRequiredMixin, DetailView): model = Passage