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): class Meta(OrderedModel.Meta):
verbose_name = _("club role") verbose_name = _("club role")
verbose_name_plural = _("club roles") verbose_name_plural = _("club roles")
abstract = False
constraints = [ constraints = [
# presidency IMPLIES board <=> NOT presidency OR board # presidency IMPLIES board <=> NOT presidency OR board
# cf. MT1 :) # cf. MT1 :)
@@ -276,14 +275,26 @@ class ClubRole(OrderedModel):
% {"name": self.name} % {"name": self.name}
) )
) )
roles = list(self.club.roles.all())
if ( if (
self.is_board self.is_board
and self.order 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( errors.append(
ValidationError( 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} % {"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.""" """Test that newly created roles are put in the right place."""
club = baker.make(Club) club = baker.make(Club)
recipe = Recipe(ClubRole, club=club, name=seq("role ")) 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( roles = recipe.make(
is_board=iter([True, True, False]), is_board=iter([True, True, False]),
is_presidency=iter([True, False, False]), is_presidency=iter([True, False, False]),
+25 -39
View File
@@ -6,7 +6,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Report-Msgid-Bugs-To: \n" "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" "PO-Revision-Date: 2016-07-18\n"
"Last-Translator: Maréchal <thomas.girod@utbm.fr\n" "Last-Translator: Maréchal <thomas.girod@utbm.fr\n"
"Language-Team: AE info <ae.info@utbm.fr>\n" "Language-Team: AE info <ae.info@utbm.fr>\n"
@@ -258,7 +258,8 @@ msgstr "Rôle de la présidence"
msgid "" msgid ""
"If the role is inactive, people joining the club won't be able to get it." "If the role is inactive, people joining the club won't be able to get it."
msgstr "" 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 #: club/models.py
msgid "club role" msgid "club role"
@@ -273,12 +274,20 @@ msgstr "rôles de club"
msgid "" msgid ""
"Role %(name)s was declared as a presidency role without being a board role" "Role %(name)s was declared as a presidency role without being a board role"
msgstr "" 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 #: club/models.py
#, python-format #, python-format
msgid "Board role %(role)s cannot be placed below a member role" msgid "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." 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 #: club/models.py core/models.py counter/models.py eboutic/models.py
#: election/models.py pedagogy/models.py sas/models.py trombi/models.py #: election/models.py pedagogy/models.py sas/models.py trombi/models.py
@@ -297,10 +306,9 @@ msgstr "date de fin"
msgid "role" msgid "role"
msgstr "rôle" msgstr "rôle"
#: club/models.py core/models.py counter/models.py election/models.py #: club/models.py
#: forum/models.py msgid "past member"
msgid "description" msgstr "ancien membre"
msgstr "description"
#: club/models.py com/templates/com/mailing_admin.jinja #: club/models.py com/templates/com/mailing_admin.jinja
#: com/templates/com/news_admin_list.jinja com/templates/com/weekmail.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 #: core/views/forms.py
msgid "" msgid ""
"Profile: you need to be visible on the picture, in order to be recognized (e." "Profile: you need to be visible on the picture, in order to be recognized "
"g. by the barmen)" "(e.g. by the barmen)"
msgstr "" msgstr ""
"Photo de profil: vous devez être visible sur la photo afin d'être reconnu " "Photo de profil: vous devez être visible sur la photo afin d'être reconnu "
"(par exemple par les barmen)" "(par exemple par les barmen)"
@@ -3733,10 +3741,10 @@ msgid ""
"orders a sandwich and a soft drink, the formula will be applied and the " "orders a sandwich and a soft drink, the formula will be applied and the "
"basket will then contain a sandwich formula instead." "basket will then contain a sandwich formula instead."
msgstr "" msgstr ""
"Par exemple s'il existe une formule associant un produit « Formule sandwich " "Par exemple s'il existe une formule associant un produit « Formule "
"» aux produits « Sandwich » et « Soft », alors, si une personne commande un " "sandwich » aux produits « Sandwich » et « Soft », alors, si une personne "
"sandwich et un soft, la formule sera appliquée et le panier contiendra alors " "commande un sandwich et un soft, la formule sera appliquée et le panier "
"une formule sandwich à la place." "contiendra alors une formule sandwich à la place."
#: counter/templates/counter/formula_list.jinja #: counter/templates/counter/formula_list.jinja
msgid "New formula" msgid "New formula"
@@ -3798,8 +3806,8 @@ msgstr ""
#: counter/templates/counter/mails/account_dump.jinja #: counter/templates/counter/mails/account_dump.jinja
msgid "If you think this was a mistake, please mail us at ae@utbm.fr." msgid "If you think this was a mistake, please mail us at ae@utbm.fr."
msgstr "" msgstr ""
"Si vous pensez qu'il s'agit d'une erreur, veuillez envoyer un mail à ae@utbm." "Si vous pensez qu'il s'agit d'une erreur, veuillez envoyer un mail à "
"fr." "ae@utbm.fr."
#: counter/templates/counter/mails/account_dump.jinja #: counter/templates/counter/mails/account_dump.jinja
msgid "" msgid ""
@@ -5418,10 +5426,6 @@ msgstr "Cursus branche (-20%)"
msgid "Alternating cursus (-20%)" msgid "Alternating cursus (-20%)"
msgstr "Cursus alternant (-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 #: sith/settings.py
msgid "A new poster needs to be moderated" msgid "A new poster needs to be moderated"
msgstr "Une nouvelle affiche a besoin d'être modérée" 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 #, python-format
msgid "Maximum characters: %(max_length)s" msgid "Maximum characters: %(max_length)s"
msgstr "Nombre de caractères max: %(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)"