From 60a6fd4d1848e2019f2e06fff99cf90f191efa0e Mon Sep 17 00:00:00 2001 From: imperosol Date: Sat, 20 Dec 2025 09:58:26 +0100 Subject: [PATCH] remove settings.SITH_MAXIMUM_FREE_ROLE --- .../0012_club_board_group_club_members_group.py | 10 +++++----- club/migrations/0015_clubrole_alter_membership_role.py | 10 +++++----- sith/settings.py | 5 ----- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/club/migrations/0012_club_board_group_club_members_group.py b/club/migrations/0012_club_board_group_club_members_group.py index e436bcd4..a9ad8d3a 100644 --- a/club/migrations/0012_club_board_group_club_members_group.py +++ b/club/migrations/0012_club_board_group_club_members_group.py @@ -2,12 +2,15 @@ import django.db.models.deletion import django.db.models.functions.datetime -from django.conf import settings from django.db import migrations, models from django.db.migrations.state import StateApps from django.db.models import Q from django.utils.timezone import localdate +# Before the club role rework, the maximum free role +# was the hardcoded highest non-board role +MAXIMUM_FREE_ROLE = 1 + def migrate_meta_groups(apps: StateApps, schema_editor): """Attach the existing meta groups to the clubs. @@ -46,10 +49,7 @@ def migrate_meta_groups(apps: StateApps, schema_editor): ).select_related("user") club.members_group.users.set([m.user for m in memberships]) club.board_group.users.set( - [ - m.user - for m in memberships.filter(role__gt=settings.SITH_MAXIMUM_FREE_ROLE) - ] + [m.user for m in memberships.filter(role__gt=MAXIMUM_FREE_ROLE)] ) diff --git a/club/migrations/0015_clubrole_alter_membership_role.py b/club/migrations/0015_clubrole_alter_membership_role.py index 08431ea1..f776b20c 100644 --- a/club/migrations/0015_clubrole_alter_membership_role.py +++ b/club/migrations/0015_clubrole_alter_membership_role.py @@ -1,12 +1,12 @@ # Generated by Django 5.2.3 on 2025-06-21 21:59 import django.db.models.deletion -from django.conf import settings from django.db import migrations, models from django.db.migrations.state import StateApps from django.db.models import Case, When -PRESIDENT_ROLE = 10 +PRESIDENCY_ROLES = [10, 9] +MAXIMUM_FREE_ROLE = 1 SITH_CLUB_ROLES = { 10: "Président⸱e", 9: "Vice-Président⸱e", @@ -28,10 +28,10 @@ def migrate_roles(apps: StateApps, schema_editor): for club_id, role in Membership.objects.values_list("club", "role").distinct(): new_role = ClubRole.objects.create( name=SITH_CLUB_ROLES[role], - is_board=role > settings.SITH_MAXIMUM_FREE_ROLE, - is_presidency=role == PRESIDENT_ROLE, + is_board=role > MAXIMUM_FREE_ROLE, + is_presidency=role in PRESIDENCY_ROLES, club_id=club_id, - order=PRESIDENT_ROLE - role, + order=max(SITH_CLUB_ROLES) - role, ) updates.append(When(role=role, then=new_role.id)) # all updates must happen at the same time diff --git a/sith/settings.py b/sith/settings.py index 6f7c02fc..f3ed911f 100644 --- a/sith/settings.py +++ b/sith/settings.py @@ -574,11 +574,6 @@ SITH_SUBSCRIPTIONS = { # To be completed.... } -# This corresponds to the maximum role a user can freely subscribe to -# In this case, SITH_MAXIMUM_FREE_ROLE=1 means that a user can -# set himself as "Membre actif" or "Curieux", but not higher -SITH_MAXIMUM_FREE_ROLE = 1 - # Minutes to timeout the logged barmen SITH_BARMAN_TIMEOUT = 30