Skip to content

Commit

Permalink
Change invocation to pass user information
Browse files Browse the repository at this point in the history
  • Loading branch information
hexylena committed Aug 10, 2017
1 parent 73369a2 commit cdb82dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion lib/galaxy/tools/error_reports/__init__.py
Expand Up @@ -36,10 +36,21 @@ class ErrorSink(object):

def __init__(self, plugin_classes, plugins_source, **kwargs):
self.extra_kwargs = kwargs
self.app = kwargs['app']
self.plugin_classes = plugin_classes
self.plugins = self.__plugins_from_source(plugins_source)

def submit_report(self, dataset, job, tool, user_submission=False, **kwargs):
def _can_access_dataset(self, dataset, user):
if user:
roles = user.all_roles()
else:
roles = []
return self.app.security_agent.can_access_dataset(roles, dataset.dataset)

def submit_report(self, dataset, job, tool, user, user_submission=False, **kwargs):
if user_submission:
assert self._can_access_dataset(dataset, user), Exception("You are not allowed to access this dataset.")

responses = []
for plugin in self.plugins:
if user_submission == plugin.user_submission:
Expand Down
3 changes: 2 additions & 1 deletion lib/galaxy/webapps/galaxy/api/jobs.py
Expand Up @@ -381,7 +381,8 @@ def error( self, trans, id, **kwd ):
job = self.__get_job( trans, id )
tool = trans.app.toolbox.get_tool( job.tool_id, tool_version=job.tool_version ) or None
messages = trans.app.error_reports.default_error_sink.submit_report(
dataset, job, tool, user_submission=True, email=kwd.get('email', trans.user.email),
dataset, job, tool, user_submission=True, user=trans.user,
email=kwd.get('email', trans.user.email),
message=kwd.get('message', None)
)

Expand Down

0 comments on commit cdb82dd

Please sign in to comment.