19
|
1 import logging
|
|
2 log = logging.getLogger( __name__ )
|
|
3
|
|
4
|
|
5 def restrict_prims_metabolomics( context, tool ):
|
|
6 """
|
|
7 This tool filter will hide prims_metabolomics tools for non-metabolomics users.
|
|
8 This can be enabled by adding the following to the
|
|
9 ``app:main`` section of ``universe_wsgi.ini``::
|
|
10
|
|
11 tool_filters = primsfilters:restrict_prims_metabolomics
|
|
12
|
|
13 and by adding this file to the folder:
|
|
14
|
|
15 <galaxy-dist>/lib/galaxy/tools/filters
|
|
16
|
|
17 This is optional and can be used in case some control is desired on whom
|
|
18 gets to see the prims_metabolomics tools. When not using this file and the
|
|
19 settings mentioned above, all prims_metabolomics tools will be visible to
|
|
20 all users.
|
|
21 """
|
|
22 # for debugging: import pydevd;pydevd.settrace("L0136815.wurnet.nl")
|
|
23 user = context.trans.user
|
|
24 metabolomics_tools = [ "msclust2", "combine_output", "create_poly_model", "lookup_library", "NDIStext2tabular", "rankfilterGCMS_tabular", "filter_on_rank" ]
|
|
25 found_match = False
|
|
26 # iterate over the tool (partial)ids and look for a match (this is compatible with tool shed given ids):
|
|
27 for partial_id in metabolomics_tools:
|
|
28 if tool.id.find("/"+ partial_id + "/") >= 0:
|
|
29 found_match = True
|
|
30 break
|
|
31 # the second part of this if is compatible with the ids when NOT using tool shed:
|
|
32 if found_match or tool.id in metabolomics_tools:
|
|
33 # logging.warn( 'FILTER MATCHED: %s' %(tool.name))
|
|
34
|
|
35 for user_role in user.roles:
|
|
36 if user_role.role.name == "PRIMS_METABOLOMICS":
|
|
37 return True
|
|
38 # not found to have the role, return false:
|
|
39 return False
|
|
40 else:
|
|
41 # return true for any other tool
|
|
42 return True |