fix galaxy tests

This commit is contained in:
imperosol 2024-11-30 23:03:49 +01:00
parent a051e3cecc
commit b3f8b2cce0
2 changed files with 19 additions and 3 deletions

View File

@ -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

View File

@ -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)
]
)