diff --git a/core/management/commands/populate.py b/core/management/commands/populate.py index 8f101d9f..e48cb491 100644 --- a/core/management/commands/populate.py +++ b/core/management/commands/populate.py @@ -784,13 +784,13 @@ class Command(BaseCommand): # public has no permission. # Its purpose is not to link users to permissions, # but to other objects (like products) - public_group = Group.objects.create(name="Public") + public_group = Group.objects.create(name="Publique") - subscribers = Group.objects.create(name="Subscribers") + subscribers = Group.objects.create(name="Cotisants") subscribers.permissions.add( *list(perms.filter(codename__in=["add_news", "add_uvcomment"])) ) - old_subscribers = Group.objects.create(name="Old subscribers") + old_subscribers = Group.objects.create(name="Anciens cotisants") old_subscribers.permissions.add( *list( perms.filter( @@ -812,7 +812,7 @@ class Command(BaseCommand): ) ) accounting_admin = Group.objects.create( - name="Accounting admin", is_manually_manageable=True + name="Admin comptabilité", is_manually_manageable=True ) accounting_admin.permissions.add( *list( @@ -833,7 +833,7 @@ class Command(BaseCommand): ) ) com_admin = Group.objects.create( - name="Communication admin", is_manually_manageable=True + name="Admin communication", is_manually_manageable=True ) com_admin.permissions.add( *list( @@ -841,7 +841,7 @@ class Command(BaseCommand): ) ) counter_admin = Group.objects.create( - name="Counter admin", is_manually_manageable=True + name="Admin comptoirs", is_manually_manageable=True ) counter_admin.permissions.add( *list( @@ -851,14 +851,14 @@ class Command(BaseCommand): ) ) ) - sas_admin = Group.objects.create(name="SAS admin", is_manually_manageable=True) + sas_admin = Group.objects.create(name="Admin SAS", is_manually_manageable=True) sas_admin.permissions.add( *list( perms.filter(content_type__app_label="sas").values_list("pk", flat=True) ) ) forum_admin = Group.objects.create( - name="Forum admin", is_manually_manageable=True + name="Admin forum", is_manually_manageable=True ) forum_admin.permissions.add( *list( @@ -868,7 +868,7 @@ class Command(BaseCommand): ) ) pedagogy_admin = Group.objects.create( - name="Pedagogy admin", is_manually_manageable=True + name="Admin pédagogie", is_manually_manageable=True ) pedagogy_admin.permissions.add( *list( diff --git a/core/management/commands/populate_more.py b/core/management/commands/populate_more.py index 447b6b98..f9456712 100644 --- a/core/management/commands/populate_more.py +++ b/core/management/commands/populate_more.py @@ -238,7 +238,13 @@ class Command(BaseCommand): ae = Club.objects.get(id=settings.SITH_MAIN_CLUB_ID) other_clubs = random.sample(list(Club.objects.all()), k=3) groups = list( - Group.objects.filter(name__in=["Subscribers", "Old subscribers", "Public"]) + Group.objects.filter( + id__in=[ + settings.SITH_GROUP_SUBSCRIBERS_ID, + settings.SITH_GROUP_OLD_SUBSCRIBERS_ID, + settings.SITH_GROUP_PUBLIC_ID, + ] + ) ) counters = list( Counter.objects.filter(name__in=["Foyer", "MDE", "La Gommette", "Eboutic"]) diff --git a/core/tests/test_core.py b/core/tests/test_core.py index 72cde11c..a3af6052 100644 --- a/core/tests/test_core.py +++ b/core/tests/test_core.py @@ -361,17 +361,9 @@ class TestUserIsInGroup(TestCase): @classmethod def setUpTestData(cls): - cls.root_group = Group.objects.get(name="Root") - cls.public_group = Group.objects.get(name="Public") + cls.public_group = Group.objects.get(id=settings.SITH_GROUP_PUBLIC_ID) cls.public_user = baker.make(User) - cls.subscribers = Group.objects.get(name="Subscribers") - cls.old_subscribers = Group.objects.get(name="Old subscribers") - cls.accounting_admin = Group.objects.get(name="Accounting admin") - cls.com_admin = Group.objects.get(name="Communication admin") - cls.counter_admin = Group.objects.get(name="Counter admin") - cls.sas_admin = Group.objects.get(name="SAS admin") cls.club = baker.make(Club) - cls.main_club = Club.objects.get(id=1) def assert_in_public_group(self, user): assert user.is_in_group(pk=self.public_group.id) @@ -379,15 +371,7 @@ class TestUserIsInGroup(TestCase): def assert_only_in_public_group(self, user): self.assert_in_public_group(user) - for group in ( - self.root_group, - self.accounting_admin, - self.sas_admin, - self.subscribers, - self.old_subscribers, - self.club.members_group, - self.club.board_group, - ): + for group in Group.objects.exclude(id=self.public_group.id): assert not user.is_in_group(pk=group.pk) assert not user.is_in_group(name=group.name) diff --git a/rootplace/tests/test_merge_users.py b/rootplace/tests/test_merge_users.py index baaa8ca9..294e2bae 100644 --- a/rootplace/tests/test_merge_users.py +++ b/rootplace/tests/test_merge_users.py @@ -53,9 +53,9 @@ class TestMergeUser(TestCase): self.to_keep.address = "Jerusalem" self.to_delete.parent_address = "Rome" self.to_delete.address = "Rome" - subscribers = Group.objects.get(name="Subscribers") + subscribers = Group.objects.get(id=settings.SITH_GROUP_SUBSCRIBERS_ID) mde_admin = Group.objects.get(name="MDE admin") - sas_admin = Group.objects.get(name="SAS admin") + sas_admin = Group.objects.get(id=settings.SITH_GROUP_SAS_ADMIN_ID) self.to_keep.groups.add(subscribers.id) self.to_delete.groups.add(mde_admin.id) self.to_keep.groups.add(sas_admin.id)