Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop non required function get_group_or_org_admin_ids #8067

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions changes/8067.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The `get_group_or_org_admin_ids` function is old and can be easily replaced by
the `member_list` action.
16 changes: 0 additions & 16 deletions ckan/authz.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,22 +181,6 @@ def _get_user(username: Optional[str]) -> Optional['model.User']:
return model.User.get(username)


def get_group_or_org_admin_ids(group_id: Optional[str]) -> list[str]:
if not group_id:
return []
group = model.Group.get(group_id)
if not group:
return []
q = model.Session.query(model.Member.table_id) \
.filter(model.Member.group_id == group.id) \
.filter(model.Member.table_name == 'user') \
.filter(model.Member.state == 'active') \
.filter(model.Member.capacity == 'admin')

# type_ignore_reason: all stored memerships have table_id
return [a.table_id for a in q]


def is_authorized_boolean(action: str, context: Context, data_dict: Optional[DataDict]=None) -> bool:
''' runs the auth function but just returns True if allowed else False
'''
Expand Down
8 changes: 6 additions & 2 deletions ckan/views/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,13 +790,17 @@ def admins(id: str, group_type: str, is_organization: bool) -> str:
extra_vars = {}
set_org(is_organization)
group_dict = _get_group_dict(id, group_type)
admins = authz.get_group_or_org_admin_ids(id)
admins = get_action('member_list')(
{'ignore_auth': True},
{'id': id, 'object_type': 'user', 'capacity': 'admin'}
)
admin_ids = [admin[0] for admin in admins]

# TODO: Remove
# ckan 2.9: Adding variables that were removed from c object for
# compatibility with templates in existing extensions
g.group_dict = group_dict
g.admins = admins
g.admins = admin_ids

extra_vars: dict[str, Any] = {
u"group_dict": group_dict,
Expand Down