mirror of https://github.com/zulip/zulip.git
user_groups: Track acting user for remove_subgroups_from_user_group.
This is a prep-commit for populating RealmAuditLogs for changes made to UserGroup. Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
parent
32f8e0324d
commit
e78dfc2868
|
@ -215,7 +215,9 @@ def add_subgroups_to_user_group(
|
|||
|
||||
|
||||
@transaction.atomic
|
||||
def remove_subgroups_from_user_group(user_group: UserGroup, subgroups: List[UserGroup]) -> None:
|
||||
def remove_subgroups_from_user_group(
|
||||
user_group: UserGroup, subgroups: List[UserGroup], *, acting_user: Optional[UserProfile]
|
||||
) -> None:
|
||||
GroupGroupMembership.objects.filter(supergroup=user_group, subgroup__in=subgroups).delete()
|
||||
|
||||
subgroup_ids = [subgroup.id for subgroup in subgroups]
|
||||
|
|
|
@ -1324,7 +1324,9 @@ class NormalActionsTest(BaseAction):
|
|||
check_user_group_add_subgroups("events[0]", events[0])
|
||||
|
||||
# Test remove subgroups
|
||||
events = self.verify_action(lambda: remove_subgroups_from_user_group(backend, [api_design]))
|
||||
events = self.verify_action(
|
||||
lambda: remove_subgroups_from_user_group(backend, [api_design], acting_user=None)
|
||||
)
|
||||
check_user_group_remove_subgroups("events[0]", events[0])
|
||||
|
||||
# Test remove event
|
||||
|
|
|
@ -195,7 +195,7 @@ def remove_subgroups_from_group_backend(
|
|||
)
|
||||
)
|
||||
|
||||
remove_subgroups_from_user_group(user_group, subgroups)
|
||||
remove_subgroups_from_user_group(user_group, subgroups, acting_user=user_profile)
|
||||
return json_success(request)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue