commit/galaxy-central: 4 new changesets
4 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/07508592cb65/ Changeset: 07508592cb65 User: jeremy goecks Date: 2014-03-05 18:00:16 Summary: Enable workflow display_by_username_and_slug to support different 'display' formats: html, json, and json download. This makes it possible to generate human-readable URLs for all workflow display/download/export actions. Update download and export links to use display_by_username_and_slug. Affected #: 3 files diff -r 27f8a2d9c7115418b263b2ff2d705b96ed9e412b -r 07508592cb65845474b9f3e0f781260c0fd861bc lib/galaxy/webapps/galaxy/buildapp.py --- a/lib/galaxy/webapps/galaxy/buildapp.py +++ b/lib/galaxy/webapps/galaxy/buildapp.py @@ -66,6 +66,7 @@ webapp.add_route( '/u/:username/p/:slug', controller='page', action='display_by_username_and_slug' ) webapp.add_route( '/u/:username/h/:slug', controller='history', action='display_by_username_and_slug' ) webapp.add_route( '/u/:username/w/:slug', controller='workflow', action='display_by_username_and_slug' ) + webapp.add_route( '/u/:username/w/:slug/:format', controller='workflow', action='display_by_username_and_slug' ) webapp.add_route( '/u/:username/v/:slug', controller='visualization', action='display_by_username_and_slug' ) webapp.add_route( '/search', controller='search', action='index' ) diff -r 27f8a2d9c7115418b263b2ff2d705b96ed9e412b -r 07508592cb65845474b9f3e0f781260c0fd861bc lib/galaxy/webapps/galaxy/controllers/workflow.py --- a/lib/galaxy/webapps/galaxy/controllers/workflow.py +++ b/lib/galaxy/webapps/galaxy/controllers/workflow.py @@ -219,24 +219,35 @@ return trans.fill_template( "workflow/list_published.mako", grid=grid ) @web.expose - def display_by_username_and_slug( self, trans, username, slug ): - """ Display workflow based on a username and slug. """ + def display_by_username_and_slug( self, trans, username, slug, format='html' ): + """ + Display workflow based on a username and slug. Format can be html, json, or json-download. + """ - # Get workflow. + # Get workflow by username and slug. Security is handled by the display methods below. session = trans.sa_session user = session.query( model.User ).filter_by( username=username ).first() stored_workflow = trans.sa_session.query( model.StoredWorkflow ).filter_by( user=user, slug=slug, deleted=False ).first() - return self.display(trans, stored_workflow) + encoded_id = trans.security.encode_id( stored_workflow.id ) + + # Display workflow in requested format. + if format == 'html': + return self._display( trans, stored_workflow ) + elif format == 'json': + return self.for_direct_import( trans, encoded_id ) + elif format == 'json-download': + return self.export_to_file( trans, encoded_id ) @web.expose def display_by_id( self, trans, id ): """ Display workflow based on id. """ # Get workflow. stored_workflow = self.get_stored_workflow( trans, id ) - return self.display(trans, stored_workflow) + return self._display(trans, stored_workflow) - def display(self, trans, stored_workflow): - """ Base workflow display """ + def _display( self, trans, stored_workflow ): + """ Diplay workflow as HTML page. """ + if stored_workflow is None: raise web.httpexceptions.HTTPNotFound() # Security check raises error if user cannot access workflow. @@ -552,6 +563,7 @@ stored_workflow = model.StoredWorkflow() stored_workflow.name = workflow_name stored_workflow.user = user + self.create_item_slug( trans.sa_session, stored_workflow ) # And the first (empty) workflow revision workflow = model.Workflow() workflow.name = workflow_name @@ -882,6 +894,12 @@ Handles download/export workflow command. """ stored = self.get_stored_workflow( trans, id, check_ownership=False, check_accessible=True ) + + # Export requires workflow to have a slug, so set slug if necessary. + if not stored.slug: + self.create_item_slug( trans.sa_session, stored ) + trans.sa_session.flush() + return trans.fill_template( "/workflow/export.mako", item=stored, use_panels=True ) @web.expose diff -r 27f8a2d9c7115418b263b2ff2d705b96ed9e412b -r 07508592cb65845474b9f3e0f781260c0fd861bc templates/export_base.mako --- a/templates/export_base.mako +++ b/templates/export_base.mako @@ -78,7 +78,8 @@ %if item.importable: Use this URL to import the ${get_class_display_name( item.__class__ ).lower()} directly into another Galaxy server: <div class="display-url"> - ${h.url_for(controller=self.controller, action='for_direct_import', id=trans.security.encode_id( item.id ), qualified=True )} + ${h.url_for(controller=self.controller, action='display_by_username_and_slug', username=trans.user.username, + slug=item.slug, format='json', qualified=True )} </div> (Copy this URL into the box titled 'Workflow URL' in the Import Workflow page.) %else: @@ -89,7 +90,8 @@ <%def name="render_download_to_file(item)"><h3>Download to File</h3> - <a href="${h.url_for(controller=self.controller, action='export_to_file', id=trans.security.encode_id( item.id ) )}"> + <a href="${h.url_for( controller=self.controller, action='display_by_username_and_slug', username=trans.user.username, + slug=item.slug, format='json-download' )}"> Download ${get_class_display_name( item.__class__ ).lower()} to file so that it can be saved or imported into another Galaxy server.</a></%def> https://bitbucket.org/galaxy/galaxy-central/commits/63dd3cfc0abe/ Changeset: 63dd3cfc0abe User: jeremy goecks Date: 2014-03-05 18:23:27 Summary: Fix 07508592cb65 bug to correctly set username for workflow download/link. Affected #: 1 file diff -r 07508592cb65845474b9f3e0f781260c0fd861bc -r 63dd3cfc0abe162d6825a8ac8cbee027678d1793 templates/export_base.mako --- a/templates/export_base.mako +++ b/templates/export_base.mako @@ -78,7 +78,7 @@ %if item.importable: Use this URL to import the ${get_class_display_name( item.__class__ ).lower()} directly into another Galaxy server: <div class="display-url"> - ${h.url_for(controller=self.controller, action='display_by_username_and_slug', username=trans.user.username, + ${h.url_for(controller=self.controller, action='display_by_username_and_slug', username=item.user.username, slug=item.slug, format='json', qualified=True )} </div> (Copy this URL into the box titled 'Workflow URL' in the Import Workflow page.) @@ -90,7 +90,7 @@ <%def name="render_download_to_file(item)"><h3>Download to File</h3> - <a href="${h.url_for( controller=self.controller, action='display_by_username_and_slug', username=trans.user.username, + <a href="${h.url_for( controller=self.controller, action='display_by_username_and_slug', username=item.user.username, slug=item.slug, format='json-download' )}"> Download ${get_class_display_name( item.__class__ ).lower()} to file so that it can be saved or imported into another Galaxy server.</a></%def> https://bitbucket.org/galaxy/galaxy-central/commits/920332bc082c/ Changeset: 920332bc082c User: jeremy goecks Date: 2014-03-05 18:25:33 Summary: Add save and link options for embedded workflows. Affected #: 1 file diff -r 63dd3cfc0abe162d6825a8ac8cbee027678d1793 -r 920332bc082cbd40452ccd0ac10f29192e094dad templates/webapps/galaxy/workflow/embed.mako --- a/templates/webapps/galaxy/workflow/embed.mako +++ b/templates/webapps/galaxy/workflow/embed.mako @@ -3,6 +3,17 @@ from galaxy.web.framework.helpers import iff %> +<%def name="render_item_links( workflow )"> + <a href="${h.url_for( controller='workflow', action='display_by_username_and_slug', username=workflow.user.username, + slug=item.slug, format='json-download' )}" title="Save Worflow" class="icon-button disk"> + ## FIXME: find and set appropriate icon for linking to workflow. + <!-- + <a href="${h.url_for( controller='workflow', action='display_by_username_and_slug', username=workflow.user.username, + slug=item.slug, format='json' )}" title="Worflow Link for Import" class="icon-button TODO "> + --> + ${parent.render_item_links( workflow )} +</%def> + <%def name="render_summary_content( workflow, steps )"> ## <ul> https://bitbucket.org/galaxy/galaxy-central/commits/8bb60a2538f6/ Changeset: 8bb60a2538f6 User: jeremy goecks Date: 2014-03-05 18:34:44 Summary: To ensure that workflow has a slug, create slug when retrieving workflow from database. Remove slug creation code from user controller actions. Affected #: 2 files diff -r 920332bc082cbd40452ccd0ac10f29192e094dad -r 8bb60a2538f6d2c4525ea50e3c37e3e78063814b lib/galaxy/web/base/controller.py --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -1562,10 +1562,18 @@ workflow = trans.sa_session.query( trans.model.StoredWorkflow ).get( trans.security.decode_id( id ) ) except TypeError: workflow = None + if not workflow: error( "Workflow not found" ) else: - return self.security_check( trans, workflow, check_ownership, check_accessible ) + self.security_check( trans, workflow, check_ownership, check_accessible ) + + # Older workflows may be missing slugs, so set them here. + if not workflow.slug: + self.create_item_slug( trans.sa_session, workflow ) + trans.sa_session.flush() + + return workflow def get_stored_workflow_steps( self, trans, stored_workflow ): """ Restores states for a stored workflow's steps. """ diff -r 920332bc082cbd40452ccd0ac10f29192e094dad -r 8bb60a2538f6d2c4525ea50e3c37e3e78063814b lib/galaxy/webapps/galaxy/controllers/workflow.py --- a/lib/galaxy/webapps/galaxy/controllers/workflow.py +++ b/lib/galaxy/webapps/galaxy/controllers/workflow.py @@ -313,7 +313,6 @@ share.user = other session = trans.sa_session session.add( share ) - self.create_item_slug( session, stored ) session.flush() trans.set_message( "Workflow '%s' shared with user '%s'" % ( stored.name, other.email ) ) return trans.response.send_redirect( url_for( controller='workflow', action='sharing', id=id ) ) @@ -505,8 +504,6 @@ """ Returns workflow's name and link. """ stored = self.get_stored_workflow( trans, id ) - if self.create_item_slug( trans.sa_session, stored ): - trans.sa_session.flush() return_dict = { "name" : stored.name, "link" : url_for(controller='workflow', action="display_by_username_and_slug", username=stored.user.username, slug=stored.slug ) } return return_dict @@ -895,11 +892,6 @@ """ stored = self.get_stored_workflow( trans, id, check_ownership=False, check_accessible=True ) - # Export requires workflow to have a slug, so set slug if necessary. - if not stored.slug: - self.create_item_slug( trans.sa_session, stored ) - trans.sa_session.flush() - return trans.fill_template( "/workflow/export.mako", item=stored, use_panels=True ) @web.expose Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org