Mercurial > repos > pieterlukasse > prims_metabolomics
diff primsfilters.py @ 19:c068ed713eb9
fixes on <when> tags
author | pieter.lukasse@wur.nl |
---|---|
date | Fri, 31 Jan 2014 12:21:51 +0100 |
parents | |
children | cd4f13119afa |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/primsfilters.py Fri Jan 31 12:21:51 2014 +0100 @@ -0,0 +1,42 @@ +import logging +log = logging.getLogger( __name__ ) + + +def restrict_prims_metabolomics( context, tool ): + """ + This tool filter will hide prims_metabolomics tools 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 + + and by adding this file to the folder: + + <galaxy-dist>/lib/galaxy/tools/filters + + This is optional and can be used in case some control is desired on whom + gets to see the prims_metabolomics tools. When not using this file and the + settings mentioned above, all prims_metabolomics tools will be visible to + all users. + """ + # for debugging: import pydevd;pydevd.settrace("L0136815.wurnet.nl") + user = context.trans.user + metabolomics_tools = [ "msclust2", "combine_output", "create_poly_model", "lookup_library", "NDIStext2tabular", "rankfilterGCMS_tabular", "filter_on_rank" ] + found_match = False + # iterate over the tool (partial)ids and look for a match (this is compatible with tool shed given ids): + for partial_id in metabolomics_tools: + if tool.id.find("/"+ partial_id + "/") >= 0: + found_match = True + break + # the second part of this if is compatible with the ids when NOT using tool shed: + if found_match or tool.id 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 \ No newline at end of file