Update calendar

This commit is contained in:
Yohann D'ANELLO 2020-10-20 14:21:16 +02:00
parent 2d467ef3af
commit 42e1abd9aa
7 changed files with 94 additions and 43 deletions

View File

@ -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

View File

@ -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

View File

@ -3,7 +3,7 @@
{% load crispy_forms_filters i18n %}
{% block content %}
<form method="post">
<form method="post" action="{% url "participation:update_phase" pk=object.pk %}">
<div id="form-content">
{% csrf_token %}
{{ form|crispy }}

View File

@ -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 %}
<script>
$("tr").click(function () {
let modalBody = $("#updatePhaseModal div.modal-body");
if (!modalBody.html().trim())
modalBody.load("{% url "participation:calendar" %}" + $(this).data("id") + "/ #form-content");
$("#updatePhase-form").attr("action", "{% url "participation:calendar" %}" + $(this).data("id") + "/")
$("#updatePhaseModal").modal();
})
</script>
{% endblock %}
{% endif %}

View File

@ -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")

View File

@ -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 <yohann.danello@animath.fr>\n"
"Language-Team: LANGUAGE <LL@li.org>\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."

View File

@ -2,7 +2,7 @@
<div id="{{ modal_id }}Modal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog {{ modal_additional_class }}" role="document">
<form method="{{ modal_form_method|default:"post" }}" action="{{ modal_action }}" enctype="{{ modal_enctype|default:"application/x-www-form-urlencoded" }}">
<form id="{{ modal_id }}-form" method="{{ modal_form_method|default:"post" }}" action="{{ modal_action }}" enctype="{{ modal_enctype|default:"application/x-www-form-urlencoded" }}">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{{ modal_title }}</h5>