mirror of https://github.com/zulip/zulip.git
user_groups: Rename allow_deactivated in 'GET /user_groups'.
This commit renames "allow_deactivated" parameter in "GET /user_groups" endpoint to "include_deactivated_groups", so that we can have consistent naming here and for client capability used for deciding whether to send deactivated groups in register response and how to handle the related events.
This commit is contained in:
parent
fb63c47ea6
commit
5c790aac72
|
@ -36,6 +36,8 @@ format used by the Zulip server that they are interacting with.
|
|||
[client capability](/api/register-queue#parameter-client_capabilities)
|
||||
do not receive `update` event when name of a deactivated user group
|
||||
is updated.
|
||||
* [`GET /user_groups`](/api/get-user-groups): Renamed `allow_deactivated`
|
||||
parameter to `include_deactivated_groups`.
|
||||
|
||||
**Feature level 293**
|
||||
|
||||
|
|
|
@ -509,7 +509,7 @@ def fetch_initial_state_data(
|
|||
|
||||
if want("realm_user_groups"):
|
||||
state["realm_user_groups"] = user_groups_in_realm_serialized(
|
||||
realm, allow_deactivated=include_deactivated_groups
|
||||
realm, include_deactivated_groups=include_deactivated_groups
|
||||
)
|
||||
|
||||
if user_profile is not None:
|
||||
|
|
|
@ -480,7 +480,7 @@ def get_setting_value_for_user_group_object(
|
|||
|
||||
|
||||
def user_groups_in_realm_serialized(
|
||||
realm: Realm, *, allow_deactivated: bool
|
||||
realm: Realm, *, include_deactivated_groups: bool
|
||||
) -> list[UserGroupDict]:
|
||||
"""This function is used in do_events_register code path so this code
|
||||
should be performant. We need to do 2 database queries because
|
||||
|
@ -494,7 +494,7 @@ def user_groups_in_realm_serialized(
|
|||
"can_mention_group__named_user_group",
|
||||
).filter(realm=realm)
|
||||
|
||||
if not allow_deactivated:
|
||||
if not include_deactivated_groups:
|
||||
realm_groups = realm_groups.filter(deactivated=False)
|
||||
|
||||
membership = UserGroupMembership.objects.filter(user_group__realm=realm).values_list(
|
||||
|
|
|
@ -20043,13 +20043,16 @@ paths:
|
|||
schema:
|
||||
type: object
|
||||
properties:
|
||||
allow_deactivated:
|
||||
include_deactivated_groups:
|
||||
description: |
|
||||
Whether to include deactivated user groups in the response.
|
||||
|
||||
**Changes**: New in Zulip 10.0 (feature level 290). Previously,
|
||||
deactivated user groups did not exist and thus would never be
|
||||
included in the response.
|
||||
**Changes**: In Zulip 10.0 (feature level 294), renamed
|
||||
`allow_deactivated` to `include_deactivated_groups`.
|
||||
|
||||
New in Zulip 10.0 (feature level 290). Previously, deactivated
|
||||
user groups did not exist and thus would never be included in
|
||||
the response.
|
||||
type: boolean
|
||||
example: true
|
||||
default: false
|
||||
|
|
|
@ -89,7 +89,7 @@ class UserGroupTestCase(ZulipTestCase):
|
|||
assert user_group is not None
|
||||
empty_user_group = check_add_user_group(realm, "newgroup", [], acting_user=user)
|
||||
|
||||
user_groups = user_groups_in_realm_serialized(realm, allow_deactivated=False)
|
||||
user_groups = user_groups_in_realm_serialized(realm, include_deactivated_groups=False)
|
||||
self.assert_length(user_groups, 10)
|
||||
self.assertEqual(user_groups[0]["id"], user_group.id)
|
||||
self.assertEqual(user_groups[0]["creator_id"], user_group.creator_id)
|
||||
|
@ -161,7 +161,7 @@ class UserGroupTestCase(ZulipTestCase):
|
|||
},
|
||||
acting_user=None,
|
||||
)
|
||||
user_groups = user_groups_in_realm_serialized(realm, allow_deactivated=False)
|
||||
user_groups = user_groups_in_realm_serialized(realm, include_deactivated_groups=False)
|
||||
self.assertEqual(user_groups[10]["id"], new_user_group.id)
|
||||
self.assertEqual(user_groups[10]["creator_id"], new_user_group.creator_id)
|
||||
self.assertEqual(
|
||||
|
@ -194,7 +194,7 @@ class UserGroupTestCase(ZulipTestCase):
|
|||
new_user_group, [another_new_group, owners_system_group], acting_user=None
|
||||
)
|
||||
do_deactivate_user_group(another_new_group, acting_user=None)
|
||||
user_groups = user_groups_in_realm_serialized(realm, allow_deactivated=True)
|
||||
user_groups = user_groups_in_realm_serialized(realm, include_deactivated_groups=True)
|
||||
self.assert_length(user_groups, 12)
|
||||
self.assertEqual(user_groups[10]["id"], new_user_group.id)
|
||||
self.assertEqual(user_groups[10]["name"], "newgroup2")
|
||||
|
@ -206,7 +206,7 @@ class UserGroupTestCase(ZulipTestCase):
|
|||
self.assertEqual(user_groups[11]["name"], "newgroup3")
|
||||
self.assertTrue(user_groups[11]["deactivated"])
|
||||
|
||||
user_groups = user_groups_in_realm_serialized(realm, allow_deactivated=False)
|
||||
user_groups = user_groups_in_realm_serialized(realm, include_deactivated_groups=False)
|
||||
self.assert_length(user_groups, 11)
|
||||
self.assertEqual(user_groups[10]["id"], new_user_group.id)
|
||||
self.assertEqual(user_groups[10]["name"], "newgroup2")
|
||||
|
|
|
@ -98,10 +98,10 @@ def get_user_groups(
|
|||
request: HttpRequest,
|
||||
user_profile: UserProfile,
|
||||
*,
|
||||
allow_deactivated: Json[bool] = False,
|
||||
include_deactivated_groups: Json[bool] = False,
|
||||
) -> HttpResponse:
|
||||
user_groups = user_groups_in_realm_serialized(
|
||||
user_profile.realm, allow_deactivated=allow_deactivated
|
||||
user_profile.realm, include_deactivated_groups=include_deactivated_groups
|
||||
)
|
||||
return json_success(request, data={"user_groups": user_groups})
|
||||
|
||||
|
|
Loading…
Reference in New Issue