mirror of https://github.com/zulip/zulip.git
user_groups: Make acting user requried for deletion.
When doing a checked deletion, the acting user is always required. It is effectively the user_profile parameter we had been previously requiring.
This commit is contained in:
parent
8792cfbadf
commit
006b2acd5d
|
@ -402,12 +402,10 @@ def do_send_delete_user_group_event(realm: Realm, user_group_id: int, realm_id:
|
||||||
send_event(realm, event, active_user_ids(realm_id))
|
send_event(realm, event, active_user_ids(realm_id))
|
||||||
|
|
||||||
|
|
||||||
def check_delete_user_group(
|
def check_delete_user_group(user_group_id: int, *, acting_user: UserProfile) -> None:
|
||||||
user_group_id: int, user_profile: UserProfile, *, acting_user: Optional[UserProfile]
|
user_group = access_user_group_by_id(user_group_id, acting_user, for_read=False)
|
||||||
) -> None:
|
|
||||||
user_group = access_user_group_by_id(user_group_id, user_profile, for_read=False)
|
|
||||||
user_group.delete()
|
user_group.delete()
|
||||||
do_send_delete_user_group_event(user_profile.realm, user_group_id, user_profile.realm.id)
|
do_send_delete_user_group_event(acting_user.realm, user_group_id, acting_user.realm.id)
|
||||||
|
|
||||||
|
|
||||||
@transaction.atomic(savepoint=False)
|
@transaction.atomic(savepoint=False)
|
||||||
|
|
|
@ -1464,7 +1464,7 @@ class NormalActionsTest(BaseAction):
|
||||||
|
|
||||||
# Test remove event
|
# Test remove event
|
||||||
events = self.verify_action(
|
events = self.verify_action(
|
||||||
lambda: check_delete_user_group(backend.id, othello, acting_user=None)
|
lambda: check_delete_user_group(backend.id, acting_user=othello)
|
||||||
)
|
)
|
||||||
check_user_group_remove("events[0]", events[0])
|
check_user_group_remove("events[0]", events[0])
|
||||||
|
|
||||||
|
|
|
@ -153,7 +153,7 @@ def delete_user_group(
|
||||||
user_profile: UserProfile,
|
user_profile: UserProfile,
|
||||||
user_group_id: int = REQ(json_validator=check_int, path_only=True),
|
user_group_id: int = REQ(json_validator=check_int, path_only=True),
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
check_delete_user_group(user_group_id, user_profile, acting_user=user_profile)
|
check_delete_user_group(user_group_id, acting_user=user_profile)
|
||||||
return json_success(request)
|
return json_success(request)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue