From 8876c64f549e258ff9a5f84c3f5f5b2f0295069b Mon Sep 17 00:00:00 2001 From: imperosol Date: Fri, 10 Apr 2026 18:53:29 +0200 Subject: [PATCH] add forgotten check --- club/models.py | 17 +++++++-- club/tests/test_clubrole.py | 2 +- locale/fr/LC_MESSAGES/django.po | 64 +++++++++++++-------------------- 3 files changed, 40 insertions(+), 43 deletions(-) diff --git a/club/models.py b/club/models.py index 0f536b58..5e072853 100644 --- a/club/models.py +++ b/club/models.py @@ -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} ) ) diff --git a/club/tests/test_clubrole.py b/club/tests/test_clubrole.py index 54067862..6956ac8c 100644 --- a/club/tests/test_clubrole.py +++ b/club/tests/test_clubrole.py @@ -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]), diff --git a/locale/fr/LC_MESSAGES/django.po b/locale/fr/LC_MESSAGES/django.po index 66c3f83b..7791ae3f 100644 --- a/locale/fr/LC_MESSAGES/django.po +++ b/locale/fr/LC_MESSAGES/django.po @@ -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 \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)"