From b3f8b2cce01042c671810a92a8d6dac0126d1dc7 Mon Sep 17 00:00:00 2001 From: imperosol Date: Sat, 30 Nov 2024 23:03:49 +0100 Subject: [PATCH] fix galaxy tests --- docs/tutorial/groups.md | 8 ++++++++ .../commands/generate_galaxy_test_data.py | 14 +++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/docs/tutorial/groups.md b/docs/tutorial/groups.md index 1b3677a5..fbb58aab 100644 --- a/docs/tutorial/groups.md +++ b/docs/tutorial/groups.md @@ -128,6 +128,14 @@ Par exemple : INNER JOIN "auth_group" ON ("core_group"."group_ptr_id" = "auth_group"."id") ``` +!!!warning + + Django réussit à abstraire assez bien la logique relationnelle. + Cependant, gardez bien en mémoire que ce n'est pas quelque chose + de magique et que cette manière de faire a des limitations. + Par exemple, il devient impossible de `bulk_create` + des groupes. + ## La définition d'un groupe diff --git a/galaxy/management/commands/generate_galaxy_test_data.py b/galaxy/management/commands/generate_galaxy_test_data.py index 2c3ab7c8..d0dea4a5 100644 --- a/galaxy/management/commands/generate_galaxy_test_data.py +++ b/galaxy/management/commands/generate_galaxy_test_data.py @@ -121,12 +121,20 @@ class Command(BaseCommand): """Create all the clubs [club.models.Club][]. After creation, the clubs are stored in `self.clubs` for fast access later. - Don't create the groups associated to the clubs - nor the pages of the clubs ([core.models.Page][]). + Don't create the pages of the clubs ([core.models.Page][]). """ + # dummy groups. + # the galaxy doesn't care about the club groups, + # but it's necessary to add them nonetheless in order + # not to break the integrity constraints self.clubs = Club.objects.bulk_create( [ - Club(unix_name=f"galaxy-club-{i}", name=f"club-{i}") + Club( + unix_name=f"galaxy-club-{i}", + name=f"club-{i}", + board_group=Group.objects.create(name=f"board {i}"), + members_group=Group.objects.create(name=f"members {i}"), + ) for i in range(self.NB_CLUBS) ] )