mirror of https://github.com/zulip/zulip.git
user_groups: Rename `can_mention_group_id` parameter.
Earlier the API endpoints related to user_group accepts and returns a field `can_mention_group_id` which represents the ID of user_group whose members can mention the group. This commit renames this field to `can_mention_group`.
This commit is contained in:
parent
c8bcb422f5
commit
fbcc3b5c84
|
@ -20,6 +20,14 @@ format used by the Zulip server that they are interacting with.
|
||||||
|
|
||||||
## Changes in Zulip 8.0
|
## Changes in Zulip 8.0
|
||||||
|
|
||||||
|
**Feature level 198**
|
||||||
|
|
||||||
|
* [`GET /events`](/api/get-events), [`POST /register`](/api/register-queue),
|
||||||
|
[`GET /user_groups`](/api/get-user-groups),
|
||||||
|
[`POST /user_groups/create`](/api/create-user-group),
|
||||||
|
[`PATCH /user_groups/{user_group_id}`](/api/update-user-group):Renamed
|
||||||
|
group setting `can_mention_group_id` to `can_mention_group`.
|
||||||
|
|
||||||
**Feature level 197**
|
**Feature level 197**
|
||||||
|
|
||||||
* [`POST /users/me/subscriptions`](/api/subscribe),
|
* [`POST /users/me/subscriptions`](/api/subscribe),
|
||||||
|
|
|
@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.9.3"
|
||||||
# Changes should be accompanied by documentation explaining what the
|
# Changes should be accompanied by documentation explaining what the
|
||||||
# new level means in api_docs/changelog.md, as well as "**Changes**"
|
# new level means in api_docs/changelog.md, as well as "**Changes**"
|
||||||
# entries in the endpoint's documentation in `zulip.yaml`.
|
# entries in the endpoint's documentation in `zulip.yaml`.
|
||||||
API_FEATURE_LEVEL = 197
|
API_FEATURE_LEVEL = 198
|
||||||
|
|
||||||
# Bump the minor PROVISION_VERSION to indicate that folks should provision
|
# Bump the minor PROVISION_VERSION to indicate that folks should provision
|
||||||
# only when going from an old version of the code to a newer version. Bump
|
# only when going from an old version of the code to a newer version. Bump
|
||||||
|
|
|
@ -12,7 +12,7 @@ export type UserGroup = {
|
||||||
members: Set<number>;
|
members: Set<number>;
|
||||||
is_system_group: boolean;
|
is_system_group: boolean;
|
||||||
direct_subgroup_ids: Set<number>;
|
direct_subgroup_ids: Set<number>;
|
||||||
can_mention_group_id: number;
|
can_mention_group: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
// The members field is a number array which we convert
|
// The members field is a number array which we convert
|
||||||
|
@ -46,7 +46,7 @@ export function add(user_group_raw: UserGroupRaw): void {
|
||||||
members: new Set(user_group_raw.members),
|
members: new Set(user_group_raw.members),
|
||||||
is_system_group: user_group_raw.is_system_group,
|
is_system_group: user_group_raw.is_system_group,
|
||||||
direct_subgroup_ids: new Set(user_group_raw.direct_subgroup_ids),
|
direct_subgroup_ids: new Set(user_group_raw.direct_subgroup_ids),
|
||||||
can_mention_group_id: user_group_raw.can_mention_group_id,
|
can_mention_group: user_group_raw.can_mention_group,
|
||||||
};
|
};
|
||||||
|
|
||||||
user_group_name_dict.set(user_group.name, user_group);
|
user_group_name_dict.set(user_group.name, user_group);
|
||||||
|
@ -96,7 +96,7 @@ export function get_user_groups_allowed_to_mention(): UserGroup[] {
|
||||||
|
|
||||||
const user_groups = get_realm_user_groups();
|
const user_groups = get_realm_user_groups();
|
||||||
return user_groups.filter((group) => {
|
return user_groups.filter((group) => {
|
||||||
const can_mention_group_id = group.can_mention_group_id;
|
const can_mention_group_id = group.can_mention_group;
|
||||||
return (
|
return (
|
||||||
page_params.user_id !== undefined &&
|
page_params.user_id !== undefined &&
|
||||||
is_user_in_group(can_mention_group_id, page_params.user_id)
|
is_user_in_group(can_mention_group_id, page_params.user_id)
|
||||||
|
|
|
@ -331,7 +331,7 @@ const hamletcharacters = {
|
||||||
members: new Set([100, 104]),
|
members: new Set([100, 104]),
|
||||||
is_system_group: false,
|
is_system_group: false,
|
||||||
direct_subgroup_ids: new Set([]),
|
direct_subgroup_ids: new Set([]),
|
||||||
can_mention_group_id: 2,
|
can_mention_group: 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
const backend = {
|
const backend = {
|
||||||
|
@ -341,7 +341,7 @@ const backend = {
|
||||||
members: new Set([101]),
|
members: new Set([101]),
|
||||||
is_system_group: false,
|
is_system_group: false,
|
||||||
direct_subgroup_ids: new Set([1]),
|
direct_subgroup_ids: new Set([1]),
|
||||||
can_mention_group_id: 1,
|
can_mention_group: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
const call_center = {
|
const call_center = {
|
||||||
|
@ -351,7 +351,7 @@ const call_center = {
|
||||||
members: new Set([102]),
|
members: new Set([102]),
|
||||||
is_system_group: false,
|
is_system_group: false,
|
||||||
direct_subgroup_ids: new Set([]),
|
direct_subgroup_ids: new Set([]),
|
||||||
can_mention_group_id: 2,
|
can_mention_group: 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
const make_emoji = (emoji_dict) => ({
|
const make_emoji = (emoji_dict) => ({
|
||||||
|
|
|
@ -795,7 +795,7 @@ exports.fixtures = {
|
||||||
members: [1],
|
members: [1],
|
||||||
is_system_group: false,
|
is_system_group: false,
|
||||||
direct_subgroup_ids: [2],
|
direct_subgroup_ids: [2],
|
||||||
can_mention_group_id: 11,
|
can_mention_group: 11,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ run_test("user_groups", () => {
|
||||||
members: new Set([1, 2]),
|
members: new Set([1, 2]),
|
||||||
is_system_group: false,
|
is_system_group: false,
|
||||||
direct_subgroup_ids: new Set([4, 5]),
|
direct_subgroup_ids: new Set([4, 5]),
|
||||||
can_mention_group_id: 2,
|
can_mention_group: 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
const params = {};
|
const params = {};
|
||||||
|
@ -34,7 +34,7 @@ run_test("user_groups", () => {
|
||||||
members: new Set([3]),
|
members: new Set([3]),
|
||||||
is_system_group: false,
|
is_system_group: false,
|
||||||
direct_subgroup_ids: new Set([]),
|
direct_subgroup_ids: new Set([]),
|
||||||
can_mention_group_id: 2,
|
can_mention_group: 2,
|
||||||
};
|
};
|
||||||
const all = {
|
const all = {
|
||||||
name: "Everyone",
|
name: "Everyone",
|
||||||
|
@ -42,7 +42,7 @@ run_test("user_groups", () => {
|
||||||
members: new Set([1, 2, 3]),
|
members: new Set([1, 2, 3]),
|
||||||
is_system_group: false,
|
is_system_group: false,
|
||||||
direct_subgroup_ids: new Set([4, 5, 6]),
|
direct_subgroup_ids: new Set([4, 5, 6]),
|
||||||
can_mention_group_id: 1,
|
can_mention_group: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
user_groups.add(admins);
|
user_groups.add(admins);
|
||||||
|
|
|
@ -183,7 +183,7 @@ def do_send_create_user_group_event(
|
||||||
id=user_group.id,
|
id=user_group.id,
|
||||||
is_system_group=user_group.is_system_group,
|
is_system_group=user_group.is_system_group,
|
||||||
direct_subgroup_ids=[direct_subgroup.id for direct_subgroup in direct_subgroups],
|
direct_subgroup_ids=[direct_subgroup.id for direct_subgroup in direct_subgroups],
|
||||||
can_mention_group_id=user_group.can_mention_group_id,
|
can_mention_group=user_group.can_mention_group_id,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
send_event(user_group.realm, event, active_user_ids(user_group.realm_id))
|
send_event(user_group.realm, event, active_user_ids(user_group.realm_id))
|
||||||
|
@ -443,6 +443,5 @@ def do_change_user_group_permission_setting(
|
||||||
).decode(),
|
).decode(),
|
||||||
)
|
)
|
||||||
|
|
||||||
setting_id_name = setting_name + "_id"
|
event_data_dict: Dict[str, Union[str, int]] = {setting_name: setting_value_group.id}
|
||||||
event_data_dict: Dict[str, Union[str, int]] = {setting_id_name: setting_value_group.id}
|
|
||||||
do_send_user_group_update_event(user_group, event_data_dict)
|
do_send_user_group_update_event(user_group, event_data_dict)
|
||||||
|
|
|
@ -1689,7 +1689,7 @@ group_type = DictType(
|
||||||
("direct_subgroup_ids", ListType(int)),
|
("direct_subgroup_ids", ListType(int)),
|
||||||
("description", str),
|
("description", str),
|
||||||
("is_system_group", bool),
|
("is_system_group", bool),
|
||||||
("can_mention_group_id", int),
|
("can_mention_group", int),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1737,7 +1737,7 @@ user_group_data_type = DictType(
|
||||||
# force vertical
|
# force vertical
|
||||||
("name", str),
|
("name", str),
|
||||||
("description", str),
|
("description", str),
|
||||||
("can_mention_group_id", int),
|
("can_mention_group", int),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ class UserGroupDict(TypedDict):
|
||||||
members: List[int]
|
members: List[int]
|
||||||
direct_subgroup_ids: List[int]
|
direct_subgroup_ids: List[int]
|
||||||
is_system_group: bool
|
is_system_group: bool
|
||||||
can_mention_group_id: int
|
can_mention_group: int
|
||||||
|
|
||||||
|
|
||||||
def access_user_group_by_id(
|
def access_user_group_by_id(
|
||||||
|
@ -144,7 +144,7 @@ def user_groups_in_realm_serialized(realm: Realm) -> List[UserGroupDict]:
|
||||||
members=[],
|
members=[],
|
||||||
direct_subgroup_ids=[],
|
direct_subgroup_ids=[],
|
||||||
is_system_group=user_group.is_system_group,
|
is_system_group=user_group.is_system_group,
|
||||||
can_mention_group_id=user_group.can_mention_group_id,
|
can_mention_group=user_group.can_mention_group_id,
|
||||||
)
|
)
|
||||||
|
|
||||||
membership = UserGroupMembership.objects.filter(user_group__realm=realm).values_list(
|
membership = UserGroupMembership.objects.filter(user_group__realm=realm).values_list(
|
||||||
|
|
|
@ -2915,7 +2915,7 @@ paths:
|
||||||
"description": "Backend team",
|
"description": "Backend team",
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"is_system_group": false,
|
"is_system_group": false,
|
||||||
"can_mention_group_id": 11,
|
"can_mention_group": 11,
|
||||||
},
|
},
|
||||||
"id": 0,
|
"id": 0,
|
||||||
}
|
}
|
||||||
|
@ -2955,13 +2955,17 @@ paths:
|
||||||
description: |
|
description: |
|
||||||
The new description of the group. Only present if the description
|
The new description of the group. Only present if the description
|
||||||
changed.
|
changed.
|
||||||
can_mention_group_id:
|
can_mention_group:
|
||||||
type: integer
|
type: integer
|
||||||
description: |
|
description: |
|
||||||
ID of the new user group whose members are allowed to mention the
|
ID of the new user group whose members are allowed to mention the
|
||||||
group.
|
group.
|
||||||
|
|
||||||
**Changes**: New in Zulip 8.0 (feature level 191). Previously, groups
|
**Changes**: Before Zulip 8.0 (feature level 198),
|
||||||
|
the `can_mention_group` setting
|
||||||
|
was named `can_mention_group_id`.
|
||||||
|
|
||||||
|
New in Zulip 8.0 (feature level 191). Previously, groups
|
||||||
could be mentioned if and only if they were not system groups.
|
could be mentioned if and only if they were not system groups.
|
||||||
example:
|
example:
|
||||||
{
|
{
|
||||||
|
@ -16230,7 +16234,7 @@ paths:
|
||||||
type: integer
|
type: integer
|
||||||
example: [1, 2, 3, 4]
|
example: [1, 2, 3, 4]
|
||||||
required: true
|
required: true
|
||||||
- name: can_mention_group_id
|
- name: can_mention_group
|
||||||
in: query
|
in: query
|
||||||
description: |
|
description: |
|
||||||
ID of the user group whose members are allowed to mention the new
|
ID of the user group whose members are allowed to mention the new
|
||||||
|
@ -16239,7 +16243,10 @@ paths:
|
||||||
This setting cannot be set to `"role:internet"` and `"role:owners"`
|
This setting cannot be set to `"role:internet"` and `"role:owners"`
|
||||||
system groups.
|
system groups.
|
||||||
|
|
||||||
**Changes**: New in Zulip 8.0 (feature level 191). Previously, groups
|
**Changes**: Before Zulip 8.0 (feature level 198),
|
||||||
|
the `can_mention_group` setting was named `can_mention_group_id`.
|
||||||
|
|
||||||
|
New in Zulip 8.0 (feature level 191). Previously, groups
|
||||||
could be mentioned if and only if they were not system groups.
|
could be mentioned if and only if they were not system groups.
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
|
@ -16367,7 +16374,7 @@ paths:
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
example: The marketing team.
|
example: The marketing team.
|
||||||
- name: can_mention_group_id
|
- name: can_mention_group
|
||||||
in: query
|
in: query
|
||||||
description: |
|
description: |
|
||||||
ID of the new user group whose members are allowed to mention the
|
ID of the new user group whose members are allowed to mention the
|
||||||
|
@ -16376,7 +16383,10 @@ paths:
|
||||||
This setting cannot be set to `"role:internet"` and `"role:owners"`
|
This setting cannot be set to `"role:internet"` and `"role:owners"`
|
||||||
system groups.
|
system groups.
|
||||||
|
|
||||||
**Changes**: New in Zulip 8.0 (feature level 191). Previously, groups
|
**Changes**: Before Zulip 8.0 (feature level 198),
|
||||||
|
the `can_mention_group` setting was named `can_mention_group_id`.
|
||||||
|
|
||||||
|
New in Zulip 8.0 (feature level 191). Previously, groups
|
||||||
could be mentioned if and only if they were not system groups.
|
could be mentioned if and only if they were not system groups.
|
||||||
schema:
|
schema:
|
||||||
type: integer
|
type: integer
|
||||||
|
@ -16498,12 +16508,15 @@ paths:
|
||||||
modified by users.
|
modified by users.
|
||||||
|
|
||||||
**Changes**: New in Zulip 5.0 (feature level 93).
|
**Changes**: New in Zulip 5.0 (feature level 93).
|
||||||
can_mention_group_id:
|
can_mention_group:
|
||||||
type: integer
|
type: integer
|
||||||
description: |
|
description: |
|
||||||
ID of the user group whose members are allowed to mention the group.
|
ID of the user group whose members are allowed to mention the group.
|
||||||
|
|
||||||
**Changes**: New in Zulip 8.0 (feature level 191). Previously, groups
|
**Changes**: Before Zulip 8.0 (feature level 198),
|
||||||
|
the `can_mention_group` setting was named `can_mention_group_id`.
|
||||||
|
|
||||||
|
New in Zulip 8.0 (feature level 191). Previously, groups
|
||||||
could be mentioned if and only if they were not system groups.
|
could be mentioned if and only if they were not system groups.
|
||||||
description: |
|
description: |
|
||||||
A list of `user_group` objects.
|
A list of `user_group` objects.
|
||||||
|
@ -16520,7 +16533,7 @@ paths:
|
||||||
"members": [1],
|
"members": [1],
|
||||||
"direct_subgroup_ids": [],
|
"direct_subgroup_ids": [],
|
||||||
"is_system_group": true,
|
"is_system_group": true,
|
||||||
"can_mention_group_id": 11,
|
"can_mention_group": 11,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Administrators of this organization, including owners",
|
"description": "Administrators of this organization, including owners",
|
||||||
|
@ -16529,7 +16542,7 @@ paths:
|
||||||
"members": [2],
|
"members": [2],
|
||||||
"direct_subgroup_ids": [1],
|
"direct_subgroup_ids": [1],
|
||||||
"is_system_group": true,
|
"is_system_group": true,
|
||||||
"can_mention_group_id": 12,
|
"can_mention_group": 12,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"description": "Characters of Hamlet",
|
"description": "Characters of Hamlet",
|
||||||
|
@ -16538,7 +16551,7 @@ paths:
|
||||||
"members": [3, 4],
|
"members": [3, 4],
|
||||||
"direct_subgroup_ids": [],
|
"direct_subgroup_ids": [],
|
||||||
"is_system_group": false,
|
"is_system_group": false,
|
||||||
"can_mention_group_id": 13,
|
"can_mention_group": 13,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
@ -17517,12 +17530,15 @@ components:
|
||||||
directly modified by users.
|
directly modified by users.
|
||||||
|
|
||||||
**Changes**: New in Zulip 5.0 (feature level 93).
|
**Changes**: New in Zulip 5.0 (feature level 93).
|
||||||
can_mention_group_id:
|
can_mention_group:
|
||||||
type: integer
|
type: integer
|
||||||
description: |
|
description: |
|
||||||
ID of the user group whose members are allowed to mention the group.
|
ID of the user group whose members are allowed to mention the group.
|
||||||
|
|
||||||
**Changes**: New in Zulip 8.0 (feature level 191). Previously, groups
|
**Changes**: Before Zulip 8.0 (feature level 198),
|
||||||
|
the `can_mention_group` setting was named `can_mention_group_id`.
|
||||||
|
|
||||||
|
New in Zulip 8.0 (feature level 191). Previously, groups
|
||||||
could be mentioned if and only if they were not system groups.
|
could be mentioned if and only if they were not system groups.
|
||||||
Subscriptions:
|
Subscriptions:
|
||||||
type: object
|
type: object
|
||||||
|
|
|
@ -1414,7 +1414,7 @@ class NormalActionsTest(BaseAction):
|
||||||
backend, "can_mention_group", moderators_group, acting_user=None
|
backend, "can_mention_group", moderators_group, acting_user=None
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
check_user_group_update("events[0]", events[0], "can_mention_group_id")
|
check_user_group_update("events[0]", events[0], "can_mention_group")
|
||||||
|
|
||||||
# Test add members
|
# Test add members
|
||||||
hamlet = self.example_user("hamlet")
|
hamlet = self.example_user("hamlet")
|
||||||
|
|
|
@ -320,7 +320,7 @@ class UserGroupAPITestCase(UserGroupTestCase):
|
||||||
"name": "support",
|
"name": "support",
|
||||||
"members": orjson.dumps([hamlet.id]).decode(),
|
"members": orjson.dumps([hamlet.id]).decode(),
|
||||||
"description": "Support team",
|
"description": "Support team",
|
||||||
"can_mention_group_id": orjson.dumps(moderators_group.id).decode(),
|
"can_mention_group": orjson.dumps(moderators_group.id).decode(),
|
||||||
}
|
}
|
||||||
result = self.client_post("/json/user_groups/create", info=params)
|
result = self.client_post("/json/user_groups/create", info=params)
|
||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
|
@ -331,7 +331,7 @@ class UserGroupAPITestCase(UserGroupTestCase):
|
||||||
"name": "test",
|
"name": "test",
|
||||||
"members": orjson.dumps([hamlet.id]).decode(),
|
"members": orjson.dumps([hamlet.id]).decode(),
|
||||||
"description": "Test group",
|
"description": "Test group",
|
||||||
"can_mention_group_id": orjson.dumps(leadership_group.id).decode(),
|
"can_mention_group": orjson.dumps(leadership_group.id).decode(),
|
||||||
}
|
}
|
||||||
result = self.client_post("/json/user_groups/create", info=params)
|
result = self.client_post("/json/user_groups/create", info=params)
|
||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
|
@ -345,7 +345,7 @@ class UserGroupAPITestCase(UserGroupTestCase):
|
||||||
"name": "marketing",
|
"name": "marketing",
|
||||||
"members": orjson.dumps([hamlet.id]).decode(),
|
"members": orjson.dumps([hamlet.id]).decode(),
|
||||||
"description": "Marketing team",
|
"description": "Marketing team",
|
||||||
"can_mention_group_id": orjson.dumps(nobody_group.id).decode(),
|
"can_mention_group": orjson.dumps(nobody_group.id).decode(),
|
||||||
}
|
}
|
||||||
result = self.client_post("/json/user_groups/create", info=params)
|
result = self.client_post("/json/user_groups/create", info=params)
|
||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
|
@ -359,7 +359,7 @@ class UserGroupAPITestCase(UserGroupTestCase):
|
||||||
"name": "frontend",
|
"name": "frontend",
|
||||||
"members": orjson.dumps([hamlet.id]).decode(),
|
"members": orjson.dumps([hamlet.id]).decode(),
|
||||||
"description": "Frontend team",
|
"description": "Frontend team",
|
||||||
"can_mention_group_id": orjson.dumps(internet_group.id).decode(),
|
"can_mention_group": orjson.dumps(internet_group.id).decode(),
|
||||||
}
|
}
|
||||||
result = self.client_post("/json/user_groups/create", info=params)
|
result = self.client_post("/json/user_groups/create", info=params)
|
||||||
self.assert_json_error(
|
self.assert_json_error(
|
||||||
|
@ -373,7 +373,7 @@ class UserGroupAPITestCase(UserGroupTestCase):
|
||||||
"name": "frontend",
|
"name": "frontend",
|
||||||
"members": orjson.dumps([hamlet.id]).decode(),
|
"members": orjson.dumps([hamlet.id]).decode(),
|
||||||
"description": "Frontend team",
|
"description": "Frontend team",
|
||||||
"can_mention_group_id": orjson.dumps(owners_group.id).decode(),
|
"can_mention_group": orjson.dumps(owners_group.id).decode(),
|
||||||
}
|
}
|
||||||
result = self.client_post("/json/user_groups/create", info=params)
|
result = self.client_post("/json/user_groups/create", info=params)
|
||||||
self.assert_json_error(
|
self.assert_json_error(
|
||||||
|
@ -384,7 +384,7 @@ class UserGroupAPITestCase(UserGroupTestCase):
|
||||||
"name": "frontend",
|
"name": "frontend",
|
||||||
"members": orjson.dumps([hamlet.id]).decode(),
|
"members": orjson.dumps([hamlet.id]).decode(),
|
||||||
"description": "Frontend team",
|
"description": "Frontend team",
|
||||||
"can_mention_group_id": orjson.dumps(1111).decode(),
|
"can_mention_group": orjson.dumps(1111).decode(),
|
||||||
}
|
}
|
||||||
result = self.client_post("/json/user_groups/create", info=params)
|
result = self.client_post("/json/user_groups/create", info=params)
|
||||||
self.assert_json_error(result, "Invalid user group")
|
self.assert_json_error(result, "Invalid user group")
|
||||||
|
@ -489,7 +489,7 @@ class UserGroupAPITestCase(UserGroupTestCase):
|
||||||
|
|
||||||
self.login("hamlet")
|
self.login("hamlet")
|
||||||
params = {
|
params = {
|
||||||
"can_mention_group_id": orjson.dumps(moderators_group.id).decode(),
|
"can_mention_group": orjson.dumps(moderators_group.id).decode(),
|
||||||
}
|
}
|
||||||
result = self.client_patch(f"/json/user_groups/{support_group.id}", info=params)
|
result = self.client_patch(f"/json/user_groups/{support_group.id}", info=params)
|
||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
|
@ -497,7 +497,7 @@ class UserGroupAPITestCase(UserGroupTestCase):
|
||||||
self.assertEqual(support_group.can_mention_group, moderators_group)
|
self.assertEqual(support_group.can_mention_group, moderators_group)
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
"can_mention_group_id": orjson.dumps(marketing_group.id).decode(),
|
"can_mention_group": orjson.dumps(marketing_group.id).decode(),
|
||||||
}
|
}
|
||||||
result = self.client_patch(f"/json/user_groups/{support_group.id}", info=params)
|
result = self.client_patch(f"/json/user_groups/{support_group.id}", info=params)
|
||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
|
@ -508,7 +508,7 @@ class UserGroupAPITestCase(UserGroupTestCase):
|
||||||
name="role:nobody", realm=hamlet.realm, is_system_group=True
|
name="role:nobody", realm=hamlet.realm, is_system_group=True
|
||||||
)
|
)
|
||||||
params = {
|
params = {
|
||||||
"can_mention_group_id": orjson.dumps(nobody_group.id).decode(),
|
"can_mention_group": orjson.dumps(nobody_group.id).decode(),
|
||||||
}
|
}
|
||||||
result = self.client_patch(f"/json/user_groups/{support_group.id}", info=params)
|
result = self.client_patch(f"/json/user_groups/{support_group.id}", info=params)
|
||||||
self.assert_json_success(result)
|
self.assert_json_success(result)
|
||||||
|
@ -519,7 +519,7 @@ class UserGroupAPITestCase(UserGroupTestCase):
|
||||||
name="role:owners", realm=hamlet.realm, is_system_group=True
|
name="role:owners", realm=hamlet.realm, is_system_group=True
|
||||||
)
|
)
|
||||||
params = {
|
params = {
|
||||||
"can_mention_group_id": orjson.dumps(owners_group.id).decode(),
|
"can_mention_group": orjson.dumps(owners_group.id).decode(),
|
||||||
}
|
}
|
||||||
result = self.client_patch(f"/json/user_groups/{support_group.id}", info=params)
|
result = self.client_patch(f"/json/user_groups/{support_group.id}", info=params)
|
||||||
self.assert_json_error(
|
self.assert_json_error(
|
||||||
|
@ -530,7 +530,7 @@ class UserGroupAPITestCase(UserGroupTestCase):
|
||||||
name="role:internet", realm=hamlet.realm, is_system_group=True
|
name="role:internet", realm=hamlet.realm, is_system_group=True
|
||||||
)
|
)
|
||||||
params = {
|
params = {
|
||||||
"can_mention_group_id": orjson.dumps(internet_group.id).decode(),
|
"can_mention_group": orjson.dumps(internet_group.id).decode(),
|
||||||
}
|
}
|
||||||
result = self.client_patch(f"/json/user_groups/{support_group.id}", info=params)
|
result = self.client_patch(f"/json/user_groups/{support_group.id}", info=params)
|
||||||
self.assert_json_error(
|
self.assert_json_error(
|
||||||
|
@ -538,7 +538,7 @@ class UserGroupAPITestCase(UserGroupTestCase):
|
||||||
)
|
)
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
"can_mention_group_id": orjson.dumps(1111).decode(),
|
"can_mention_group": orjson.dumps(1111).decode(),
|
||||||
}
|
}
|
||||||
result = self.client_patch(f"/json/user_groups/{support_group.id}", info=params)
|
result = self.client_patch(f"/json/user_groups/{support_group.id}", info=params)
|
||||||
self.assert_json_error(result, "Invalid user group")
|
self.assert_json_error(result, "Invalid user group")
|
||||||
|
|
|
@ -49,7 +49,9 @@ def add_user_group(
|
||||||
name: str = REQ(),
|
name: str = REQ(),
|
||||||
members: Sequence[int] = REQ(json_validator=check_list(check_int), default=[]),
|
members: Sequence[int] = REQ(json_validator=check_list(check_int), default=[]),
|
||||||
description: str = REQ(),
|
description: str = REQ(),
|
||||||
can_mention_group_id: Optional[int] = REQ(json_validator=check_int, default=None),
|
can_mention_group_id: Optional[int] = REQ(
|
||||||
|
"can_mention_group", json_validator=check_int, default=None
|
||||||
|
),
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
user_profiles = user_ids_to_users(members, user_profile.realm)
|
user_profiles = user_ids_to_users(members, user_profile.realm)
|
||||||
name = check_user_group_name(name)
|
name = check_user_group_name(name)
|
||||||
|
@ -101,7 +103,9 @@ def edit_user_group(
|
||||||
user_group_id: int = REQ(json_validator=check_int, path_only=True),
|
user_group_id: int = REQ(json_validator=check_int, path_only=True),
|
||||||
name: Optional[str] = REQ(default=None),
|
name: Optional[str] = REQ(default=None),
|
||||||
description: Optional[str] = REQ(default=None),
|
description: Optional[str] = REQ(default=None),
|
||||||
can_mention_group_id: Optional[int] = REQ(json_validator=check_int, default=None),
|
can_mention_group_id: Optional[int] = REQ(
|
||||||
|
"can_mention_group", json_validator=check_int, default=None
|
||||||
|
),
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
if name is None and description is None and can_mention_group_id is None:
|
if name is None and description is None and can_mention_group_id is None:
|
||||||
raise JsonableError(_("No new data supplied"))
|
raise JsonableError(_("No new data supplied"))
|
||||||
|
|
Loading…
Reference in New Issue