mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-07-04 04:12:08 +02:00
Register new organizers
This commit is contained in:
@ -45,6 +45,38 @@ class SignupForm(UserCreationForm):
|
||||
fields = ('first_name', 'last_name', 'email', 'password1', 'password2', 'role',)
|
||||
|
||||
|
||||
class AddOrganizerForm(forms.ModelForm):
|
||||
"""
|
||||
Signup form to registers volunteers
|
||||
"""
|
||||
type = forms.ChoiceField(
|
||||
label=lambda: _("role").capitalize(),
|
||||
choices=lambda: [
|
||||
("volunteer", _("volunteer").capitalize()),
|
||||
("admin", _("admin").capitalize()),
|
||||
],
|
||||
)
|
||||
|
||||
def clean_email(self):
|
||||
"""
|
||||
Ensure that the email address is unique.
|
||||
"""
|
||||
email = self.data["email"]
|
||||
if User.objects.filter(email=email).exists():
|
||||
self.add_error("email", _("This email address is already used."))
|
||||
return email
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.fields["first_name"].required = True
|
||||
self.fields["last_name"].required = True
|
||||
self.fields["email"].required = True
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ('first_name', 'last_name', 'email', 'type',)
|
||||
|
||||
|
||||
class UserForm(forms.ModelForm):
|
||||
"""
|
||||
Replace the default user form to require the first name, last name and the email.
|
||||
|
Reference in New Issue
Block a user