Commit c0f55d89 authored by Hamza Dely's avatar Hamza Dely
Browse files

[comptes/forms] Le formulaire de création d'adhérent utilise aussi Adherent.object.create()

parent 45e637d1
......@@ -85,24 +85,9 @@ class AdherentInscriptionForm(UserCreationForm):
Toute l'opération est effectuée de manière atomique dans
la base de données.
"""
with transaction.atomic():
adh = super().save(*args, **kwargs)
pseudo, _ = Alias.objects.get_or_create(alias=adh.pseudo)
pseudo.proprietaire = adh
pseudo.save()
Historique.objects.create(alias=pseudo, suivant=adh)
Adhesion.objects.create(
adherent=adh,
fin=timezone.now() + timedelta(days=365),
section=self.cleaned_data['section'],
)
for codename, niveau, meta in ACCREDITATIONS_DEFAUT.get(adh.type, []):
perm = Accreditation.objects.create(
droit=Droit.objects.get(codename=codename, niveau=niveau),
adherent=adh,
meta=meta,
)
return adh
self.cleaned_data.pop('password2')
self.cleaned_data['password'] = self.cleaned_data.pop('password1')
return self._meta.model.objects.create(**self.cleaned_data)
class AdherentPasswordChangeForm(PasswordChangeForm):
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment