diff --git a/apps/participation/tables.py b/apps/participation/tables.py index dc34b04..45088a9 100644 --- a/apps/participation/tables.py +++ b/apps/participation/tables.py @@ -1,7 +1,23 @@ +from django.utils import timezone from django.utils.translation import gettext_lazy as _ import django_tables2 as tables -from .models import Team +from .models import Phase, Team + + +class CalendarTable(tables.Table): + class Meta: + attrs = { + 'class': 'table table condensed table-striped', + } + row_attrs = { + 'class': lambda record: 'bg-success' if timezone.now() > record.end else + 'bg-waring' if timezone.now() > record.start else + 'bg-danger' + } + model = Phase + fields = ('phase_number', 'description', 'start', 'end',) + template_name = 'django_tables2/bootstrap4.html' # noinspection PyTypeChecker diff --git a/apps/participation/templates/participation/phase_list.html b/apps/participation/templates/participation/phase_list.html new file mode 100644 index 0000000..4cfa8d6 --- /dev/null +++ b/apps/participation/templates/participation/phase_list.html @@ -0,0 +1,11 @@ +{% extends "base.html" %} + +{% load django_tables2 i18n %} + +{% block contenttitle %} +

{% trans "Calendar" %}

+{% endblock %} + +{% block content %} + {% render_table table %} +{% endblock %} diff --git a/apps/participation/urls.py b/apps/participation/urls.py index f094335..121dc75 100644 --- a/apps/participation/urls.py +++ b/apps/participation/urls.py @@ -1,7 +1,7 @@ from django.urls import path -from .views import CreateTeamView, JoinTeamView, MyParticipationDetailView, MyTeamDetailView, ParticipationDetailView,\ - TeamAuthorizationsView, TeamDetailView, TeamUpdateView, UploadVideoView +from .views import CalendarView, CreateTeamView, JoinTeamView, MyParticipationDetailView, MyTeamDetailView, \ + ParticipationDetailView,TeamAuthorizationsView, TeamDetailView, TeamUpdateView, UploadVideoView app_name = "participation" @@ -16,4 +16,5 @@ urlpatterns = [ path("detail/", MyParticipationDetailView.as_view(), name="my_participation_detail"), path("detail//", ParticipationDetailView.as_view(), name="participation_detail"), path("detail/upload-video//", UploadVideoView.as_view(), name="upload_video"), + path("calendar/", CalendarView.as_view(), name="calendar"), ] diff --git a/apps/participation/views.py b/apps/participation/views.py index 6066e19..d777916 100644 --- a/apps/participation/views.py +++ b/apps/participation/views.py @@ -13,12 +13,14 @@ from django.urls import reverse_lazy from django.utils.translation import gettext_lazy as _ from django.views.generic import CreateView, DetailView, FormView, RedirectView, UpdateView from django.views.generic.edit import FormMixin, ProcessFormView +from django_tables2 import SingleTableView from magic import Magic from registration.models import AdminRegistration from .forms import JoinTeamForm, ParticipationForm, RequestValidationForm, TeamForm, UploadVideoForm,\ ValidateParticipationForm -from .models import Participation, Team, Video +from .models import Participation, Phase, Team, Video +from .tables import CalendarTable class CreateTeamView(LoginRequiredMixin, CreateView): @@ -274,3 +276,8 @@ class UploadVideoView(LoginRequiredMixin, UpdateView): def get_success_url(self): return reverse_lazy("participation:participation_detail", args=(self.object.participation.pk,)) + + +class CalendarView(SingleTableView): + table_class = CalendarTable + model = Phase diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 93fd81b..6424689 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 12:54+0200\n" +"POT-Creation-Date: 2020-10-20 13:03+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: Yohann D'ANELLO \n" "Language-Team: LANGUAGE \n" @@ -115,12 +115,12 @@ msgstr "Je m'engage à participer à l'intégralité des Correspondances." msgid "Message to address to the team:" msgstr "Message à adresser à l'équipe :" -#: apps/participation/models.py:18 apps/participation/tables.py:12 -#: apps/participation/tables.py:34 apps/participation/tables.py:60 +#: apps/participation/models.py:18 apps/participation/tables.py:22 +#: apps/participation/tables.py:44 apps/participation/tables.py:70 msgid "name" msgstr "nom" -#: apps/participation/models.py:24 apps/participation/tables.py:39 +#: apps/participation/models.py:24 apps/participation/tables.py:49 msgid "trigram" msgstr "trigramme" @@ -163,8 +163,8 @@ msgstr "équipes" msgid "Problem #{problem:d}" msgstr "Problème n°{problem:d}" -#: apps/participation/models.py:86 apps/participation/tables.py:17 -#: apps/participation/tables.py:44 +#: apps/participation/models.py:86 apps/participation/tables.py:27 +#: apps/participation/tables.py:54 msgid "problem number" msgstr "numéro de problème" @@ -255,12 +255,12 @@ msgid "phases" msgstr "phases" #: apps/participation/templates/participation/create_team.html:11 -#: templates/base.html:220 +#: templates/base.html:223 msgid "Create" msgstr "Créer" #: apps/participation/templates/participation/join_team.html:11 -#: templates/base.html:216 +#: templates/base.html:219 msgid "Join" msgstr "Rejoindre" @@ -311,6 +311,11 @@ 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_list.html:6 +#: templates/base.html:67 +msgid "Calendar" +msgstr "Calendrier" + #: apps/participation/templates/participation/team_detail.html:14 msgid "Name:" msgstr "Nom :" @@ -404,65 +409,65 @@ msgstr "Invalider" msgid "Update team" msgstr "Modifier l'équipe" -#: apps/participation/views.py:27 templates/base.html:70 -#: templates/base.html:219 +#: apps/participation/views.py:29 templates/base.html:73 +#: templates/base.html:222 msgid "Create team" msgstr "Créer une équipe" -#: apps/participation/views.py:34 apps/participation/views.py:64 +#: apps/participation/views.py:36 apps/participation/views.py:66 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:36 apps/participation/views.py:66 +#: apps/participation/views.py:38 apps/participation/views.py:68 msgid "You are already in a team." msgstr "Vous êtes déjà dans une équipe." -#: apps/participation/views.py:57 templates/base.html:75 -#: templates/base.html:215 +#: apps/participation/views.py:59 templates/base.html:78 +#: templates/base.html:218 msgid "Join team" msgstr "Rejoindre une équipe" -#: apps/participation/views.py:92 apps/participation/views.py:246 +#: apps/participation/views.py:94 apps/participation/views.py:248 msgid "You are not in a team." msgstr "Vous n'êtes pas dans une équipe." -#: apps/participation/views.py:93 apps/participation/views.py:247 +#: apps/participation/views.py:95 apps/participation/views.py:249 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:132 +#: apps/participation/views.py:134 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:135 +#: apps/participation/views.py:137 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:148 +#: apps/participation/views.py:150 msgid "You are not an administrator." msgstr "Vous n'êtes pas administrateur." -#: apps/participation/views.py:151 +#: apps/participation/views.py:153 msgid "This team has no pending validation." msgstr "L'équipe n'a pas de validation en attente." -#: apps/participation/views.py:173 +#: apps/participation/views.py:175 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:230 apps/registration/views.py:213 +#: apps/participation/views.py:232 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:234 +#: apps/participation/views.py:236 #, 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:256 +#: apps/participation/views.py:258 msgid "The team is not validated yet." msgstr "L'équipe n'est pas encore validée." @@ -655,7 +660,7 @@ msgid "Your password has been set. You may go ahead and log in now." msgstr "Votre mot de passe a été changé. Vous pouvez désormais vous connecter." #: apps/registration/templates/registration/password_reset_complete.html:10 -#: templates/base.html:123 templates/base.html:210 templates/base.html:211 +#: templates/base.html:126 templates/base.html:213 templates/base.html:214 #: templates/registration/login.html:7 templates/registration/login.html:8 #: templates/registration/login.html:25 msgid "Log in" @@ -883,43 +888,43 @@ msgstr "" msgid "Home" msgstr "Accueil" -#: templates/base.html:81 +#: templates/base.html:84 msgid "My team" msgstr "Mon équipe" -#: templates/base.html:86 +#: templates/base.html:89 msgid "My participation" msgstr "Ma participation" -#: templates/base.html:93 +#: templates/base.html:96 msgid "Make a gift" msgstr "Faire un don" -#: templates/base.html:97 +#: templates/base.html:100 msgid "Administration" msgstr "Administration" -#: templates/base.html:105 +#: templates/base.html:108 msgid "Search..." msgstr "Chercher ..." -#: templates/base.html:114 +#: templates/base.html:117 msgid "Return to admin view" msgstr "Retourner à l'interface administrateur" -#: templates/base.html:119 +#: templates/base.html:122 msgid "Register" msgstr "S'inscrire" -#: templates/base.html:135 +#: templates/base.html:138 msgid "My account" msgstr "Mon compte" -#: templates/base.html:138 +#: templates/base.html:141 msgid "Log out" msgstr "Déconnexion" -#: templates/base.html:154 +#: templates/base.html:157 #, python-format msgid "" "Your email address is not validated. Please click on the link you received " @@ -930,11 +935,11 @@ msgstr "" "avez reçu par mail. Vous pouvez renvoyer un mail en cliquant sur ce lien." -#: templates/base.html:177 +#: templates/base.html:180 msgid "Contact us" msgstr "Nous contacter" -#: templates/base.html:208 +#: templates/base.html:211 msgid "Search results" msgstr "Résultats de la recherche" diff --git a/templates/base.html b/templates/base.html index 5bc6855..38effba 100644 --- a/templates/base.html +++ b/templates/base.html @@ -63,6 +63,9 @@ + {% if user.is_authenticated and user.registration.participates %} {% if not user.registration.team %}