commit/galaxy-central: jgoecks: Clone annotation and tags when cloning workflows.
1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/ffba3d4a66d5/ changeset: r5580:ffba3d4a66d5 user: jgoecks date: 2011-05-18 22:48:02 summary: Clone annotation and tags when cloning workflows. affected #: 3 files (1.3 KB) --- a/lib/galaxy/model/mapping.py Tue May 17 21:31:34 2011 -0400 +++ b/lib/galaxy/model/mapping.py Wed May 18 16:48:02 2011 -0400 @@ -1469,7 +1469,12 @@ latest_workflow=relation( Workflow, post_update=True, primaryjoin=( StoredWorkflow.table.c.latest_workflow_id == Workflow.table.c.id ), lazy=False ), - tags=relation( StoredWorkflowTagAssociation, order_by=StoredWorkflowTagAssociation.table.c.id, backref="stored_workflows" ), + tags=relation( StoredWorkflowTagAssociation, order_by=StoredWorkflowTagAssociation.table.c.id, backref="stored_workflows" ), + owner_tags=relation( StoredWorkflowTagAssociation, + primaryjoin=and_( StoredWorkflow.table.c.id == StoredWorkflowTagAssociation.table.c.stored_workflow_id, + StoredWorkflow.table.c.user_id == StoredWorkflowTagAssociation.table.c.user_id ), + foreign_keys=[StoredWorkflowTagAssociation.table.c.user_id], + order_by=StoredWorkflowTagAssociation.table.c.id ), annotations=relation( StoredWorkflowAnnotationAssociation, order_by=StoredWorkflowAnnotationAssociation.table.c.id, backref="stored_workflows" ), ratings=relation( StoredWorkflowRatingAssociation, order_by=StoredWorkflowRatingAssociation.table.c.id, backref="stored_workflows" ) ) ) --- a/lib/galaxy/web/controllers/workflow.py Tue May 17 21:31:34 2011 -0400 +++ b/lib/galaxy/web/controllers/workflow.py Wed May 18 16:48:02 2011 -0400 @@ -586,6 +586,7 @@ @web.expose @web.require_login( "use Galaxy workflows" ) def clone( self, trans, id ): + # Get workflow to clone. stored = self.get_stored_workflow( trans, id, check_ownership=False ) user = trans.get_user() if stored.user == user: @@ -595,9 +596,24 @@ .filter_by( user=user, stored_workflow=stored ).count() == 0: error( "Workflow is not owned by or shared with current user" ) owner = False + + # Clone. new_stored = model.StoredWorkflow() new_stored.name = "Clone of '%s'" % stored.name new_stored.latest_workflow = stored.latest_workflow + # Clone annotation. + annotation_obj = self.get_item_annotation_obj( trans.sa_session, stored.user, stored ) + if annotation_obj: + self.add_item_annotation( trans.sa_session, trans.get_user(), new_stored, annotation_obj.annotation ) + # Clone tags. + for swta in stored.owner_tags: + new_swta = model.StoredWorkflowTagAssociation() + new_swta.tag = swta.tag + new_swta.user = trans.user + new_swta.user_tname = swta.user_tname + new_swta.user_value = swta.user_value + new_swta.value = swta.value + new_stored.tags.append( new_swta ) if not owner: new_stored.name += " shared by '%s'" % stored.user.email new_stored.user = user --- a/templates/tagging_common.mako Tue May 17 21:31:34 2011 -0400 +++ b/templates/tagging_common.mako Wed May 18 16:48:02 2011 -0400 @@ -126,7 +126,7 @@ tagged_item_id = str( trans.security.encode_id ( tagged_item.id ) ) elt_id = int ( floor ( random()*maxint ) ) - # Get list of user's item tags. TODO: this could be moved to a database query for speed purposes. + # Get list of user's item tags. TODO: implement owner_tags for all taggable objects and use here. item_tags = [ tag for tag in tagged_item.tags if ( tag.user == user ) ] %> 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)
-
Bitbucket