Don't create WEI registrations for unvalidated users

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
Yohann D'ANELLO 2021-09-08 18:47:45 +02:00
parent 7edd622755
commit bd035744a4
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
2 changed files with 75 additions and 38 deletions

View File

@ -6,7 +6,7 @@ from django.contrib.auth.models import User
from django.db.models import Q from django.db.models import Q
from django.forms import CheckboxSelectMultiple from django.forms import CheckboxSelectMultiple
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from note.models import NoteSpecial from note.models import NoteSpecial, NoteUser
from note_kfet.inputs import AmountInput, DatePickerInput, Autocomplete, ColorWidget from note_kfet.inputs import AmountInput, DatePickerInput, Autocomplete, ColorWidget
from ..models import WEIClub, WEIRegistration, Bus, BusTeam, WEIMembership, WEIRole from ..models import WEIClub, WEIRegistration, Bus, BusTeam, WEIMembership, WEIRole
@ -27,6 +27,15 @@ class WEIForm(forms.ModelForm):
class WEIRegistrationForm(forms.ModelForm): class WEIRegistrationForm(forms.ModelForm):
def clean(self):
cleaned_data = super().clean()
if 'user' in cleaned_data:
if not NoteUser.objects.filter(user=cleaned_data['user']).exists():
self.add_error('user', _("The selected user is not validated. Please validate its account first"))
return cleaned_data
class Meta: class Meta:
model = WEIRegistration model = WEIRegistration
exclude = ('wei', ) exclude = ('wei', )

View File

