Factorize modal templates

This commit is contained in:
Yohann D'ANELLO 2020-09-24 21:43:45 +02:00
parent 471befb1f8
commit e1ca18085a
10 changed files with 86 additions and 155 deletions

View File

@ -1,21 +0,0 @@
{% load i18n %}
<div id="joinTeamModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<form method="post" action="{% url "participation:join_team" %}">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{% trans "Join team" %}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">{% trans "Join" %}</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">{% trans "Close" %}</button>
</div>
</div>
</form>
</div>
</div>

View File

@ -38,7 +38,10 @@
</div> </div>
</div> </div>
{% include "participation/update_team_modal.html" %} {% trans "Update team" as modal_title %}
{% trans "Update" as modal_button %}
{% url "participation:update_team" pk=team.pk as modal_action %}
{% include "base_modal.html" with modal_id="updateTeam" %}
{% endblock %} {% endblock %}
{% block extrajavascript %} {% block extrajavascript %}

View File

@ -1,21 +0,0 @@
{% load i18n %}
<div id="updateTeamModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<form method="post" action="{% url "participation:update_team" pk=team.pk %}">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{% trans "Update team" %}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">{% trans "Update" %}</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">{% trans "Close" %}</button>
</div>
</div>
</form>
</div>
</div>

View File

@ -1,21 +0,0 @@
{% load crispy_forms_filters i18n %}
<div id="loginModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<form method="post" action="{% url "login" %}">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{% trans "Log in" %}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">{% trans "Log in" %}</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">{% trans "Close" %}</button>
</div>
</div>
</form>
</div>
</div>

View File

@ -1,21 +0,0 @@
{% load i18n %}
<div id="updateUserModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<form method="post" action="{% url "registration:update_user" pk=user.pk %}">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">{% trans "Update user" %}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">{% trans "Update" %}</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">{% trans "Close" %}</button>
</div>
</div>
</form>
</div>
</div>

View File

@ -44,7 +44,11 @@
</div> </div>
</div> </div>
{% include "registration/update_user_modal.html" %}
{% trans "Update user" as modal_title %}
{% trans "Update" as modal_button %}
{% url "registration:update_user" pk=user_object.pk as modal_action %}
{% include "base_modal.html" with modal_id="updateUser" %}
{% endblock %} {% endblock %}
{% block extrajavascript %} {% block extrajavascript %}

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Corres2math\n" "Project-Id-Version: Corres2math\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-09-24 18:52+0200\n" "POT-Creation-Date: 2020-09-24 21:42+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Yohann D'ANELLO <yohann.danello@animath.fr>\n" "Last-Translator: Yohann D'ANELLO <yohann.danello@animath.fr>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -30,11 +30,7 @@ msgid "This task failed successfully."
msgstr "Cette tâche a échoué avec succès." msgstr "Cette tâche a échoué avec succès."
#: apps/eastereggs/templates/eastereggs/xp_modal.html:16 #: apps/eastereggs/templates/eastereggs/xp_modal.html:16
#: apps/participation/templates/participation/create_team_modal.html:16 #: templates/base_modal.html:16
#: apps/participation/templates/participation/join_team_modal.html:16
#: apps/participation/templates/participation/update_team_modal.html:16
#: apps/registration/templates/registration/login_modal.html:16
#: apps/registration/templates/registration/update_user_modal.html:16
msgid "Close" msgid "Close"
msgstr "Fermer" msgstr "Fermer"
@ -42,7 +38,7 @@ msgstr "Fermer"
msgid "Logs" msgid "Logs"
msgstr "Logs" msgstr "Logs"
#: apps/logs/models.py:22 apps/registration/models.py:15 #: apps/logs/models.py:22 apps/registration/models.py:17
msgid "user" msgid "user"
msgstr "utilisateur" msgstr "utilisateur"
@ -145,7 +141,7 @@ msgid "Team {name} ({trigram})"
msgstr "Équipe {name} ({trigram})" msgstr "Équipe {name} ({trigram})"
#: apps/participation/models.py:45 apps/participation/models.py:56 #: apps/participation/models.py:45 apps/participation/models.py:56
#: apps/registration/models.py:76 apps/registration/models.py:114 #: apps/registration/models.py:78 apps/registration/models.py:123
msgid "team" msgid "team"
msgstr "équipe" msgstr "équipe"
@ -217,25 +213,15 @@ msgid "videos"
msgstr "vidéos" msgstr "vidéos"
#: apps/participation/templates/participation/create_team.html:11 #: apps/participation/templates/participation/create_team.html:11
#: apps/participation/templates/participation/create_team_modal.html:15 #: templates/base.html:202
msgid "Create" msgid "Create"
msgstr "Créer" msgstr "Créer"
#: apps/participation/templates/participation/create_team_modal.html:8
#: apps/participation/views.py:15 templates/base.html:70
msgid "Create team"
msgstr "Créer une équipe"
#: apps/participation/templates/participation/join_team.html:11 #: apps/participation/templates/participation/join_team.html:11
#: apps/participation/templates/participation/join_team_modal.html:15 #: templates/base.html:198
msgid "Join" msgid "Join"
msgstr "Rejoindre" msgstr "Rejoindre"
#: apps/participation/templates/participation/join_team_modal.html:8
#: apps/participation/views.py:41 templates/base.html:75
msgid "Join team"
msgstr "Rejoindre une équipe"
#: apps/participation/templates/participation/team_detail.html:6 #: apps/participation/templates/participation/team_detail.html:6
#: apps/registration/templates/registration/user_detail.html:6 #: apps/registration/templates/registration/user_detail.html:6
msgid "any" msgid "any"
@ -270,18 +256,23 @@ msgid "Grant Animath to publish our video:"
msgstr "Autoriser Animath à publier notre vidéo :" msgstr "Autoriser Animath à publier notre vidéo :"
#: apps/participation/templates/participation/team_detail.html:37 #: apps/participation/templates/participation/team_detail.html:37
#: apps/participation/templates/participation/team_detail.html:42
#: apps/participation/templates/participation/update_team.html:12 #: apps/participation/templates/participation/update_team.html:12
#: apps/participation/templates/participation/update_team_modal.html:15
#: apps/registration/templates/registration/update_user.html:12 #: apps/registration/templates/registration/update_user.html:12
#: apps/registration/templates/registration/update_user_modal.html:15
#: apps/registration/templates/registration/user_detail.html:43 #: apps/registration/templates/registration/user_detail.html:43
#: apps/registration/templates/registration/user_detail.html:49
msgid "Update" msgid "Update"
msgstr "Modifier" msgstr "Modifier"
#: apps/participation/templates/participation/update_team_modal.html:8 #: apps/participation/templates/participation/team_detail.html:41
msgid "Update team" msgid "Update team"
msgstr "Modifier l'équipe" msgstr "Modifier l'équipe"
#: apps/participation/views.py:15 templates/base.html:70
#: templates/base.html:201
msgid "Create team"
msgstr "Créer une équipe"
#: apps/participation/views.py:23 apps/participation/views.py:49 #: apps/participation/views.py:23 apps/participation/views.py:49
msgid "You don't participate, so you can't create a team." 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." msgstr "Vous ne participez pas, vous ne pouvez pas créer d'équipe."
@ -290,6 +281,11 @@ msgstr "Vous ne participez pas, vous ne pouvez pas créer d'équipe."
msgid "You are already in a team." msgid "You are already in a team."
msgstr "Vous êtes déjà dans une équipe." msgstr "Vous êtes déjà dans une équipe."
#: apps/participation/views.py:41 templates/base.html:75
#: templates/base.html:197
msgid "Join team"
msgstr "Rejoindre une équipe"
#: apps/participation/views.py:72 #: apps/participation/views.py:72
msgid "You are not in a team." msgid "You are not in a team."
msgstr "Vous n'êtes pas dans une équipe." msgstr "Vous n'êtes pas dans une équipe."
@ -306,88 +302,92 @@ msgstr "rôle"
msgid "participant" msgid "participant"
msgstr "participant" msgstr "participant"
#: apps/registration/forms.py:14 apps/registration/models.py:123 #: apps/registration/forms.py:14 apps/registration/models.py:132
msgid "coach" msgid "coach"
msgstr "encadrant" msgstr "encadrant"
#: apps/registration/models.py:20 #: apps/registration/models.py:22
msgid "Grant Animath to contact me in the future about other actions" msgid "Grant Animath to contact me in the future about other actions"
msgstr "" msgstr ""
"Autoriser Animath à me recontacter à l'avenir à propos d'autres actions" "Autoriser Animath à me recontacter à l'avenir à propos d'autres actions"
#: apps/registration/models.py:25 #: apps/registration/models.py:27
msgid "email confirmed" msgid "email confirmed"
msgstr "email confirmé" msgstr "email confirmé"
#: apps/registration/models.py:29 #: apps/registration/models.py:31
msgid "Activate your Correspondances account" msgid "Activate your Correspondances account"
msgstr "Activez votre compte des Correspondances" msgstr "Activez votre compte des Correspondances"
#: apps/registration/models.py:65 #: apps/registration/models.py:67
msgid "registration" msgid "registration"
msgstr "inscription" msgstr "inscription"
#: apps/registration/models.py:66 #: apps/registration/models.py:68
msgid "registrations" msgid "registrations"
msgstr "inscriptions" msgstr "inscriptions"
#: apps/registration/models.py:81 #: apps/registration/models.py:83
msgid "12th grade" msgid "12th grade"
msgstr "Terminale" msgstr "Terminale"
#: apps/registration/models.py:82 #: apps/registration/models.py:84
msgid "11th grade" msgid "11th grade"
msgstr "Première" msgstr "Première"
#: apps/registration/models.py:83 #: apps/registration/models.py:85
msgid "10th grade or lower" msgid "10th grade or lower"
msgstr "Seconde ou inférieur" msgstr "Seconde ou inférieur"
#: apps/registration/models.py:85 #: apps/registration/models.py:87
msgid "student class" msgid "student class"
msgstr "classe" msgstr "classe"
#: apps/registration/models.py:90 #: apps/registration/models.py:92
msgid "school" msgid "school"
msgstr "école" msgstr "école"
#: apps/registration/models.py:95 #: apps/registration/models.py:96
msgid "photo authorization"
msgstr ""
#: apps/registration/models.py:104
msgid "student" msgid "student"
msgstr "étudiant" msgstr "étudiant"
#: apps/registration/models.py:103 #: apps/registration/models.py:112
msgid "student registration" msgid "student registration"
msgstr "inscription d'élève" msgstr "inscription d'élève"
#: apps/registration/models.py:104 #: apps/registration/models.py:113
msgid "student registrations" msgid "student registrations"
msgstr "inscriptions d'élève" msgstr "inscriptions d'élève"
#: apps/registration/models.py:118 #: apps/registration/models.py:127
msgid "professional activity" msgid "professional activity"
msgstr "activité professionnelle" msgstr "activité professionnelle"
#: apps/registration/models.py:131 #: apps/registration/models.py:140
msgid "coach registration" msgid "coach registration"
msgstr "inscription d'encadrant" msgstr "inscription d'encadrant"
#: apps/registration/models.py:132 #: apps/registration/models.py:141
msgid "coach registrations" msgid "coach registrations"
msgstr "inscriptions d'encadrants" msgstr "inscriptions d'encadrants"
#: apps/registration/models.py:137 #: apps/registration/models.py:146
msgid "role of the administrator" msgid "role of the administrator"
msgstr "rôle de l'administrateur" msgstr "rôle de l'administrateur"
#: apps/registration/models.py:142 #: apps/registration/models.py:151
msgid "admin" msgid "admin"
msgstr "admin" msgstr "admin"
#: apps/registration/models.py:150 #: apps/registration/models.py:159
msgid "admin registration" msgid "admin registration"
msgstr "inscription d'administrateur" msgstr "inscription d'administrateur"
#: apps/registration/models.py:151 #: apps/registration/models.py:160
msgid "admin registrations" msgid "admin registrations"
msgstr "inscriptions d'administrateur" msgstr "inscriptions d'administrateur"
@ -427,14 +427,6 @@ msgstr "Merci d'avoir utilisé la plateforme des Correspondances."
msgid "Log in again" msgid "Log in again"
msgstr "Se reconnecter" msgstr "Se reconnecter"
#: apps/registration/templates/registration/login_modal.html:8
#: apps/registration/templates/registration/login_modal.html:15
#: apps/registration/templates/registration/password_reset_complete.html:10
#: templates/base.html:108 templates/registration/login.html:7
#: templates/registration/login.html:8 templates/registration/login.html:25
msgid "Log in"
msgstr "Connexion"
#: apps/registration/templates/registration/mails/email_validation_email.html:12 #: apps/registration/templates/registration/mails/email_validation_email.html:12
#: apps/registration/templates/registration/mails/email_validation_email.txt:3 #: apps/registration/templates/registration/mails/email_validation_email.txt:3
msgid "Hi" msgid "Hi"
@ -490,6 +482,13 @@ msgstr "Changer mon mot de passe"
msgid "Your password has been set. You may go ahead and log in now." 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." 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:108 templates/base.html:192 templates/base.html:193
#: templates/registration/login.html:7 templates/registration/login.html:8
#: templates/registration/login.html:25
msgid "Log in"
msgstr "Connexion"
#: apps/registration/templates/registration/password_reset_confirm.html:9 #: apps/registration/templates/registration/password_reset_confirm.html:9
msgid "" msgid ""
"Please enter your new password twice so we can verify you typed it in " "Please enter your new password twice so we can verify you typed it in "
@ -543,10 +542,6 @@ msgstr "Réinitialiser mon mot de passe"
msgid "Sign up" msgid "Sign up"
msgstr "Inscription" msgstr "Inscription"
#: apps/registration/templates/registration/update_user_modal.html:8
msgid "Update user"
msgstr "Modifier l'utilisateur"
#: apps/registration/templates/registration/user_detail.html:14 #: apps/registration/templates/registration/user_detail.html:14
msgid "Last name:" msgid "Last name:"
msgstr "Nom de famille :" msgstr "Nom de famille :"
@ -587,23 +582,27 @@ msgstr "Rôle :"
msgid "Grant Animath to contact me in the future about other actions:" msgid "Grant Animath to contact me in the future about other actions:"
msgstr "Autorise Animath à recontacter à propos d'autres actions :" msgstr "Autorise Animath à recontacter à propos d'autres actions :"
#: apps/registration/views.py:55 #: apps/registration/templates/registration/user_detail.html:48
msgid "Update user"
msgstr "Modifier l'utilisateur"
#: apps/registration/views.py:56
msgid "Email validation" msgid "Email validation"
msgstr "Validation de l'adresse mail" msgstr "Validation de l'adresse mail"
#: apps/registration/views.py:57 #: apps/registration/views.py:58
msgid "Validate email" msgid "Validate email"
msgstr "Valider l'adresse mail" msgstr "Valider l'adresse mail"
#: apps/registration/views.py:96 #: apps/registration/views.py:97
msgid "Email validation unsuccessful" msgid "Email validation unsuccessful"
msgstr "Échec de la validation de l'adresse mail" msgstr "Échec de la validation de l'adresse mail"
#: apps/registration/views.py:107 #: apps/registration/views.py:108
msgid "Email validation email sent" msgid "Email validation email sent"
msgstr "Mail de confirmation de l'adresse mail envoyé" msgstr "Mail de confirmation de l'adresse mail envoyé"
#: apps/registration/views.py:115 #: apps/registration/views.py:116
msgid "Resend email validation link" msgid "Resend email validation link"
msgstr "Renvoyé le lien de validation de l'adresse mail" msgstr "Renvoyé le lien de validation de l'adresse mail"

View File

@ -189,10 +189,19 @@
</div> </div>
</footer> </footer>
{% include "registration/login_modal.html" %} {% trans "Log in" as modal_title %}
{% trans "Log in" as modal_button %}
{% url "login" as modal_action %}
{% include "base_modal.html" with modal_id="login" %}
{% if user.is_authenticated %} {% if user.is_authenticated %}
{% include "participation/create_team_modal.html" %} {% trans "Join team" as modal_title %}
{% include "participation/join_team_modal.html" %} {% trans "Join" as modal_button %}
{% url "participation:join_team" as modal_action %}
{% include "base_modal.html" with modal_id="joinTeam" %}
{% trans "Create team" as modal_title %}
{% trans "Create" as modal_button %}
{% url "participation:create_team" as modal_action %}
{% include "base_modal.html" with modal_id="createTeam" modal_button_type="success" %}
{% endif %} {% endif %}
<script> <script>

View File

@ -1,18 +1,18 @@
{% load i18n %} {% load i18n %}
<div id="createTeamModal" class="modal fade" tabindex="-1" role="dialog"> <div id="{{ modal_id }}Modal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document"> <div class="modal-dialog" role="document">
<form method="post" action="{% url "participation:create_team" %}"> <form method="post" action="{{ modal_action }}" enctype="{{ modal_enctype|default:"application/x-www-form-urlencoded" }}">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title">{% trans "Create team" %}</h5> <h5 class="modal-title">{{ modal_title }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
<div class="modal-body"></div> <div class="modal-body"></div>
<div class="modal-footer"> <div class="modal-footer">
<button type="submit" class="btn btn-success">{% trans "Create" %}</button> <button type="submit" class="btn btn-{{ modal_button_type|default:"primary" }}">{{ modal_button }}</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">{% trans "Close" %}</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">{% trans "Close" %}</button>
</div> </div>
</div> </div>

View File

@ -11,7 +11,7 @@ deps =
-r{toxinidir}/requirements.txt -r{toxinidir}/requirements.txt
coverage coverage
commands = commands =
coverage run --omit='*migrations*,apps/scripts*' --source=apps,tfjm ./manage.py test apps/ coverage run --omit='*migrations*,apps/scripts*' --source=apps ./manage.py test apps/
coverage report -m coverage report -m
[testenv:linters] [testenv:linters]