mirror of
https://github.com/ae-utbm/sith.git
synced 2025-03-31 08:50:26 +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:
parent
ac1e40038e
commit
df2d0d4d4c
@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2025-02-25 16:38+0100\n"
|
||||
"POT-Creation-Date: 2025-03-28 13:51+0100\n"
|
||||
"PO-Revision-Date: 2016-07-18\n"
|
||||
"Last-Translator: Maréchal <thomas.girod@utbm.fr\n"
|
||||
"Language-Team: AE info <ae.info@utbm.fr>\n"
|
||||
@ -935,10 +935,6 @@ msgstr "rôle"
|
||||
msgid "description"
|
||||
msgstr "description"
|
||||
|
||||
#: club/models.py
|
||||
msgid "past member"
|
||||
msgstr "ancien membre"
|
||||
|
||||
#: club/models.py
|
||||
msgid "Email address"
|
||||
msgstr "Adresse email"
|
||||
@ -2837,6 +2833,7 @@ msgid "Users"
|
||||
msgstr "Utilisateurs"
|
||||
|
||||
#: core/templates/core/search.jinja core/views/user.py
|
||||
#: counter/templates/counter/product_list.jinja
|
||||
msgid "Clubs"
|
||||
msgstr "Clubs"
|
||||
|
||||
@ -3182,7 +3179,7 @@ msgid "Bans"
|
||||
msgstr "Bans"
|
||||
|
||||
#: core/templates/core/user_tools.jinja counter/forms.py
|
||||
#: counter/views/mixins.py
|
||||
#: counter/templates/counter/product_list.jinja counter/views/mixins.py
|
||||
msgid "Counters"
|
||||
msgstr "Comptoirs"
|
||||
|
||||
@ -3338,8 +3335,8 @@ msgstr "Nom d'utilisateur, email, ou numéro de compte AE"
|
||||
|
||||
#: core/views/forms.py
|
||||
msgid ""
|
||||
"Profile: you need to be visible on the picture, in order to be recognized "
|
||||
"(e.g. by the barmen)"
|
||||
"Profile: you need to be visible on the picture, in order to be recognized (e."
|
||||
"g. by the barmen)"
|
||||
msgstr ""
|
||||
"Photo de profil: vous devez être visible sur la photo afin d'être reconnu "
|
||||
"(par exemple par les barmen)"
|
||||
@ -3949,8 +3946,8 @@ msgstr ""
|
||||
#: counter/templates/counter/mails/account_dump.jinja
|
||||
msgid "If you think this was a mistake, please mail us at ae@utbm.fr."
|
||||
msgstr ""
|
||||
"Si vous pensez qu'il s'agit d'une erreur, veuillez envoyer un mail à "
|
||||
"ae@utbm.fr."
|
||||
"Si vous pensez qu'il s'agit d'une erreur, veuillez envoyer un mail à ae@utbm."
|
||||
"fr."
|
||||
|
||||
#: counter/templates/counter/mails/account_dump.jinja
|
||||
msgid ""
|
||||
@ -5120,6 +5117,10 @@ msgstr "Utilisateur qui sera conservé"
|
||||
msgid "User that will be deleted"
|
||||
msgstr "Utilisateur qui sera supprimé"
|
||||
|
||||
#: rootplace/forms.py
|
||||
msgid "You cannot merge two identical users."
|
||||
msgstr "Vous ne pouvez pas fusionner deux utilisateurs identiques."
|
||||
|
||||
#: rootplace/forms.py
|
||||
msgid "User to be selected"
|
||||
msgstr "Utilisateur à sélectionner"
|
||||
@ -5219,15 +5220,15 @@ msgstr "SAS"
|
||||
msgid "Albums"
|
||||
msgstr "Albums"
|
||||
|
||||
#: sas/templates/sas/album.jinja
|
||||
msgid "Download album"
|
||||
msgstr "Télécharger l'album"
|
||||
|
||||
#: sas/templates/sas/album.jinja sas/templates/sas/macros.jinja
|
||||
#: sas/templates/sas/user_pictures.jinja
|
||||
msgid "To be moderated"
|
||||
msgstr "A modérer"
|
||||
|
||||
#: sas/templates/sas/album.jinja
|
||||
msgid "Download album"
|
||||
msgstr "Télécharger l'album"
|
||||
|
||||
#: sas/templates/sas/album.jinja
|
||||
msgid "Upload"
|
||||
msgstr "Envoyer"
|
||||
@ -6042,3 +6043,6 @@ msgstr "Vous ne pouvez plus écrire de commentaires, la date est passée."
|
||||
#, python-format
|
||||
msgid "Maximum characters: %(max_length)s"
|
||||
msgstr "Nombre de caractères max: %(max_length)s"
|
||||
|
||||
#~ msgid "past member"
|
||||
#~ msgstr "ancien membre"
|
||||
|
@ -7,7 +7,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2025-02-25 16:10+0100\n"
|
||||
"POT-Creation-Date: 2025-03-28 13:52+0100\n"
|
||||
"PO-Revision-Date: 2024-09-17 11:54+0200\n"
|
||||
"Last-Translator: Sli <antoine@bartuccio.fr>\n"
|
||||
"Language-Team: AE info <ae.info@utbm.fr>\n"
|
||||
@ -34,6 +34,7 @@ msgid "Delete"
|
||||
msgstr "Supprimer"
|
||||
|
||||
#: com/static/bundled/com/components/moderation-alert-index.ts
|
||||
#, javascript-format
|
||||
msgid ""
|
||||
"This event will take place every week for %s weeks. If you publish or delete "
|
||||
"this event, it will also be published (or deleted) for the following weeks."
|
||||
|
@ -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(
|
||||
|
@ -22,6 +22,7 @@ from django.utils.timezone import localtime, now
|
||||
from club.models import Club
|
||||
from core.models import Group, User
|
||||
from counter.models import Counter, Customer, Product, Refilling, Selling
|
||||
from rootplace.forms import MergeForm
|
||||
from subscription.models import Subscription
|
||||
|
||||
|
||||
@ -79,6 +80,15 @@ class TestMergeUser(TestCase):
|
||||
sas_admin.id,
|
||||
}
|
||||
|
||||
def test_identical_accounts(self):
|
||||
form = MergeForm(data={"user1": self.to_keep.id, "user2": self.to_keep.id})
|
||||
assert not form.is_valid()
|
||||
assert "__all__" in form.errors
|
||||
assert (
|
||||
"Vous ne pouvez pas fusionner deux utilisateurs identiques."
|
||||
in form.errors["__all__"]
|
||||
)
|
||||
|
||||
def test_both_subscribers_and_with_account(self):
|
||||
Customer(user=self.to_keep, account_id="11000l", amount=0).save()
|
||||
Customer(user=self.to_delete, account_id="12000m", amount=0).save()
|
||||
|
Loading…
x
Reference in New Issue
Block a user