Give the student role when creating a new user subscription

This commit is contained in:
imperosol
2025-02-24 07:13:19 +01:00
parent a96b374ad7
commit 9c0d89de83
2 changed files with 29 additions and 0 deletions

View File

@ -100,6 +100,13 @@ class SubscriptionNewUserForm(SubscriptionForm):
email=self.cleaned_data.get("email"),
date_of_birth=self.cleaned_data.get("date_of_birth"),
)
if self.cleaned_data.get("subscription_type") in [
"un-semestre",
"deux-semestres",
"cursus-tronc-commun",
"cursus-branche",
]:
member.role = "STUDENT"
member.generate_username()
member.set_password(secrets.token_urlsafe(nbytes=10))
self.instance.member = member