diff --git a/users/forms.py b/users/forms.py
index ae4481a..ddf26ef 100644
--- a/users/forms.py
+++ b/users/forms.py
@@ -21,6 +21,12 @@ class CreateUserForm(forms.ModelForm):
school = forms.ModelChoiceField(queryset=School.objects.all(), label="École")
+ def clean(self):
+ cleaned_data = super().clean()
+ email = cleaned_data.get("email")
+ if User.objects.filter(email=email).count() > 0:
+ raise forms.ValidationError("L'email est déjà utilisé")
+
class CreateGroupForm(forms.ModelForm):
"""
Form to create a new group (:class:`django.contrib.auth.models.Group`).
diff --git a/users/models.py b/users/models.py
index a3e8310..52231e2 100644
--- a/users/models.py
+++ b/users/models.py
@@ -8,8 +8,6 @@ from preferences.models import PaymentMethod, Cotisation
from gestion.models import ConsumptionHistory
-User._meta.get_field('email')._unique = True
-
class School(models.Model):
"""
Stores school.
diff --git a/users/templates/users/profile.html b/users/templates/users/profile.html
index 0b90ecf..c7b3de7 100644
--- a/users/templates/users/profile.html
+++ b/users/templates/users/profile.html
@@ -58,9 +58,6 @@
{% if self %}
Changer mon mot de passe
{% endif %}
- {% if perms.users.can_reset_password %}
- Réinitialiser le mot de passe
- {% endif %}
{% if perms.users.can_change_user_perm %}
Changer les groupes
{% endif %}
diff --git a/users/urls.py b/users/urls.py
index 5f91232..413178d 100644
--- a/users/urls.py
+++ b/users/urls.py
@@ -14,7 +14,6 @@ urlpatterns = [
path('editGroups/', views.editGroups, name="editGroups"),
path('editPassword/', views.editPassword, name="editPassword"),
path('editUser/', views.editUser, name="editUser"),
- path('resetPassword/', views.resetPassword, name="resetPassword"),
path('groupsIndex', views.groupsIndex, name="groupsIndex"),
path('groupProfile/', views.groupProfile, name="groupProfile"),
path('createGroup', views.createGroup, name="createGroup"),
diff --git a/users/views.py b/users/views.py
index a2a8c20..ea3e75c 100644
--- a/users/views.py
+++ b/users/views.py
@@ -282,23 +282,6 @@ def editUser(request, pk):
return redirect(reverse('users:profile', kwargs={'pk': pk}))
return render(request, "form.html", {"form_entete":"Modification du compte " + user.username, "form": form, "form_title": "Modification des informations", "form_button": "Modifier", "form_button_icon": "pencil-alt"})
-@active_required
-@login_required
-@permission_required('auth.change_user')
-def resetPassword(request, pk):
- """
- Reset the password of a user (:class:`django.contrib.auth.models.User`).
- """
- user = get_object_or_404(User, pk=pk)
- if user.is_superuser:
- messages.error(request, "Impossible de réinitialiser le mot de passe de " + user.username + " : il est superuser.")
- return redirect(reverse('users:profile', kwargs={'pk': pk}))
- else:
- user.set_password(user.username)
- user.save()
- messages.success(request, "Le mot de passe de " + user.username + " a bien été réinitialisé.")
- return redirect(reverse('users:profile', kwargs={'pk': pk}))
-
@active_required
@login_required
@permission_required('auth.view_user')