add forgotten check

This commit is contained in:
imperosol
2026-04-10 18:53:29 +02:00
parent a40c43204a
commit 8876c64f54
3 changed files with 40 additions and 43 deletions
+14 -3
View File
@@ -245,7 +245,6 @@ class ClubRole(OrderedModel):
class Meta(OrderedModel.Meta):
verbose_name = _("club role")
verbose_name_plural = _("club roles")
abstract = False
constraints = [
# presidency IMPLIES board <=> NOT presidency OR board
# cf. MT1 :)
@@ -276,14 +275,26 @@ class ClubRole(OrderedModel):
% {"name": self.name}
)
)
roles = list(self.club.roles.all())
if (
self.is_board
and self.order
and self.club.roles.filter(is_board=False, order__lt=self.order).exists()
and any(r.order < self.order and not r.is_board for r in roles)
):
errors.append(
ValidationError(
_("Board role %(role)s cannot be placed below a member role")
_("Role %(role)s cannot be placed below a member role")
% {"role": self.name}
)
)
if (
self.is_presidency
and self.order
and any(r.order < self.order and not r.is_presidency for r in roles)
):
errors.append(
ValidationError(
_("Role %(role)s cannot be placed below a non-presidency role")
% {"role": self.name}
)
)
+1 -1
View File
@@ -10,7 +10,7 @@ def test_order_auto():
"""Test that newly created roles are put in the right place."""
club = baker.make(Club)
recipe = Recipe(ClubRole, club=club, name=seq("role "))
# bulk create initial roles
# bulk create initial roles (1 presidency, 1 board, 1 member)
roles = recipe.make(
is_board=iter([True, True, False]),
is_presidency=iter([True, False, False]),
+25 -39
View File
@@ -6,7 +6,7 @@
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2026-05-10 20:27+0200\n"
"POT-Creation-Date: 2026-05-12 09:48+0200\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"
@@ -258,7 +258,8 @@ msgstr "Rôle de la présidence"
msgid ""
"If the role is inactive, people joining the club won't be able to get it."
msgstr ""
"Si ce rôle est inactif, il ne pourra pas être attribué aux gens qui rejoignent le club."
"Si ce rôle est inactif, il ne pourra pas être attribué aux gens qui "
"rejoignent le club."
#: club/models.py
msgid "club role"
@@ -273,12 +274,20 @@ msgstr "rôles de club"
msgid ""
"Role %(name)s was declared as a presidency role without being a board role"
msgstr ""
"Le rôle %(name)s a été déclaré comme rôle de présidence sans être un rôle du bureau."
"Le rôle %(name)s a été déclaré comme rôle de présidence sans être un rôle du "
"bureau."
#: club/models.py
#, python-format
msgid "Board role %(role)s cannot be placed below a member role"
msgstr "Le rôle du bureau %(role)s ne peut pas être placé en-dessous d'un rôle de membre."
msgid "Role %(role)s cannot be placed below a member role"
msgstr ""
"Le rôle %(role)s ne peut pas être placé en-dessous d'un rôle de membre."
#: club/models.py
#, python-format
msgid "Role %(role)s cannot be placed below a non-presidency role"
msgstr ""
"Le rôle %(role)s ne peut pas être placé en-dessous d'un rôle de membre."
#: club/models.py core/models.py counter/models.py eboutic/models.py
#: election/models.py pedagogy/models.py sas/models.py trombi/models.py
@@ -297,10 +306,9 @@ msgstr "date de fin"
msgid "role"
msgstr "rôle"
#: club/models.py core/models.py counter/models.py election/models.py
#: forum/models.py
msgid "description"
msgstr "description"
#: club/models.py
msgid "past member"
msgstr "ancien membre"
#: club/models.py com/templates/com/mailing_admin.jinja
#: com/templates/com/news_admin_list.jinja com/templates/com/weekmail.jinja
@@ -2932,8 +2940,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)"
@@ -3733,10 +3741,10 @@ msgid ""
"orders a sandwich and a soft drink, the formula will be applied and the "
"basket will then contain a sandwich formula instead."
msgstr ""
"Par exemple s'il existe une formule associant un produit « Formule sandwich "
"» aux produits « Sandwich » et « Soft », alors, si une personne commande un "
"sandwich et un soft, la formule sera appliquée et le panier contiendra alors "
"une formule sandwich à la place."
"Par exemple s'il existe une formule associant un produit « Formule "
"sandwich » aux produits « Sandwich » et « Soft », alors, si une personne "
"commande un sandwich et un soft, la formule sera appliquée et le panier "
"contiendra alors une formule sandwich à la place."
#: counter/templates/counter/formula_list.jinja
msgid "New formula"
@@ -3798,8 +3806,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 ""
@@ -5418,10 +5426,6 @@ msgstr "Cursus branche (-20%)"
msgid "Alternating cursus (-20%)"
msgstr "Cursus alternant (-20%)"
#: sith/settings.py
msgid "One year for free(CA offer)"
msgstr "Une année offerte (Offre CA)"
#: sith/settings.py
msgid "A new poster needs to be moderated"
msgstr "Une nouvelle affiche a besoin d'être modérée"
@@ -5899,21 +5903,3 @@ 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"
#~ msgid "One semester Welcome Week"
#~ msgstr "Un semestre Welcome Week"
#~ msgid "Eurok's volunteer"
#~ msgstr "Bénévole Eurockéennes"
#~ msgid "Six weeks for free"
#~ msgstr "6 semaines gratuites"
#~ msgid "GA staff member"
#~ msgstr "Membre staff GA"
#~ msgid "One year for free(CA offer)"
#~ msgstr "Une année offerte (Offre CA)"