# HG changeset patch # User pieter.lukasse@wur.nl # Date 1391167311 -3600 # Node ID c068ed713eb9f5b1fbc73315d26cad0f9ff757b1 # Parent 278680d76d71d9bfe0bce8e0700769a4eebe0810 fixes on tags diff -r 278680d76d71 -r c068ed713eb9 msclust.xml --- a/msclust.xml Tue Jan 28 16:22:15 2014 +0100 +++ b/msclust.xml Fri Jan 31 12:21:51 2014 +0100 @@ -80,6 +80,10 @@ + + + + @@ -111,10 +115,12 @@ + @@ -169,6 +175,8 @@ + + diff -r 278680d76d71 -r c068ed713eb9 primsfilters.py --- /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: + + /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