mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-11 04:19:25 +00:00
methode clean dans MergeForm
fixed formatting Update rootplace/forms.py Co-authored-by: thomas girod <56346771+imperosol@users.noreply.github.com> Check that a user cannot be merged into itself ajout des traductions changed test language to french Check that a user cannot be merged into itself
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
from django import forms
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from core.models import User, UserBan
|
||||
@ -22,6 +23,16 @@ class MergeForm(forms.Form):
|
||||
queryset=User.objects.all(),
|
||||
)
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super().clean()
|
||||
user1 = cleaned_data.get("user1")
|
||||
user2 = cleaned_data.get("user2")
|
||||
|
||||
if user1.id == user2.id:
|
||||
raise ValidationError(_("You cannot merge two identical users."))
|
||||
|
||||
return cleaned_data
|
||||
|
||||
|
||||
class SelectUserForm(forms.Form):
|
||||
user = forms.ModelChoiceField(
|
||||
|
Reference in New Issue
Block a user