[ckan-dev] Restrict visible groups in _group_or_organization_list()

Adrià Mercader adria.mercader at okfn.org
Tue Apr 17 12:53:06 UTC 2018


Hi Knud,

On 17 April 2018 at 13:05, Knud Möller <knud at datalysator.com> wrote:
>
>
> So, I have two questions:
>
> - Is this a “good” way of implementing my use case?
>

It is a bit inefficient because you call `group_show` on all groups
returned. You can probably just override the default `group_list` using
`IActions` with something like this:

def my_group_list(context, data_dict_):
    group_list = core_group_list(context, data_dict_)
    user = context['user']
    if not user or not user.sysadmin:
        # Pop the restricted groups from the list
    return group_list





> - Is this of general interest? In that case, I’m happy to make a PR.
>

It sounds like a specific use case so it's probably better off in an
extension like you are implementing it

Hope this helps,

Adrià



>
> Cheers,
> Knud
>
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20180417/293d50fb/attachment-0003.html>


More information about the ckan-dev mailing list