diff --git a/apps/participation/forms.py b/apps/participation/forms.py index 3d0d829..fc6249c 100644 --- a/apps/participation/forms.py +++ b/apps/participation/forms.py @@ -80,6 +80,17 @@ class PhaseForm(forms.ModelForm): model = Phase fields = ('start', 'end',) widgets = { - 'start': DateTimePickerInput(), - 'end': DateTimePickerInput(), + 'start': DateTimePickerInput(format='%d/%m/%Y %H:%M'), + 'end': DateTimePickerInput(format='%d/%m/%Y %H:%M'), } + + def clean(self): + # Ensure that dates are in a right order + cleaned_data = super().clean() + if cleaned_data["end"] <= cleaned_data["start"]: + self.add_error("end", _("Start date must be before the end date.")) + if Phase.objects.filter(phase_number__lt=self.instance.phase_number, end__gt=cleaned_data["start"]).exists(): + self.add_error("start", _("This phase must start after the previous phases.")) + if Phase.objects.filter(phase_number__gt=self.instance.phase_number, start__lt=cleaned_data["end"]).exists(): + self.add_error("end", _("This phase must end after the next phases.")) + return cleaned_data diff --git a/apps/participation/tables.py b/apps/participation/tables.py index 45088a9..2ca91c9 100644 --- a/apps/participation/tables.py +++ b/apps/participation/tables.py @@ -12,12 +12,14 @@ class CalendarTable(tables.Table): } row_attrs = { 'class': lambda record: 'bg-success' if timezone.now() > record.end else - 'bg-waring' if timezone.now() > record.start else - 'bg-danger' + 'bg-warning' if timezone.now() > record.start else + 'bg-danger', + 'data-id': lambda record: str(record.phase_number), } model = Phase fields = ('phase_number', 'description', 'start', 'end',) template_name = 'django_tables2/bootstrap4.html' + order_by = ('phase_number',) # noinspection PyTypeChecker diff --git a/apps/participation/templates/participation/phase_form.html b/apps/participation/templates/participation/phase_form.html index a5bb901..b2b3a5c 100644 --- a/apps/participation/templates/participation/phase_form.html +++ b/apps/participation/templates/participation/phase_form.html @@ -3,7 +3,7 @@ {% load crispy_forms_filters i18n %} {% block content %} -
+
{% csrf_token %} {{ form|crispy }} diff --git a/apps/participation/templates/participation/phase_list.html b/apps/participation/templates/participation/phase_list.html index 4cfa8d6..f0554d1 100644 --- a/apps/participation/templates/participation/phase_list.html +++ b/apps/participation/templates/participation/phase_list.html @@ -8,4 +8,22 @@ {% block content %} {% render_table table %} + + {% trans "Update phase" as modal_title %} + {% trans "Update" as modal_button %} + {% include "base_modal.html" with modal_id="updatePhase" %} {% endblock %} + +{% if user.registration.is_admin %} + {% block extrajavascript %} + + {% endblock %} +{% endif %} diff --git a/apps/participation/views.py b/apps/participation/views.py index 97b18ef..2b76884 100644 --- a/apps/participation/views.py +++ b/apps/participation/views.py @@ -287,3 +287,6 @@ class CalendarView(SingleTableView): class PhaseUpdateView(AdminMixin, UpdateView): model = Phase form_class = PhaseForm + + def get_success_url(self): + return reverse_lazy("participation:calendar") diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 6424689..92d89a5 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: Corres2math\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-10-20 13:03+0200\n" +"POT-Creation-Date: 2020-10-20 14:11+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Yohann D'ANELLO \n" "Language-Team: LANGUAGE \n" @@ -99,28 +99,40 @@ msgstr "changelogs" msgid "Changelog of type \"{action}\" for model {model} at {timestamp}" msgstr "Changelog de type \"{action}\" pour le modèle {model} le {timestamp}" -#: apps/participation/forms.py:14 apps/participation/models.py:25 +#: apps/participation/forms.py:15 apps/participation/models.py:25 msgid "The trigram must be composed of three uppercase letters." msgstr "Le trigramme doit être composé de trois lettres majuscules." -#: apps/participation/forms.py:26 +#: apps/participation/forms.py:27 msgid "No team was found with this access code." msgstr "Aucune équipe n'a été trouvée avec ce code d'accès." -#: apps/participation/forms.py:54 +#: apps/participation/forms.py:55 msgid "I engage myself to participate to the whole \"Correspondances\"." msgstr "Je m'engage à participer à l'intégralité des Correspondances." -#: apps/participation/forms.py:66 +#: apps/participation/forms.py:67 msgid "Message to address to the team:" msgstr "Message à adresser à l'équipe :" -#: apps/participation/models.py:18 apps/participation/tables.py:22 -#: apps/participation/tables.py:44 apps/participation/tables.py:70 +#: apps/participation/forms.py:91 +msgid "Start date must be before the end date." +msgstr "La date de début doit être avant la date de fin." + +#: apps/participation/forms.py:93 +msgid "This phase must start after the previous phases." +msgstr "Cette phase doit commencer après les phases précédentes." + +#: apps/participation/forms.py:95 +msgid "This phase must end after the next phases." +msgstr "Cette phase doit finir avant les phases suivantes." + +#: apps/participation/models.py:18 apps/participation/tables.py:30 +#: apps/participation/tables.py:52 apps/participation/tables.py:78 msgid "name" msgstr "nom" -#: apps/participation/models.py:24 apps/participation/tables.py:49 +#: apps/participation/models.py:24 apps/participation/tables.py:57 msgid "trigram" msgstr "trigramme" @@ -163,8 +175,8 @@ msgstr "équipes" msgid "Problem #{problem:d}" msgstr "Problème n°{problem:d}" -#: apps/participation/models.py:86 apps/participation/tables.py:27 -#: apps/participation/tables.py:54 +#: apps/participation/models.py:86 apps/participation/tables.py:35 +#: apps/participation/tables.py:62 msgid "problem number" msgstr "numéro de problème" @@ -311,11 +323,26 @@ msgstr "La plateforme de cette vidéo n'est pas encore supportée." msgid "Upload video" msgstr "Envoyer la vidéo" +#: apps/participation/templates/participation/phase_form.html:11 +#: apps/participation/templates/participation/phase_list.html:13 +#: apps/participation/templates/participation/team_detail.html:61 +#: apps/participation/templates/participation/team_detail.html:117 +#: apps/participation/templates/participation/update_team.html:12 +#: apps/registration/templates/registration/update_user.html:12 +#: apps/registration/templates/registration/user_detail.html:64 +#: apps/registration/templates/registration/user_detail.html:73 +msgid "Update" +msgstr "Modifier" + #: apps/participation/templates/participation/phase_list.html:6 #: templates/base.html:67 msgid "Calendar" msgstr "Calendrier" +#: apps/participation/templates/participation/phase_list.html:12 +msgid "Update phase" +msgstr "Modifier la phase" + #: apps/participation/templates/participation/team_detail.html:14 msgid "Name:" msgstr "Nom :" @@ -348,15 +375,6 @@ msgstr "Autorisations :" msgid "Not uploaded yet" msgstr "Pas encore envoyée" -#: apps/participation/templates/participation/team_detail.html:61 -#: apps/participation/templates/participation/team_detail.html:117 -#: apps/participation/templates/participation/update_team.html:12 -#: apps/registration/templates/registration/update_user.html:12 -#: apps/registration/templates/registration/user_detail.html:64 -#: apps/registration/templates/registration/user_detail.html:73 -msgid "Update" -msgstr "Modifier" - #: apps/participation/templates/participation/team_detail.html:70 msgid "Access to team participation" msgstr "Accéder à la participation de l'équipe" @@ -409,65 +427,65 @@ msgstr "Invalider" msgid "Update team" msgstr "Modifier l'équipe" -#: apps/participation/views.py:29 templates/base.html:73 +#: apps/participation/views.py:30 templates/base.html:73 #: templates/base.html:222 msgid "Create team" msgstr "Créer une équipe" -#: apps/participation/views.py:36 apps/participation/views.py:66 +#: apps/participation/views.py:37 apps/participation/views.py:67 msgid "You don't participate, so you can't create a team." msgstr "Vous ne participez pas, vous ne pouvez pas créer d'équipe." -#: apps/participation/views.py:38 apps/participation/views.py:68 +#: apps/participation/views.py:39 apps/participation/views.py:69 msgid "You are already in a team." msgstr "Vous êtes déjà dans une équipe." -#: apps/participation/views.py:59 templates/base.html:78 +#: apps/participation/views.py:60 templates/base.html:78 #: templates/base.html:218 msgid "Join team" msgstr "Rejoindre une équipe" -#: apps/participation/views.py:94 apps/participation/views.py:248 +#: apps/participation/views.py:95 apps/participation/views.py:249 msgid "You are not in a team." msgstr "Vous n'êtes pas dans une équipe." -#: apps/participation/views.py:95 apps/participation/views.py:249 +#: apps/participation/views.py:96 apps/participation/views.py:250 msgid "You don't participate, so you don't have any team." msgstr "Vous ne participez pas, vous n'avez donc pas d'équipe." -#: apps/participation/views.py:134 +#: apps/participation/views.py:135 msgid "You don't participate, so you can't request the validation of the team." msgstr "" "Vous ne participez pas, vous ne pouvez pas demander la validation de " "l'équipe." -#: apps/participation/views.py:137 +#: apps/participation/views.py:138 msgid "The validation of the team is already done or pending." msgstr "La validation de l'équipe est déjà faite ou en cours." -#: apps/participation/views.py:150 +#: apps/participation/views.py:151 msgid "You are not an administrator." msgstr "Vous n'êtes pas administrateur." -#: apps/participation/views.py:153 +#: apps/participation/views.py:154 msgid "This team has no pending validation." msgstr "L'équipe n'a pas de validation en attente." -#: apps/participation/views.py:175 +#: apps/participation/views.py:176 msgid "You must specify if you validate the registration or not." msgstr "Vous devez spécifier si vous validez l'inscription ou non." -#: apps/participation/views.py:232 apps/registration/views.py:213 +#: apps/participation/views.py:233 apps/registration/views.py:213 #, python-brace-format msgid "Photo authorization of {student}.{ext}" msgstr "Autorisation de droit à l'image de {student}.{ext}" -#: apps/participation/views.py:236 +#: apps/participation/views.py:237 #, python-brace-format msgid "Photo authorizations of team {trigram}.zip" msgstr "Autorisations de droit à l'image de l'équipe {trigram}.zip" -#: apps/participation/views.py:258 +#: apps/participation/views.py:259 msgid "The team is not validated yet." msgstr "L'équipe n'est pas encore validée." @@ -827,10 +845,6 @@ msgstr "Anglais" msgid "French" msgstr "Français" -#: corres2math/views.py:12 -msgid "Only administrators are allowed to perform a full research." -msgstr "Seuls les administrateurs sont autorisés à effectuer une recherche." - #: templates/400.html:6 msgid "Bad request" msgstr "Requête invalide" @@ -975,3 +989,6 @@ msgstr "Résultats" #: templates/search/search.html:26 msgid "No results found." msgstr "Aucun résultat." + +#~ msgid "Only administrators are allowed to perform a full research." +#~ msgstr "Seuls les administrateurs sont autorisés à effectuer une recherche." diff --git a/templates/base_modal.html b/templates/base_modal.html index 51679a2..083a9b4 100644 --- a/templates/base_modal.html +++ b/templates/base_modal.html @@ -2,7 +2,7 @@