Toolbox filtering question

classic Classic list List threaded Threaded
3 messages Options
| Threaded
Open this post in threaded view
|

Toolbox filtering question

Lukasse, Pieter

Hi,

 

I would like specify a filter based on a role. Does someone know how to do this? I already have an example on how to do this based on user id (found at https://wiki.galaxyproject.org/UserDefinedToolboxFilters#For_Administrators) but now I would like to filter out menu items in case users don’t have a specific role.

 

Thanks and regards,

 

Pieter Lukasse

Wageningen UR, Plant Research International

Departments of Bioscience and Bioinformatics

Wageningen Campus, Building 107, Droevendaalsesteeg 1, 6708 PB,
Wageningen, the Netherlands

+31-317481122; skype: pieter.lukasse.wur

http://www.pri.wur.nl

 


___________________________________________________________
Please keep all replies on the list by using "reply all"
in your mail client.  To manage your subscriptions to this
and other Galaxy lists, please use the interface at:
  http://lists.bx.psu.edu/

To search Galaxy mailing lists use the unified search at:
  http://galaxyproject.org/search/mailinglists/
| Threaded
Open this post in threaded view
|

Re: Toolbox filtering question

Lukasse, Pieter

Ok, just answering my own question ;) I found a solution, here it goes (also attached):

 

import logging

log = logging.getLogger( __name__ )

 

 

def restrict_prims_metabolomics( context, tool ):

    """

    This tool filter will hide MsClust for non-metabolomics users. This can be

    enabled by adding the following to the

     ``app:main`` section of ``universe_wsgi.ini``::

 

        tool_filters = primsfilters:restrict_prims_metabolomics

    """

    # for debugging: import pydevd;pydevd.settrace("L0136815.wurnet.nl")

    user = context.trans.user

    metabolomics_tools = [ "MsClust", "textutil", "filter" ]

    if tool.name in metabolomics_tools:

        # logging.warn( 'FILTER MATCHED: %s' %(tool.name))       

    

        for user_role in user.roles:

            if user_role.role.name == "PRIMS_METABOLOMICS":

                return True

        # not found to have the role, return false:

        return False

    else:

        # return true for any other tool

        return True

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Lukasse, Pieter
Sent: donderdag 30 januari 2014 14:25
To: [hidden email]
Subject: [galaxy-dev] Toolbox filtering question

 

Hi,

 

I would like specify a filter based on a role. Does someone know how to do this? I already have an example on how to do this based on user id (found at https://wiki.galaxyproject.org/UserDefinedToolboxFilters#For_Administrators) but now I would like to filter out menu items in case users don’t have a specific role.

 

Thanks and regards,

 

Pieter Lukasse

Wageningen UR, Plant Research International

Departments of Bioscience and Bioinformatics

Wageningen Campus, Building 107, Droevendaalsesteeg 1, 6708 PB,
Wageningen, the Netherlands

+31-317481122; skype: pieter.lukasse.wur

http://www.pri.wur.nl

 


___________________________________________________________
Please keep all replies on the list by using "reply all"
in your mail client.  To manage your subscriptions to this
and other Galaxy lists, please use the interface at:
  http://lists.bx.psu.edu/

To search Galaxy mailing lists use the unified search at:
  http://galaxyproject.org/search/mailinglists/

primsfilters.py (1K) Download Attachment
| Threaded
Open this post in threaded view
|

Re: Toolbox filtering question

Björn Grüning-3
Hi Pieter,

glad to see that features is actually used :)
Do you mind to add your example to the wiki? Otherwise I can also add it
if you like.

Thanks,
Bjoern

> Ok, just answering my own question ;) I found a solution, here it goes
> (also attached):
>
>  
>
> import logging
>
> log = logging.getLogger( __name__ )
>
>  
>
>  
>
> defrestrict_prims_metabolomics( context, tool ):
>
>    """
>
>     This tool filter will hide MsClust for non-metabolomics users.
> This can be
>
>     enabled by adding the following to the
>
>      ``app:main`` section of ``universe_wsgi.ini``::
>
>  
>
>         tool_filters = primsfilters:restrict_prims_metabolomics
>
>     """
>
>    # for debugging: import
> pydevd;pydevd.settrace("L0136815.wurnet.nl")
>
>     user = context.trans.user
>
>     metabolomics_tools = ["MsClust","textutil","filter" ]
>
>    if tool.namein metabolomics_tools:
>
>         # logging.warn( 'FILTER MATCHED: %s' %(tool.name))        
>
>    
>
>         for user_role in user.roles:
>
>            if user_role.role.name == "PRIMS_METABOLOMICS":
>
>                returnTrue
>
>        # not found to have the role, return false:
>
>        returnFalse
>
>    else:
>
>        # return true for any other tool
>
>        returnTrue
>
>  
>
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of Lukasse,
> Pieter
> Sent: donderdag 30 januari 2014 14:25
> To: [hidden email]
> Subject: [galaxy-dev] Toolbox filtering question
>
>
>  
>
> Hi,
>
>  
>
> I would like specify a filter based on a role. Does someone know how
> to do this? I already have an example on how to do this based on user
> id (found
> athttps://wiki.galaxyproject.org/UserDefinedToolboxFilters#For_Administrators) but now I would like to filter out menu items in case users don’t have a specific role.
>
>  
>
> Thanks and regards,
>
>  
>
> Pieter Lukasse
>
> Wageningen UR, Plant Research International
>
> Departments of Bioscience and Bioinformatics
>
> Wageningen Campus, Building 107, Droevendaalsesteeg 1, 6708 PB,
> Wageningen, the Netherlands
>
> +31-317481122; skype: pieter.lukasse.wur
>
> http://www.pri.wur.nl
>
>  
>
>
> ___________________________________________________________
> Please keep all replies on the list by using "reply all"
> in your mail client.  To manage your subscriptions to this
> and other Galaxy lists, please use the interface at:
>   http://lists.bx.psu.edu/
>
> To search Galaxy mailing lists use the unified search at:
>   http://galaxyproject.org/search/mailinglists/


___________________________________________________________
Please keep all replies on the list by using "reply all"
in your mail client.  To manage your subscriptions to this
and other Galaxy lists, please use the interface at:
  http://lists.bx.psu.edu/

To search Galaxy mailing lists use the unified search at:
  http://galaxyproject.org/search/mailinglists/