From b81088ed33e160b0cef02c2e308760db0f3d29d9 Mon Sep 17 00:00:00 2001 From: Jeremy Goecks Date: Fri, 22 Jan 2010 08:47:05 -0500 Subject: [PATCH] Require that users set a public username before making items accessible via link or publishing. --- lib/galaxy/web/base/controller.py | 9 ++ lib/galaxy/web/controllers/history.py | 2 +- templates/sharing_base.mako | 126 +++++++++++++++----------- 3 files changed, 82 insertions(+), 55 deletions(-) diff --git a/lib/galaxy/web/base/controller.py b/lib/galaxy/web/base/controller.py index 1144c61ab4e..4eaeb16f535 100644 --- a/lib/galaxy/web/base/controller.py +++ b/lib/galaxy/web/base/controller.py @@ -115,6 +115,15 @@ class SharingStatusColumn( grids.GridColumn ): class Sharable: """ Mixin for a controller that manages and item that can be shared. """ + + # Implemented methods. + @web.expose + @web.require_login( "share Galaxy items" ) + def set_public_username( self, trans, id, username, **kwargs ): + """ Set user's public username and delegate to sharing() """ + trans.get_user().username = username + trans.sa_session.flush + return self.sharing( trans, id, **kwargs ) # Abstract methods. diff --git a/lib/galaxy/web/controllers/history.py b/lib/galaxy/web/controllers/history.py index 9ceda61f6c1..b676dcf3ff4 100644 --- a/lib/galaxy/web/controllers/history.py +++ b/lib/galaxy/web/controllers/history.py @@ -542,7 +542,7 @@ class HistoryController( BaseController, Sharable ): elif 'unpublish' in kwargs: history.published = False elif 'disable_link_access_and_unpubish' in kwargs: - history.importable = stored.published = False + history.importable = history.published = False elif 'unshare_user' in kwargs: user = trans.sa_session.query( trans.app.model.User ).get( trans.security.decode_id( kwargs[ 'unshare_user' ] ) ) if not user: diff --git a/templates/sharing_base.mako b/templates/sharing_base.mako index c66d4d91eaf..12dda834d16 100644 --- a/templates/sharing_base.mako +++ b/templates/sharing_base.mako @@ -71,64 +71,82 @@

Making ${item_class_name} Accessible via Link and Publishing It

- %if item.importable: - <% - item_status = "accessible via link" - if item.published: - item_status = item_status + " and published" - %> - This ${item_class_name_lc} ${item_status}. -
-

Anyone can view and import this ${item_class_name_lc} by visiting the following URL: - <% url = h.url_for( action='display_by_username_and_slug', username=trans.get_user().username, slug=item.slug, qualified=True ) %> -

- ${url} -
- - %if item.published: - This ${item_class_name_lc} is publicly listed and searchable in Galaxy's Published ${item_class_plural_name} section. - %endif -
- -

You can: -

-
+ - %if not item.published: - ## Item is importable but not published. User can disable importable or publish. - -
Disables ${item_class_name_lc}'s link so that it is not accessible.
-
- -
Publishes the ${item_class_name_lc} to Galaxy's Published ${item_class_plural_name} section, where it is publicly listed and searchable.
- -
- %else: ## item.published == True - ## Item is importable and published. User can unpublish or disable import and unpublish. - -
Removes ${item_class_name_lc} from Galaxy's Published ${item_class_plural_name} section so that it is not publicly listed or searchable.
-
- -
Disables ${item_class_name_lc}'s link so that it is not accessible and removes ${item_class_name_lc} from Galaxy's Published ${item_class_plural_name} section so that it is not publicly listed or searchable.
- %endif - -
-
- +
+ +
+ +
+
+
+
+ +
+ %else: - - This ${item_class_name_lc} is currently restricted so that only you and the users listed below can access it. You can: -

-

- -
Generates a web link that you can share with other people so that they can view and import the ${item_class_name_lc}.
+ %if item.importable: + <% + item_status = "accessible via link" + if item.published: + item_status = item_status + " and published" + %> + This ${item_class_name_lc} ${item_status}. +
+

Anyone can view and import this ${item_class_name_lc} by visiting the following URL: + <% url = h.url_for( action='display_by_username_and_slug', username=trans.get_user().username, slug=item.slug, qualified=True ) %> +

+ ${url} +
-
- -
Makes the ${item_class_name_lc} accessible via link (see above) and publishes the ${item_class_name_lc} to Galaxy's Published ${item_class_plural_name} section, where it is publicly listed and searchable.
- + %if item.published: + This ${item_class_name_lc} is publicly listed and searchable in Galaxy's Published ${item_class_plural_name} section. + %endif +
+ +

You can: +

+
+ %if not item.published: + ## Item is importable but not published. User can disable importable or publish. + +
Disables ${item_class_name_lc}'s link so that it is not accessible.
+
+ +
Publishes the ${item_class_name_lc} to Galaxy's Published ${item_class_plural_name} section, where it is publicly listed and searchable.
+ +
+ %else: ## item.published == True + ## Item is importable and published. User can unpublish or disable import and unpublish. + +
Removes ${item_class_name_lc} from Galaxy's Published ${item_class_plural_name} section so that it is not publicly listed or searchable.
+
+ +
Disables ${item_class_name_lc}'s link so that it is not accessible and removes ${item_class_name_lc} from Galaxy's Published ${item_class_plural_name} section so that it is not publicly listed or searchable.
+ %endif + +
+
+ + %else: + + This ${item_class_name_lc} is currently restricted so that only you and the users listed below can access it. You can: +

+

+ +
Generates a web link that you can share with other people so that they can view and import the ${item_class_name_lc}.
+ +
+ +
Makes the ${item_class_name_lc} accessible via link (see above) and publishes the ${item_class_name_lc} to Galaxy's Published ${item_class_plural_name} section, where it is publicly listed and searchable.
+
- %endif + %endif + %endif

Sharing ${item_class_name} with Specific Users