@ -7,7 +7,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-09-06 00:45+0200\n" "POT-Creation-Date: 2021-09-08 18:46+0200\n"
"PO-Revision-Date: 2020-11-16 20:02+0000\n" "PO-Revision-Date: 2020-11-16 20:02+0000\n"
"Last-Translator: Yohann D'ANELLO <ynerant@crans.org>\n" "Last-Translator: Yohann D'ANELLO <ynerant@crans.org>\n"
"Language-Team: French <http://translate.ynerant.fr/projects/nk20/nk20/fr/>\n" "Language-Team: French <http://translate.ynerant.fr/projects/nk20/nk20/fr/>\n"
@ -257,14 +257,14 @@ msgstr "Type"
#: apps/activity/tables.py:82 apps/member/forms.py:186 #: apps/activity/tables.py:82 apps/member/forms.py:186
#: apps/registration/forms.py:90 apps/treasury/forms.py:131 #: apps/registration/forms.py:90 apps/treasury/forms.py:131
#: apps/wei/forms/registration.py:96 #: apps/wei/forms/registration.py:105
msgid "Last name" msgid "Last name"
msgstr "Nom de famille" msgstr "Nom de famille"
#: apps/activity/tables.py:84 apps/member/forms.py:191 #: apps/activity/tables.py:84 apps/member/forms.py:191
#: apps/note/templates/note/transaction_form.html:134 #: apps/note/templates/note/transaction_form.html:134
#: apps/registration/forms.py:95 apps/treasury/forms.py:133 #: apps/registration/forms.py:95 apps/treasury/forms.py:133
#: apps/wei/forms/registration.py:101 #: apps/wei/forms/registration.py:110
msgid "First name" msgid "First name"
msgstr "Prénom" msgstr "Prénom"
@ -508,7 +508,7 @@ msgstr "rôles"
msgid "fee" msgid "fee"
msgstr "cotisation" msgstr "cotisation"
#: apps/member/apps.py:14 apps/wei/tables.py:193 apps/wei/tables.py:224 #: apps/member/apps.py:14 apps/wei/tables.py:196 apps/wei/tables.py:227
msgid "member" msgid "member"
msgstr "adhérent" msgstr "adhérent"
@ -541,7 +541,7 @@ msgid "This image cannot be loaded."
msgstr "Cette image ne peut pas être chargée." msgstr "Cette image ne peut pas être chargée."
#: apps/member/forms.py:141 apps/member/views.py:102 #: apps/member/forms.py:141 apps/member/views.py:102
#: apps/registration/forms.py:33 apps/registration/views.py:259 #: apps/registration/forms.py:33 apps/registration/views.py:262
msgid "An alias with a similar name already exists." msgid "An alias with a similar name already exists."
msgstr "Un alias avec un nom similaire existe déjà." msgstr "Un alias avec un nom similaire existe déjà."
@ -554,12 +554,12 @@ msgid "Check this case if the Société Générale paid the inscription."
msgstr "Cochez cette case si la Société Générale a payé l'inscription." msgstr "Cochez cette case si la Société Générale a payé l'inscription."
#: apps/member/forms.py:172 apps/registration/forms.py:77 #: apps/member/forms.py:172 apps/registration/forms.py:77
#: apps/wei/forms/registration.py:83 #: apps/wei/forms/registration.py:92
msgid "Credit type" msgid "Credit type"
msgstr "Type de rechargement" msgstr "Type de rechargement"
#: apps/member/forms.py:173 apps/registration/forms.py:78 #: apps/member/forms.py:173 apps/registration/forms.py:78
#: apps/wei/forms/registration.py:84 #: apps/wei/forms/registration.py:93
msgid "No credit" msgid "No credit"
msgstr "Pas de rechargement" msgstr "Pas de rechargement"
@ -568,13 +568,13 @@ msgid "You can credit the note of the user."
msgstr "Vous pouvez créditer la note de l'utilisateur avant l'adhésion." msgstr "Vous pouvez créditer la note de l'utilisateur avant l'adhésion."
#: apps/member/forms.py:179 apps/registration/forms.py:83 #: apps/member/forms.py:179 apps/registration/forms.py:83
#: apps/wei/forms/registration.py:89 #: apps/wei/forms/registration.py:98
msgid "Credit amount" msgid "Credit amount"
msgstr "Montant à créditer" msgstr "Montant à créditer"
#: apps/member/forms.py:196 apps/note/templates/note/transaction_form.html:140 #: apps/member/forms.py:196 apps/note/templates/note/transaction_form.html:140
#: apps/registration/forms.py:100 apps/treasury/forms.py:135 #: apps/registration/forms.py:100 apps/treasury/forms.py:135
#: apps/wei/forms/registration.py:106 #: apps/wei/forms/registration.py:115
msgid "Bank" msgid "Bank"
msgstr "Banque" msgstr "Banque"
@ -586,6 +586,22 @@ msgstr "Utilisateur"
msgid "Roles" msgid "Roles"
msgstr "Rôles" msgstr "Rôles"
#: apps/member/hashers.py:57
msgid "algorithm"
msgstr "algorithme"
#: apps/member/hashers.py:58
msgid "iterations"
msgstr "itérations"
#: apps/member/hashers.py:59
msgid "salt"
msgstr "salage"
#: apps/member/hashers.py:60
msgid "hash"
msgstr "haché"
#: apps/member/models.py:38 #: apps/member/models.py:38
#: apps/member/templates/member/includes/profile_info.html:35 #: apps/member/templates/member/includes/profile_info.html:35
#: apps/registration/templates/registration/future_profile_detail.html:40 #: apps/registration/templates/registration/future_profile_detail.html:40
@ -688,7 +704,7 @@ msgid "address"
msgstr "adresse" msgstr "adresse"
#: apps/member/models.py:90 #: apps/member/models.py:90
#: apps/member/templates/member/includes/profile_info.html:46 #: apps/member/templates/member/includes/profile_info.html:42
#: apps/registration/templates/registration/future_profile_detail.html:43 #: apps/registration/templates/registration/future_profile_detail.html:43
#: apps/wei/templates/wei/weimembership_form.html:47 #: apps/wei/templates/wei/weimembership_form.html:47
msgid "paid" msgid "paid"
@ -1020,7 +1036,7 @@ msgid "membership fee"
msgstr "cotisation pour adhérer" msgstr "cotisation pour adhérer"
#: apps/member/templates/member/includes/club_info.html:43 #: apps/member/templates/member/includes/club_info.html:43
#: apps/member/templates/member/includes/profile_info.html:43 #: apps/member/templates/member/includes/profile_info.html:47
#: apps/treasury/templates/treasury/sogecredit_detail.html:24 #: apps/treasury/templates/treasury/sogecredit_detail.html:24
#: apps/wei/templates/wei/base.html:60 #: apps/wei/templates/wei/base.html:60
msgid "balance" msgid "balance"
@ -1514,7 +1530,7 @@ msgstr "Pas de motif spécifié"
#: apps/note/tables.py:169 apps/note/tables.py:203 apps/treasury/tables.py:39 #: apps/note/tables.py:169 apps/note/tables.py:203 apps/treasury/tables.py:39
#: apps/treasury/templates/treasury/invoice_confirm_delete.html:30 #: apps/treasury/templates/treasury/invoice_confirm_delete.html:30
#: apps/treasury/templates/treasury/sogecredit_detail.html:65 #: apps/treasury/templates/treasury/sogecredit_detail.html:65
#: apps/wei/tables.py:74 apps/wei/tables.py:114 #: apps/wei/tables.py:74 apps/wei/tables.py:117
#: apps/wei/templates/wei/weiregistration_confirm_delete.html:31 #: apps/wei/templates/wei/weiregistration_confirm_delete.html:31
#: note_kfet/templates/oauth2_provider/application_confirm_delete.html:18 #: note_kfet/templates/oauth2_provider/application_confirm_delete.html:18
#: note_kfet/templates/oauth2_provider/application_detail.html:39 #: note_kfet/templates/oauth2_provider/application_detail.html:39
@ -1770,7 +1786,7 @@ msgstr "s'applique au club"
msgid "role permissions" msgid "role permissions"
msgstr "permissions par rôles" msgstr "permissions par rôles"
#: apps/permission/signals.py:67 #: apps/permission/signals.py:73
#, python-brace-format #, python-brace-format
msgid "" msgid ""
"You don't have the permission to change the field {field} on this instance " "You don't have the permission to change the field {field} on this instance "
@ -1779,7 +1795,7 @@ msgstr ""
"Vous n'avez pas la permission de modifier le champ {field} sur l'instance du " "Vous n'avez pas la permission de modifier le champ {field} sur l'instance du "
"modèle {app_label}.{model_name}." "modèle {app_label}.{model_name}."
#: apps/permission/signals.py:77 apps/permission/views.py:105 #: apps/permission/signals.py:83 apps/permission/views.py:105
#, python-brace-format #, python-brace-format
msgid "" msgid ""
"You don't have the permission to add an instance of model {app_label}." "You don't have the permission to add an instance of model {app_label}."
@ -1788,7 +1804,7 @@ msgstr ""
"Vous n'avez pas la permission d'ajouter une instance du modèle {app_label}." "Vous n'avez pas la permission d'ajouter une instance du modèle {app_label}."
"{model_name}." "{model_name}."
#: apps/permission/signals.py:106 #: apps/permission/signals.py:112
#, python-brace-format #, python-brace-format
msgid "" msgid ""
"You don't have the permission to delete this instance of model {app_label}." "You don't have the permission to delete this instance of model {app_label}."
@ -2035,50 +2051,50 @@ msgstr "L'équipe de la Note Kfet."
msgid "Register new user" msgid "Register new user"
msgstr "Enregistrer un nouvel utilisateur" msgstr "Enregistrer un nouvel utilisateur"
#: apps/registration/views.py:95 #: apps/registration/views.py:98
msgid "Email validation" msgid "Email validation"
msgstr "Validation de l'adresse mail" msgstr "Validation de l'adresse mail"
#: apps/registration/views.py:97 #: apps/registration/views.py:100
msgid "Validate email" msgid "Validate email"
msgstr "Valider l'adresse e-mail" msgstr "Valider l'adresse e-mail"
#: apps/registration/views.py:141 #: apps/registration/views.py:144
msgid "Email validation unsuccessful" msgid "Email validation unsuccessful"
msgstr "La validation de l'adresse mail a échoué" msgstr "La validation de l'adresse mail a échoué"
#: apps/registration/views.py:152 #: apps/registration/views.py:155
msgid "Email validation email sent" msgid "Email validation email sent"
msgstr "L'email de vérification de l'adresse email a bien été envoyé" msgstr "L'email de vérification de l'adresse email a bien été envoyé"
#: apps/registration/views.py:160 #: apps/registration/views.py:163
msgid "Resend email validation link" msgid "Resend email validation link"
msgstr "Renvoyer le lien de validation" msgstr "Renvoyer le lien de validation"
#: apps/registration/views.py:178 #: apps/registration/views.py:181
msgid "Pre-registered users list" msgid "Pre-registered users list"
msgstr "Liste des utilisateurs en attente d'inscription" msgstr "Liste des utilisateurs en attente d'inscription"
#: apps/registration/views.py:202 #: apps/registration/views.py:205
msgid "Unregistered users" msgid "Unregistered users"
msgstr "Utilisateurs en attente d'inscription" msgstr "Utilisateurs en attente d'inscription"
#: apps/registration/views.py:215 #: apps/registration/views.py:218
msgid "Registration detail" msgid "Registration detail"
msgstr "Détails de l'inscription" msgstr "Détails de l'inscription"
#: apps/registration/views.py:279 #: apps/registration/views.py:282
msgid "You must join the BDE." msgid "You must join the BDE."
msgstr "Vous devez adhérer au BDE." msgstr "Vous devez adhérer au BDE."
#: apps/registration/views.py:303 #: apps/registration/views.py:306
msgid "" msgid ""
"The entered amount is not enough for the memberships, should be at least {}" "The entered amount is not enough for the memberships, should be at least {}"
msgstr "" msgstr ""
"Le montant crédité est trop faible pour adhérer, il doit être au minimum de " "Le montant crédité est trop faible pour adhérer, il doit être au minimum de "
"{}" "{}"
#: apps/registration/views.py:384 #: apps/registration/views.py:387
msgid "Invalidate pre-registration" msgid "Invalidate pre-registration"
msgstr "Invalider l'inscription" msgstr "Invalider l'inscription"
@ -2494,12 +2510,18 @@ msgstr "Gérer les crédits de la Société générale"
msgid "WEI" msgid "WEI"
msgstr "WEI" msgstr "WEI"
#: apps/wei/forms/registration.py:51 apps/wei/models.py:118 #: apps/wei/forms/registration.py:35
msgid "The selected user is not validated. Please validate its account first"
msgstr ""
"L'utilisateur sélectionné n'est pas validé. Merci de d'abord valider son "
"compte."
#: apps/wei/forms/registration.py:60 apps/wei/models.py:118
#: apps/wei/models.py:315 #: apps/wei/models.py:315
msgid "bus" msgid "bus"
msgstr "bus" msgstr "bus"
#: apps/wei/forms/registration.py:52 #: apps/wei/forms/registration.py:61
msgid "" msgid ""
"This choice is not definitive. The WEI organizers are free to attribute for " "This choice is not definitive. The WEI organizers are free to attribute for "
"you a bus and a team, in particular if you are a free eletron." "you a bus and a team, in particular if you are a free eletron."
@ -2508,11 +2530,11 @@ msgstr ""
"attribuer un bus et une équipe, en particulier si vous êtes un électron " "attribuer un bus et une équipe, en particulier si vous êtes un électron "
"libre." "libre."
#: apps/wei/forms/registration.py:59 #: apps/wei/forms/registration.py:68
msgid "Team" msgid "Team"
msgstr "Équipe" msgstr "Équipe"
#: apps/wei/forms/registration.py:61 #: apps/wei/forms/registration.py:70
msgid "" msgid ""
"Leave this field empty if you won't be in a team (staff, bus chief, free " "Leave this field empty if you won't be in a team (staff, bus chief, free "
"electron)" "electron)"
@ -2520,16 +2542,16 @@ msgstr ""
"Laissez ce champ vide si vous ne serez pas dans une équipe (staff, chef de " "Laissez ce champ vide si vous ne serez pas dans une équipe (staff, chef de "
"bus ou électron libre)" "bus ou électron libre)"
#: apps/wei/forms/registration.py:67 apps/wei/forms/registration.py:77 #: apps/wei/forms/registration.py:76 apps/wei/forms/registration.py:86
#: apps/wei/models.py:153 #: apps/wei/models.py:153
msgid "WEI Roles" msgid "WEI Roles"
msgstr "Rôles au WEI" msgstr "Rôles au WEI"
#: apps/wei/forms/registration.py:68 #: apps/wei/forms/registration.py:77
msgid "Select the roles that you are interested in." msgid "Select the roles that you are interested in."
msgstr "Sélectionnez les rôles qui vous intéressent." msgstr "Sélectionnez les rôles qui vous intéressent."
#: apps/wei/forms/registration.py:113 #: apps/wei/forms/registration.py:122
msgid "This team doesn't belong to the given bus." msgid "This team doesn't belong to the given bus."
msgstr "Cette équipe n'appartient pas à ce bus." msgstr "Cette équipe n'appartient pas à ce bus."
@ -2688,23 +2710,29 @@ msgid "The user does not have enough money."
msgstr "L'utilisateur n'a pas assez d'argent." msgstr "L'utilisateur n'a pas assez d'argent."
#: apps/wei/tables.py:107 #: apps/wei/tables.py:107
msgid "The user is in first year, and the repartition algorithm didn't run."
msgstr ""
"L'utilisateur est en première année, et l'algorithme de répartition n'a pas "
"tourné."
#: apps/wei/tables.py:110
msgid "The user has enough money, you can validate the registration." msgid "The user has enough money, you can validate the registration."
msgstr "L'utilisateur a assez d'argent, l'inscription est possible." msgstr "L'utilisateur a assez d'argent, l'inscription est possible."
#: apps/wei/tables.py:139 #: apps/wei/tables.py:142
msgid "Year" msgid "Year"
msgstr "Année" msgstr "Année"
#: apps/wei/tables.py:177 apps/wei/templates/wei/bus_detail.html:32 #: apps/wei/tables.py:180 apps/wei/templates/wei/bus_detail.html:32
#: apps/wei/templates/wei/busteam_detail.html:50 #: apps/wei/templates/wei/busteam_detail.html:50
msgid "Teams" msgid "Teams"
msgstr "Équipes" msgstr "Équipes"
#: apps/wei/tables.py:186 apps/wei/tables.py:227 #: apps/wei/tables.py:189 apps/wei/tables.py:230
msgid "Members count" msgid "Members count"
msgstr "Nombre de membres" msgstr "Nombre de membres"
#: apps/wei/tables.py:193 apps/wei/tables.py:224 #: apps/wei/tables.py:196 apps/wei/tables.py:227
msgid "members" msgid "members"
msgstr "adhérents" msgstr "adhérents"