Skip to content

Utils

org_role_is_valid(group_or_org_id, username) ΒΆ

Determine whether the given user has a valid role in the specified group or organisation.

Parameters:

Name Type Description Default
group_or_org_id

ID of a group or organisation

required
username

username for the user to check

required

Returns:

Type Description
bool

True if the role is valid (member, editor, or admin), False otherwise

Source code in ckanext/userdatasets/logic/utils.py
10
11
12
13
14
15
16
17
18
19
20
21
def org_role_is_valid(group_or_org_id, username):
    """
    Determine whether the given user has a valid role in the specified group or
    organisation.

    :param group_or_org_id: ID of a group or organisation
    :param username: username for the user to check
    :returns: True if the role is valid (member, editor, or admin), False otherwise
    :rtype: bool
    """
    role = users_role_for_group_or_org(group_or_org_id, username)
    return role in ['member', 'editor', 'admin']