mirror of https://github.com/zulip/zulip.git
user_groups: Allow not passing old_setting_api_value.
This commit is contained in:
parent
b1198785be
commit
3f800002be
|
@ -440,13 +440,19 @@ def do_change_user_group_permission_setting(
|
|||
setting_name: str,
|
||||
setting_value_group: UserGroup,
|
||||
*,
|
||||
old_setting_api_value: int | AnonymousSettingGroupDict,
|
||||
old_setting_api_value: int | AnonymousSettingGroupDict | None = None,
|
||||
acting_user: UserProfile | None,
|
||||
) -> None:
|
||||
old_value = getattr(user_group, setting_name)
|
||||
setattr(user_group, setting_name, setting_value_group)
|
||||
user_group.save()
|
||||
|
||||
if old_setting_api_value is None:
|
||||
# Most production callers will have computed this as part of
|
||||
# verifying whether there's an actual change to make, but it
|
||||
# feels quite clumsy to have to pass it from unit tests, so we
|
||||
# compute it here if not provided by the caller.
|
||||
old_setting_api_value = get_group_setting_value_for_api(old_value)
|
||||
new_setting_api_value = get_group_setting_value_for_api(setting_value_group)
|
||||
|
||||
if not hasattr(old_value, "named_user_group") and hasattr(
|
||||
|
|
Loading…
Reference in New Issue