From 5d524b263b86d71563a3e295052af5046b8f9d9a Mon Sep 17 00:00:00 2001
From: Yohann D'ANELLO
Date: Thu, 21 Jan 2021 23:43:59 +0100
Subject: [PATCH 1/8] Use the server email in the from header
---
tfjm/settings_prod.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tfjm/settings_prod.py b/tfjm/settings_prod.py
index ac9168b..c7cd466 100644
--- a/tfjm/settings_prod.py
+++ b/tfjm/settings_prod.py
@@ -20,8 +20,8 @@ EMAIL_PORT = os.getenv("SMTP_PORT")
EMAIL_HOST_USER = os.getenv("SMTP_HOST_USER")
EMAIL_HOST_PASSWORD = os.getenv("SMTP_HOST_PASSWORD")
-DEFAULT_FROM_EMAIL = os.getenv('FROM_EMAIL', 'Contact TFJM² ')
SERVER_EMAIL = os.getenv('SERVER_EMAIL', 'contact@tfjm.org')
+DEFAULT_FROM_EMAIL = os.getenv('FROM_EMAIL', 'Contact TFJM²') + f" <{SERVER_EMAIL}>"
# Security settings
SECURE_CONTENT_TYPE_NOSNIFF = False
From 48107943f9fe3362d6c35f2e8ec54496df462138 Mon Sep 17 00:00:00 2001
From: Yohann D'ANELLO
Date: Thu, 21 Jan 2021 23:49:20 +0100
Subject: [PATCH 2/8] Use registration name rather than email address in the
add organizer mail
---
.../templates/registration/mails/add_organizer.html | 2 +-
.../registration/templates/registration/mails/add_organizer.txt | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/apps/registration/templates/registration/mails/add_organizer.html b/apps/registration/templates/registration/mails/add_organizer.html
index 37b1645..e33e667 100644
--- a/apps/registration/templates/registration/mails/add_organizer.html
+++ b/apps/registration/templates/registration/mails/add_organizer.html
@@ -13,7 +13,7 @@
- Vous avez été invités par {{ inviter }} à rejoindre la plateforme du TFJM², accessible à l'adresse
+ Vous avez été invités par {{ inviter.registration }} à rejoindre la plateforme du TFJM², accessible à l'adresse
https://{{ domain }}/ . Vous disposez d'un compte d'organisateur.
diff --git a/apps/registration/templates/registration/mails/add_organizer.txt b/apps/registration/templates/registration/mails/add_organizer.txt
index a8ba63e..19f91ec 100644
--- a/apps/registration/templates/registration/mails/add_organizer.txt
+++ b/apps/registration/templates/registration/mails/add_organizer.txt
@@ -2,7 +2,7 @@
Bonjour {{ user.registration }},
-Vous avez été invités par {{ inviter }} à rejoindre la plateforme du TFJM², accessible à l'adresse
+Vous avez été invités par {{ inviter.registration }} à rejoindre la plateforme du TFJM², accessible à l'adresse
https://{{ domain }}/. Vous disposez d'un compte d'organisateur.
Un mot de passe aléatoire a été défini : {{ password }}.
From 384de5758bf9f790aa8b653d6f63229ad46f24d6 Mon Sep 17 00:00:00 2001
From: Yohann D'ANELLO
Date: Fri, 22 Jan 2021 08:45:00 +0100
Subject: [PATCH 3/8] Ask gender
---
apps/registration/forms.py | 4 +-
.../0002_participantregistration_gender.py | 18 ++
apps/registration/models.py | 10 +
.../templates/registration/user_detail.html | 5 +-
locale/fr/LC_MESSAGES/django.po | 200 ++++++++++--------
5 files changed, 144 insertions(+), 93 deletions(-)
create mode 100644 apps/registration/migrations/0002_participantregistration_gender.py
diff --git a/apps/registration/forms.py b/apps/registration/forms.py
index ac4650b..5f62398 100644
--- a/apps/registration/forms.py
+++ b/apps/registration/forms.py
@@ -100,7 +100,7 @@ class StudentRegistrationForm(forms.ModelForm):
"""
class Meta:
model = StudentRegistration
- fields = ('team', 'student_class', 'birth_date', 'address', 'phone_number',
+ fields = ('team', 'student_class', 'birth_date', 'gender', 'address', 'phone_number',
'school', 'responsible_name', 'responsible_phone', 'responsible_email',
'give_contact_to_animath', 'email_confirmed',)
@@ -177,7 +177,7 @@ class CoachRegistrationForm(forms.ModelForm):
"""
class Meta:
model = CoachRegistration
- fields = ('team', 'birth_date', 'address', 'phone_number', 'professional_activity',
+ fields = ('team', 'birth_date', 'gender', 'address', 'phone_number', 'professional_activity',
'give_contact_to_animath', 'email_confirmed',)
diff --git a/apps/registration/migrations/0002_participantregistration_gender.py b/apps/registration/migrations/0002_participantregistration_gender.py
new file mode 100644
index 0000000..0dd0e24
--- /dev/null
+++ b/apps/registration/migrations/0002_participantregistration_gender.py
@@ -0,0 +1,18 @@
+# Generated by Django 3.0.11 on 2021-01-22 07:42
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('registration', '0001_initial'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='participantregistration',
+ name='gender',
+ field=models.DateField(choices=[('female', 'Female'), ('male', 'Male'), ('other', 'Other')], default='other', verbose_name='gender'),
+ ),
+ ]
diff --git a/apps/registration/models.py b/apps/registration/models.py
index 4cf4416..ad1d3dd 100644
--- a/apps/registration/models.py
+++ b/apps/registration/models.py
@@ -128,6 +128,16 @@ class ParticipantRegistration(Registration):
default=date.today,
)
+ gender = models.DateField(
+ verbose_name=_("gender"),
+ choices=[
+ ("female", _("Female")),
+ ("male", _("Male")),
+ ("other", _("Other")),
+ ],
+ default="other",
+ )
+
address = AddressField(
verbose_name=_("address"),
null=True,
diff --git a/apps/registration/templates/registration/user_detail.html b/apps/registration/templates/registration/user_detail.html
index cdc6017..04b29d1 100644
--- a/apps/registration/templates/registration/user_detail.html
+++ b/apps/registration/templates/registration/user_detail.html
@@ -16,7 +16,7 @@
{% trans "First name:" %}
{{ user_object.first_name }}
-
+StudentRegistrationForm(
{% trans "Email:" %}
{{ user_object.email }}
{% if not user_object.registration.email_confirmed %} ({% trans "Not confirmed" %}, {% trans "resend the validation link" %} ){% endif %}
@@ -42,6 +42,9 @@
{% trans "Birth date:" %}
{{ user_object.registration.birth_date }}
+ {% trans "Gender:" %}
+ {{ user_object.registration.get_gender_display }}
+
{% trans "Address:" %}
{{ user_object.registration.address }}
diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po
index 794e7f3..bb7ff27 100644
--- a/locale/fr/LC_MESSAGES/django.po
+++ b/locale/fr/LC_MESSAGES/django.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: TFJM\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2021-01-21 22:34+0100\n"
+"POT-Creation-Date: 2021-01-22 08:43+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: Yohann D'ANELLO \n"
"Language-Team: LANGUAGE \n"
@@ -100,7 +100,7 @@ msgid "Changelog of type \"{action}\" for model {model} at {timestamp}"
msgstr "Changelog de type \"{action}\" pour le modèle {model} le {timestamp}"
#: apps/participation/admin.py:19 apps/participation/models.py:298
-#: apps/participation/tables.py:44 apps/registration/models.py:335
+#: apps/participation/tables.py:44 apps/registration/models.py:345
msgid "valid"
msgstr "valide"
@@ -513,9 +513,9 @@ msgstr "Rejoindre"
#: apps/participation/templates/participation/update_team.html:12
#: apps/registration/templates/registration/payment_form.html:49
#: apps/registration/templates/registration/update_user.html:16
-#: apps/registration/templates/registration/user_detail.html:147
-#: apps/registration/templates/registration/user_detail.html:156
-#: apps/registration/templates/registration/user_detail.html:184
+#: apps/registration/templates/registration/user_detail.html:150
+#: apps/registration/templates/registration/user_detail.html:159
+#: apps/registration/templates/registration/user_detail.html:187
msgid "Update"
msgstr "Modifier"
@@ -569,10 +569,10 @@ msgstr "Envoyer une solution"
#: apps/registration/templates/registration/upload_health_sheet.html:17
#: apps/registration/templates/registration/upload_parental_authorization.html:17
#: apps/registration/templates/registration/upload_photo_authorization.html:18
-#: apps/registration/templates/registration/user_detail.html:162
-#: apps/registration/templates/registration/user_detail.html:167
-#: apps/registration/templates/registration/user_detail.html:172
-#: apps/registration/templates/registration/user_detail.html:177
+#: apps/registration/templates/registration/user_detail.html:165
+#: apps/registration/templates/registration/user_detail.html:170
+#: apps/registration/templates/registration/user_detail.html:175
+#: apps/registration/templates/registration/user_detail.html:180
msgid "Upload"
msgstr "Téléverser"
@@ -1031,7 +1031,7 @@ msgstr "rôle"
msgid "participant"
msgstr "participant"
-#: apps/registration/forms.py:24 apps/registration/models.py:236
+#: apps/registration/forms.py:24 apps/registration/models.py:246
msgid "coach"
msgstr "encadrant"
@@ -1039,11 +1039,11 @@ msgstr "encadrant"
msgid "This email address is already used."
msgstr "Cette adresse e-mail est déjà utilisée."
-#: apps/registration/forms.py:55 apps/registration/models.py:262
+#: apps/registration/forms.py:55 apps/registration/models.py:272
msgid "volunteer"
msgstr "bénévole"
-#: apps/registration/forms.py:56 apps/registration/models.py:281
+#: apps/registration/forms.py:56 apps/registration/models.py:291
msgid "admin"
msgstr "admin"
@@ -1073,7 +1073,7 @@ msgstr "email confirmé"
msgid "Activate your TFJM² account"
msgstr "Activez votre compte du TFJM²"
-#: apps/registration/models.py:99 apps/registration/models.py:302
+#: apps/registration/models.py:99 apps/registration/models.py:312
msgid "registration"
msgstr "inscription"
@@ -1086,139 +1086,155 @@ msgid "birth date"
msgstr "date de naissance"
#: apps/registration/models.py:132
+msgid "gender"
+msgstr "genre"
+
+#: apps/registration/models.py:134
+msgid "Female"
+msgstr "Femme"
+
+#: apps/registration/models.py:135
+msgid "Male"
+msgstr "Homme"
+
+#: apps/registration/models.py:136
+msgid "Other"
+msgstr "Autre"
+
+#: apps/registration/models.py:142
msgid "address"
msgstr "adresse"
-#: apps/registration/models.py:138
+#: apps/registration/models.py:148
msgid "phone number"
msgstr "numéro de téléphone"
-#: apps/registration/models.py:143
+#: apps/registration/models.py:153
msgid "photo authorization"
msgstr "autorisation de droit à l'image"
-#: apps/registration/models.py:169
+#: apps/registration/models.py:179
msgid "12th grade"
msgstr "Terminale"
-#: apps/registration/models.py:170
+#: apps/registration/models.py:180
msgid "11th grade"
msgstr "Première"
-#: apps/registration/models.py:171
+#: apps/registration/models.py:181
msgid "10th grade or lower"
msgstr "Seconde ou inférieur"
-#: apps/registration/models.py:173
+#: apps/registration/models.py:183
msgid "student class"
msgstr "classe"
-#: apps/registration/models.py:178
+#: apps/registration/models.py:188
msgid "school"
msgstr "école"
-#: apps/registration/models.py:183
+#: apps/registration/models.py:193
msgid "responsible name"
msgstr "nom du responsable légal"
-#: apps/registration/models.py:188
+#: apps/registration/models.py:198
msgid "responsible phone number"
msgstr "numéro de téléphone du responsable légal"
-#: apps/registration/models.py:193
+#: apps/registration/models.py:203
msgid "responsible email address"
msgstr "adresse e-mail du responsable légal"
-#: apps/registration/models.py:198
+#: apps/registration/models.py:208
msgid "parental authorization"
msgstr "autorisation parentale"
-#: apps/registration/models.py:205
+#: apps/registration/models.py:215
msgid "health sheet"
msgstr "fiche sanitaire"
-#: apps/registration/models.py:213
+#: apps/registration/models.py:223
msgid "student"
msgstr "étudiant"
-#: apps/registration/models.py:221
+#: apps/registration/models.py:231
msgid "student registration"
msgstr "inscription d'élève"
-#: apps/registration/models.py:222
+#: apps/registration/models.py:232
msgid "student registrations"
msgstr "inscriptions d'élève"
-#: apps/registration/models.py:231 apps/registration/models.py:253
+#: apps/registration/models.py:241 apps/registration/models.py:263
msgid "professional activity"
msgstr "activité professionnelle"
-#: apps/registration/models.py:244
+#: apps/registration/models.py:254
msgid "coach registration"
msgstr "inscription d'encadrant"
-#: apps/registration/models.py:245
+#: apps/registration/models.py:255
msgid "coach registrations"
msgstr "inscriptions d'encadrants"
-#: apps/registration/models.py:276
+#: apps/registration/models.py:286
msgid "role of the administrator"
msgstr "rôle de l'administrateur"
-#: apps/registration/models.py:289
+#: apps/registration/models.py:299
msgid "admin registration"
msgstr "inscription d'administrateur"
-#: apps/registration/models.py:290
+#: apps/registration/models.py:300
msgid "admin registrations"
msgstr "inscriptions d'administrateur"
-#: apps/registration/models.py:306
+#: apps/registration/models.py:316
msgid "type"
msgstr "type"
-#: apps/registration/models.py:309
+#: apps/registration/models.py:319
msgid "No payment"
msgstr "Pas de paiement"
-#: apps/registration/models.py:311
+#: apps/registration/models.py:321
msgid "Scholarship"
msgstr "Notification de bourse"
-#: apps/registration/models.py:312
+#: apps/registration/models.py:322
msgid "Bank transfer"
msgstr "Virement bancaire"
-#: apps/registration/models.py:313
+#: apps/registration/models.py:323
msgid "The tournament is free"
msgstr "Le tournoi est gratuit"
-#: apps/registration/models.py:320
+#: apps/registration/models.py:330
msgid "scholarship file"
msgstr "Notification de bourse"
-#: apps/registration/models.py:321
+#: apps/registration/models.py:331
msgid "only if you have a scholarship."
msgstr "Nécessaire seulement si vous déclarez être boursier."
-#: apps/registration/models.py:328
+#: apps/registration/models.py:338
msgid "additional information"
msgstr "informations additionnelles"
-#: apps/registration/models.py:329
+#: apps/registration/models.py:339
msgid "To help us to find your payment."
msgstr "Pour nous aider à retrouver votre paiement, si nécessaire."
-#: apps/registration/models.py:344
+#: apps/registration/models.py:354
#, python-brace-format
msgid "Payment of {registration}"
msgstr "Paiement de {registration}"
-#: apps/registration/models.py:347
+#: apps/registration/models.py:357
msgid "payment"
msgstr "paiement"
-#: apps/registration/models.py:348
+#: apps/registration/models.py:358
msgid "payments"
msgstr "paiements"
@@ -1450,9 +1466,9 @@ msgstr "Modèle de fiche sanitaire :"
#: apps/registration/templates/registration/upload_health_sheet.html:12
#: apps/registration/templates/registration/upload_parental_authorization.html:12
-#: apps/registration/templates/registration/user_detail.html:54
-#: apps/registration/templates/registration/user_detail.html:67
-#: apps/registration/templates/registration/user_detail.html:77
+#: apps/registration/templates/registration/user_detail.html:57
+#: apps/registration/templates/registration/user_detail.html:70
+#: apps/registration/templates/registration/user_detail.html:80
msgid "Download"
msgstr "Télécharger"
@@ -1501,106 +1517,110 @@ msgid "Birth date:"
msgstr "Date de naissance :"
#: apps/registration/templates/registration/user_detail.html:45
+msgid "Gender:"
+msgstr "Genre :"
+
+#: apps/registration/templates/registration/user_detail.html:48
msgid "Address:"
msgstr "Adresse :"
-#: apps/registration/templates/registration/user_detail.html:48
+#: apps/registration/templates/registration/user_detail.html:51
msgid "Phone number:"
msgstr "Numéro de téléphone :"
-#: apps/registration/templates/registration/user_detail.html:51
+#: apps/registration/templates/registration/user_detail.html:54
msgid "Photo authorization:"
msgstr "Autorisation de droit à l'image"
-#: apps/registration/templates/registration/user_detail.html:57
-#: apps/registration/templates/registration/user_detail.html:70
-#: apps/registration/templates/registration/user_detail.html:80
+#: apps/registration/templates/registration/user_detail.html:60
+#: apps/registration/templates/registration/user_detail.html:73
+#: apps/registration/templates/registration/user_detail.html:83
msgid "Replace"
msgstr "Remplacer"
-#: apps/registration/templates/registration/user_detail.html:64
+#: apps/registration/templates/registration/user_detail.html:67
msgid "Health sheet:"
msgstr "Fiche sanitaire :"
-#: apps/registration/templates/registration/user_detail.html:74
+#: apps/registration/templates/registration/user_detail.html:77
msgid "Parental authorization:"
msgstr "Autorisation parentale :"
-#: apps/registration/templates/registration/user_detail.html:85
+#: apps/registration/templates/registration/user_detail.html:88
msgid "Student class:"
msgstr "Classe :"
-#: apps/registration/templates/registration/user_detail.html:88
+#: apps/registration/templates/registration/user_detail.html:91
msgid "School:"
msgstr "École :"
-#: apps/registration/templates/registration/user_detail.html:91
+#: apps/registration/templates/registration/user_detail.html:94
msgid "Responsible name:"
msgstr "Nom du responsable légal :"
-#: apps/registration/templates/registration/user_detail.html:94
+#: apps/registration/templates/registration/user_detail.html:97
msgid "Responsible phone number:"
msgstr "Numéro de téléphone du responsable légal :"
-#: apps/registration/templates/registration/user_detail.html:97
+#: apps/registration/templates/registration/user_detail.html:100
msgid "Responsible email address:"
msgstr "Adresse e-mail du responsable légal :"
-#: apps/registration/templates/registration/user_detail.html:102
+#: apps/registration/templates/registration/user_detail.html:105
msgid "Role:"
msgstr "Rôle :"
-#: apps/registration/templates/registration/user_detail.html:105
+#: apps/registration/templates/registration/user_detail.html:108
msgid "Profesional activity:"
msgstr "Activité professionnelle :"
-#: apps/registration/templates/registration/user_detail.html:109
+#: apps/registration/templates/registration/user_detail.html:112
msgid "Grant Animath to contact me in the future about other actions:"
msgstr "Autorise Animath à recontacter à propos d'autres actions :"
-#: apps/registration/templates/registration/user_detail.html:117
+#: apps/registration/templates/registration/user_detail.html:120
msgid "Payment information:"
msgstr "Informations de paiement :"
-#: apps/registration/templates/registration/user_detail.html:119
+#: apps/registration/templates/registration/user_detail.html:122
msgid "yes,no,pending"
msgstr "oui,non,en attente"
-#: apps/registration/templates/registration/user_detail.html:123
#: apps/registration/templates/registration/user_detail.html:126
+#: apps/registration/templates/registration/user_detail.html:129
msgid "valid:"
msgstr "valide :"
-#: apps/registration/templates/registration/user_detail.html:130
-#: apps/registration/templates/registration/user_detail.html:183
+#: apps/registration/templates/registration/user_detail.html:133
+#: apps/registration/templates/registration/user_detail.html:186
msgid "Update payment"
msgstr "Modifier le paiement"
-#: apps/registration/templates/registration/user_detail.html:136
+#: apps/registration/templates/registration/user_detail.html:139
msgid "Download scholarship attestation"
msgstr "Télécharger l'attestation de bourse"
-#: apps/registration/templates/registration/user_detail.html:149
+#: apps/registration/templates/registration/user_detail.html:152
msgid "Impersonate"
msgstr "Impersonifier"
-#: apps/registration/templates/registration/user_detail.html:155
+#: apps/registration/templates/registration/user_detail.html:158
msgid "Update user"
msgstr "Modifier l'utilisateur"
-#: apps/registration/templates/registration/user_detail.html:161
-#: apps/registration/views.py:315
+#: apps/registration/templates/registration/user_detail.html:164
+#: apps/registration/views.py:319
msgid "Upload photo authorization"
msgstr "Téléverser l'autorisation de droit à l'image"
-#: apps/registration/templates/registration/user_detail.html:166
-#: apps/registration/views.py:341
+#: apps/registration/templates/registration/user_detail.html:169
+#: apps/registration/views.py:345
msgid "Upload health sheet"
msgstr "Téléverser la fiche sanitaire"
-#: apps/registration/templates/registration/user_detail.html:171
-#: apps/registration/templates/registration/user_detail.html:176
-#: apps/registration/views.py:367
+#: apps/registration/templates/registration/user_detail.html:174
+#: apps/registration/templates/registration/user_detail.html:179
+#: apps/registration/views.py:371
msgid "Upload parental authorization"
msgstr "Téléverser l'autorisation parentale"
@@ -1608,52 +1628,52 @@ msgstr "Téléverser l'autorisation parentale"
msgid "New TFJM² organizer account"
msgstr "Nouveau compte organisateur pour le TFJM²"
-#: apps/registration/views.py:149
+#: apps/registration/views.py:153
msgid "Email validation"
msgstr "Validation de l'adresse mail"
-#: apps/registration/views.py:151
+#: apps/registration/views.py:155
msgid "Validate email"
msgstr "Valider l'adresse mail"
-#: apps/registration/views.py:190
+#: apps/registration/views.py:194
msgid "Email validation unsuccessful"
msgstr "Échec de la validation de l'adresse mail"
-#: apps/registration/views.py:201
+#: apps/registration/views.py:205
msgid "Email validation email sent"
msgstr "Mail de confirmation de l'adresse mail envoyé"
-#: apps/registration/views.py:209
+#: apps/registration/views.py:213
msgid "Resend email validation link"
msgstr "Renvoyé le lien de validation de l'adresse mail"
-#: apps/registration/views.py:249
+#: apps/registration/views.py:253
#, python-brace-format
msgid "Detail of user {user}"
msgstr "Détails de l'utilisateur {user}"
-#: apps/registration/views.py:279
+#: apps/registration/views.py:283
#, python-brace-format
msgid "Update user {user}"
msgstr "Mise à jour de l'utilisateur {user}"
-#: apps/registration/views.py:476
+#: apps/registration/views.py:480
#, python-brace-format
msgid "Photo authorization of {student}.{ext}"
msgstr "Autorisation de droit à l'image de {student}.{ext}"
-#: apps/registration/views.py:499
+#: apps/registration/views.py:503
#, python-brace-format
msgid "Health sheet of {student}.{ext}"
msgstr "Fiche sanitaire de {student}.{ext}"
-#: apps/registration/views.py:522
+#: apps/registration/views.py:526
#, python-brace-format
msgid "Parental authorization of {student}.{ext}"
msgstr "Autorisation parentale de {student}.{ext}"
-#: apps/registration/views.py:544
+#: apps/registration/views.py:548
#, python-brace-format
msgid "Scholarship attestation of {user}.{ext}"
msgstr "Notification de bourse de {user}.{ext}"
From 74c02605931ebc815b4bcc0d528a4b03e523c759 Mon Sep 17 00:00:00 2001
From: Yohann D'ANELLO
Date: Fri, 22 Jan 2021 08:57:01 +0100
Subject: [PATCH 4/8] Don't re-upload a new avatar every time
---
.../management/commands/fix_matrix_channels.py | 18 ++++++++++--------
tfjm/matrix.py | 10 ++++++++++
2 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/apps/participation/management/commands/fix_matrix_channels.py b/apps/participation/management/commands/fix_matrix_channels.py
index ee033d0..5b67eb1 100644
--- a/apps/participation/management/commands/fix_matrix_channels.py
+++ b/apps/participation/management/commands/fix_matrix_channels.py
@@ -22,14 +22,16 @@ class Command(BaseCommand):
avatar_uri = "plop"
else: # pragma: no cover
if not os.path.isfile(".matrix_avatar"):
- stat_file = os.stat("tfjm/static/logo.png")
- with open("tfjm/static/logo.png", "rb") as f:
- resp = Matrix.upload(f, filename="logo.png", content_type="image/png",
- filesize=stat_file.st_size)[0][0]
- avatar_uri = resp.content_uri
- with open(".matrix_avatar", "w") as f:
- f.write(avatar_uri)
- Matrix.set_avatar(avatar_uri)
+ avatar_uri = Matrix.get_avatar()
+ if not isinstance(avatar_uri, str):
+ stat_file = os.stat("tfjm/static/logo.png")
+ with open("tfjm/static/logo.png", "rb") as f:
+ resp = Matrix.upload(f, filename="logo.png", content_type="image/png",
+ filesize=stat_file.st_size)[0][0]
+ avatar_uri = resp.content_uri
+ with open(".matrix_avatar", "w") as f:
+ f.write(avatar_uri)
+ Matrix.set_avatar(avatar_uri)
with open(".matrix_avatar", "r") as f:
avatar_uri = f.read().rstrip(" \t\r\n")
diff --git a/tfjm/matrix.py b/tfjm/matrix.py
index 1a65311..20732d6 100644
--- a/tfjm/matrix.py
+++ b/tfjm/matrix.py
@@ -68,6 +68,16 @@ class Matrix:
client = await cls._get_client()
return await client.set_avatar(avatar_url)
+ @classmethod
+ @async_to_sync
+ async def get_avatar(cls): # pragma: no cover
+ """
+ Set the display avatar of the bot account.
+ """
+ client = await cls._get_client()
+ resp = await client.get_avatar()
+ return resp.avatar_url if resp.status_code == 200 else resp
+
@classmethod
@async_to_sync
async def upload(
From 628f69e7723b13206d53876861bedfff1863a885 Mon Sep 17 00:00:00 2001
From: Yohann D'ANELLO
Date: Fri, 22 Jan 2021 09:04:44 +0100
Subject: [PATCH 5/8] Gender is not a date
---
.../migrations/0002_participantregistration_gender.py | 4 ++--
apps/registration/models.py | 3 ++-
apps/registration/tests.py | 9 ++++++---
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/apps/registration/migrations/0002_participantregistration_gender.py b/apps/registration/migrations/0002_participantregistration_gender.py
index 0dd0e24..0bf81fa 100644
--- a/apps/registration/migrations/0002_participantregistration_gender.py
+++ b/apps/registration/migrations/0002_participantregistration_gender.py
@@ -1,4 +1,4 @@
-# Generated by Django 3.0.11 on 2021-01-22 07:42
+# Generated by Django 3.0.11 on 2021-01-22 08:00
from django.db import migrations, models
@@ -13,6 +13,6 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='participantregistration',
name='gender',
- field=models.DateField(choices=[('female', 'Female'), ('male', 'Male'), ('other', 'Other')], default='other', verbose_name='gender'),
+ field=models.CharField(choices=[('female', 'Female'), ('male', 'Male'), ('other', 'Other')], default='other', max_length=6, verbose_name='gender'),
),
]
diff --git a/apps/registration/models.py b/apps/registration/models.py
index ad1d3dd..3e12fce 100644
--- a/apps/registration/models.py
+++ b/apps/registration/models.py
@@ -128,7 +128,8 @@ class ParticipantRegistration(Registration):
default=date.today,
)
- gender = models.DateField(
+ gender = models.CharField(
+ max_length=6,
verbose_name=_("gender"),
choices=[
("female", _("Female")),
diff --git a/apps/registration/tests.py b/apps/registration/tests.py
index ffa7955..6866f9f 100644
--- a/apps/registration/tests.py
+++ b/apps/registration/tests.py
@@ -130,6 +130,7 @@ class TestRegistration(TestCase):
student_class=12,
school="God",
birth_date="2000-01-01",
+ gender="other",
address="1 Rue de Rivoli, 75001 Paris, France",
phone_number="0123456789",
responsible_name="Toto",
@@ -153,6 +154,7 @@ class TestRegistration(TestCase):
student_class=12,
school="God",
birth_date="2000-01-01",
+ gender="other",
address="1 Rue de Rivoli, 75001 Paris, France",
phone_number="0123456789",
responsible_name="Toto",
@@ -173,6 +175,7 @@ class TestRegistration(TestCase):
password2="azertyuiopazertyuiop",
role="coach",
birth_date="1980-01-01",
+ gender="other",
address="1 Rue de Rivoli, 75001 Paris, France",
phone_number="0123456789",
professional_activity="God",
@@ -252,10 +255,10 @@ class TestRegistration(TestCase):
for user, data in [(self.user, dict(role="Bot")),
(self.student, dict(student_class=11, school="Sky", birth_date="2001-01-01",
- address="1 Rue de Rivoli, 75001 Paris, France", responsible_name="Toto",
- responsible_email="toto@example.com")),
+ gender="female", address="1 Rue de Rivoli, 75001 Paris, France",
+ responsible_name="Toto", responsible_email="toto@example.com")),
(self.coach, dict(professional_activity="God", birth_date="2001-01-01",
- address="1 Rue de Rivoli, 75001 Paris, France"))]:
+ gender="male", address="1 Rue de Rivoli, 75001 Paris, France"))]:
response = self.client.get(reverse("registration:update_user", args=(user.pk,)))
self.assertEqual(response.status_code, 200)
From ce206998f00b4611bbc2bf91c110beab180e3502 Mon Sep 17 00:00:00 2001
From: Yohann D'ANELLO
Date: Fri, 22 Jan 2021 09:40:28 +0100
Subject: [PATCH 6/8] Teams must send their motivation letter
---
apps/participation/forms.py | 15 +
.../migrations/0003_team_motivation_letter.py | 19 +
apps/participation/models.py | 11 +
.../templates/participation/team_detail.html | 22 +
.../upload_motivation_letter.html | 15 +
apps/participation/urls.py | 6 +-
apps/participation/views.py | 74 ++-
apps/registration/tests.py | 1 +
apps/registration/views.py | 3 +
locale/fr/LC_MESSAGES/django.po | 455 ++++++++++--------
tfjm/lists.py | 2 +-
tfjm/urls.py | 3 +
12 files changed, 402 insertions(+), 224 deletions(-)
create mode 100644 apps/participation/migrations/0003_team_motivation_letter.py
create mode 100644 apps/participation/templates/participation/upload_motivation_letter.html
diff --git a/apps/participation/forms.py b/apps/participation/forms.py
index 02a8279..782cdc1 100644
--- a/apps/participation/forms.py
+++ b/apps/participation/forms.py
@@ -59,6 +59,21 @@ class ParticipationForm(forms.ModelForm):
fields = ('tournament',)
+class MotivationLetterForm(forms.ModelForm):
+ def clean_file(self):
+ if "file" in self.files:
+ file = self.files["motivation_letter"]
+ if file.size > 2e6:
+ raise ValidationError(_("The uploaded file size must be under 2 Mo."))
+ if file.content_type not in ["application/pdf", "image/png", "image/jpeg"]:
+ raise ValidationError(_("The uploaded file must be a PDF, PNG of JPEG file."))
+ return self.cleaned_data["motivation_letter"]
+
+ class Meta:
+ model = Team
+ fields = ('motivation_letter',)
+
+
class RequestValidationForm(forms.Form):
"""
Form to ask about validation.
diff --git a/apps/participation/migrations/0003_team_motivation_letter.py b/apps/participation/migrations/0003_team_motivation_letter.py
new file mode 100644
index 0000000..fb298af
--- /dev/null
+++ b/apps/participation/migrations/0003_team_motivation_letter.py
@@ -0,0 +1,19 @@
+# Generated by Django 3.0.11 on 2021-01-22 08:15
+
+from django.db import migrations, models
+import participation.models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('participation', '0002_auto_20210121_2206'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='team',
+ name='motivation_letter',
+ field=models.FileField(blank=True, default='', upload_to=participation.models.get_motivation_letter_filename, verbose_name='motivation letter'),
+ ),
+ ]
diff --git a/apps/participation/models.py b/apps/participation/models.py
index d19a0d6..912125b 100644
--- a/apps/participation/models.py
+++ b/apps/participation/models.py
@@ -20,6 +20,10 @@ from tfjm.lists import get_sympa_client
from tfjm.matrix import Matrix, RoomPreset, RoomVisibility
+def get_motivation_letter_filename(instance, filename):
+ return f"authorization/motivation_letters/motivation_letter_{instance.trigram}"
+
+
class Team(models.Model):
"""
The Team model represents a real team that participates to the TFJM².
@@ -45,6 +49,13 @@ class Team(models.Model):
help_text=_("The access code let other people to join the team."),
)
+ motivation_letter = models.FileField(
+ verbose_name=_("motivation letter"),
+ upload_to=get_motivation_letter_filename,
+ blank=True,
+ default="",
+ )
+
@property
def students(self):
return self.participants.filter(studentregistration__isnull=False)
diff --git a/apps/participation/templates/participation/team_detail.html b/apps/participation/templates/participation/team_detail.html
index 03dc45f..ff3acac 100644
--- a/apps/participation/templates/participation/team_detail.html
+++ b/apps/participation/templates/participation/team_detail.html
@@ -85,6 +85,18 @@
{% endif %}
{% endfor %}
+
+ {% trans "Motivation letter:" %}
+
+ {% if team.motivation_letter %}
+ {% trans "Download" %}
+ {% else %}
+ {% trans "Not uploaded yet" %}
+ {% endif %}
+ {% if user.registration.team == team and not user.registration.team.participation.valid or user.registration.is_admin %}
+ {% trans "Replace" %}
+ {% endif %}
+