[go: nahoru, domu]

Skip to content

Commit

Permalink
REBASE/TEST -- use other url-builder?
Browse files Browse the repository at this point in the history
  • Loading branch information
dannon committed Apr 25, 2023
1 parent 3b8fec1 commit 7e07c4a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions lib/galaxy/visualization/plugins/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def render_saved(self, visualization, trans=None, embedded=None, **kwargs):
)
return self._render(render_vars, trans=trans, embedded=embedded)

def to_dict(self):
def to_dict(self, url_builder=None):
return {
"name": self.name,
"html": self.config.get("name"),
Expand All @@ -125,13 +125,15 @@ def to_dict(self):
"settings": self.config.get("settings"),
"groups": self.config.get("groups"),
"specs": self.config.get("specs"),
"href": self._get_url(),
"href": self._get_url(url_builder),
}

def _get_url(self):
def _get_url(self, url_builder=None):
url_builder = None
url_builder = url_builder or self.app.url_for
if self.name in self.app.visualizations_registry.BUILT_IN_VISUALIZATIONS:
return self.app.url_for(controller="visualization", action=self.name)
return self.app.url_for("visualization_plugin", visualization_name=self.name)
return url_builder(controller="visualization", action=self.name)
return url_builder("visualization_plugin", visualization_name=self.name)

def _get_static_path(self, path):
if "/config/" in path:
Expand Down Expand Up @@ -254,7 +256,7 @@ def _render(self, render_vars, trans=None, embedded=None, **kwargs):
template.
"""
render_vars["embedded"] = self._parse_embedded(embedded)
render_vars["static_url"] = self.app.url_for(f"/{self.static_path}/")
render_vars["static_url"] = trans.url_builder(f"/{self.static_path}/")
render_vars.update(vars={})
render_vars.update({"script_attributes": self.config["entry_point"]["attr"]})
template_filename = os.path.join(self.MAKO_TEMPLATE)
Expand Down
4 changes: 2 additions & 2 deletions lib/galaxy/webapps/galaxy/api/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def index(
return plugins

@router.get(
"/api/plugins/{id}",
"/api/plugins/{plugin_id}",
summary="Get a plugin by id",
response_description="Plugin",
)
Expand All @@ -107,7 +107,7 @@ def show(
if registry.get_visualization(trans, plugin_id, hda):
result["hdas"].append({"id": trans.security.encode_id(hda.id), "name": hda.name})
else:
result = registry.get_plugin(plugin_id).to_dict()
result = registry.get_plugin(plugin_id).to_dict(url_builder=trans.url_builder)
return result

def _get_registry(self, trans):
Expand Down

0 comments on commit 7e07c4a

Please sign in to comment.