mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
user_groups: Make system groups creation atomic.
We want to make sure that the system groups, once created, will always have the GroupGroupMemberships fully set up. Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
committed by
Alex Vandiver
parent
e9f0ef4c15
commit
a9a30ad5b4
@@ -1,5 +1,6 @@
|
|||||||
from typing import Dict, Iterable, List, Sequence, TypedDict
|
from typing import Dict, Iterable, List, Sequence, TypedDict
|
||||||
|
|
||||||
|
from django.db import transaction
|
||||||
from django.db.models import F, QuerySet
|
from django.db.models import F, QuerySet
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
from django_cte import With
|
from django_cte import With
|
||||||
@@ -215,6 +216,7 @@ def get_subgroup_ids(user_group: UserGroup, *, direct_subgroup_only: bool = Fals
|
|||||||
return list(subgroup_ids)
|
return list(subgroup_ids)
|
||||||
|
|
||||||
|
|
||||||
|
@transaction.atomic(savepoint=False)
|
||||||
def create_system_user_groups_for_realm(realm: Realm) -> Dict[int, UserGroup]:
|
def create_system_user_groups_for_realm(realm: Realm) -> Dict[int, UserGroup]:
|
||||||
"""Any changes to this function likely require a migration to adjust
|
"""Any changes to this function likely require a migration to adjust
|
||||||
existing realms. See e.g. migration 0382_create_role_based_system_groups.py,
|
existing realms. See e.g. migration 0382_create_role_based_system_groups.py,
|
||||||
|
|||||||
Reference in New Issue
Block a user