Require that users set a public username before making items accessible via link or publishing.

This commit is contained in:
Jeremy Goecks
2010-01-22 08:47:05 -05:00
parent 58305aace6
commit b81088ed33
3 changed files with 82 additions and 55 deletions
+9
View File
@@ -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.
+1 -1
View File
@@ -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:
+72 -54
View File
@@ -71,64 +71,82 @@
<h3>Making ${item_class_name} Accessible via Link and Publishing It</h3>
<div class="indent">
%if item.importable:
<%
item_status = "accessible via link"
if item.published:
item_status = item_status + " and published"
%>
This ${item_class_name_lc} <strong>${item_status}</strong>.
<div class="indent">
<p>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 ) %>
<blockquote>
<a href="${url}" target="_top">${url}</a>
</blockquote>
%if item.published:
This ${item_class_name_lc} is publicly listed and searchable in Galaxy's <a href='${h.url_for( action='list_published' )}' target="_top">Published ${item_class_plural_name}</a> section.
%endif
</div>
<p>You can:
<div class="indent">
<form action="${h.url_for( action='sharing', id=trans.security.encode_id( item.id ) )}"
%if trans.get_user().username is None or trans.get_user().username is "":
To make a ${item_class_name_lc} accessible via link or publish it, you must create a public username:
<p>
<form action="${h.url_for( action='set_public_username', id=trans.security.encode_id( item.id ) )}"
method="POST">
%if not item.published:
## Item is importable but not published. User can disable importable or publish.
<input class="action-button" type="submit" name="disable_link_access" value="Disable Access to ${item_class_name} Link">
<div class="toolParamHelp">Disables ${item_class_name_lc}'s link so that it is not accessible.</div>
<br>
<input class="action-button" type="submit" name="publish" value="Publish ${item_class_name}" method="POST">
<div class="toolParamHelp">Publishes the ${item_class_name_lc} to Galaxy's <a href='${h.url_for( action='list_published' )}' target="_top">Published ${item_class_plural_name}</a> section, where it is publicly listed and searchable.</div>
<br>
%else: ## item.published == True
## Item is importable and published. User can unpublish or disable import and unpublish.
<input class="action-button" type="submit" name="unpublish" value="Unpublish ${item_class_name}">
<div class="toolParamHelp">Removes ${item_class_name_lc} from Galaxy's <a href='${h.url_for( action='list_published' )}' target="_top">Published ${item_class_plural_name}</a> section so that it is not publicly listed or searchable.</div>
<br>
<input class="action-button" type="submit" name="disable_link_access_and_unpubish" value="Disable Access to ${item_class_name} via Link and Unpublish">
<div class="toolParamHelp">Disables ${item_class_name_lc}'s link so that it is not accessible and removes ${item_class_name_lc} from Galaxy's <a href='${h.url_for( action='list_published' )}' target='_top'>Published ${item_class_plural_name}</a> section so that it is not publicly listed or searchable.</div>
%endif
</form>
</div>
<div class="form-row">
<label>Public Username:</label>
<div class="form-row-input">
<input type="text" name="username" size="40"/>
</div>
</div>
<div style="clear: both"></div>
<div class="form-row">
<input class="action-button" type="submit" name="Set Username" value="Set Username"/>
</div>
</form>
%else:
This ${item_class_name_lc} is currently restricted so that only you and the users listed below can access it. You can:
<p>
<form action="${h.url_for( action='sharing', id=trans.security.encode_id(item.id) )}" method="POST">
<input class="action-button" type="submit" name="make_accessible_via_link" value="Make ${item_class_name} Accessible via Link">
<div class="toolParamHelp">Generates a web link that you can share with other people so that they can view and import the ${item_class_name_lc}.</div>
%if item.importable:
<%
item_status = "accessible via link"
if item.published:
item_status = item_status + " and published"
%>
This ${item_class_name_lc} <strong>${item_status}</strong>.
<div class="indent">
<p>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 ) %>
<blockquote>
<a href="${url}" target="_top">${url}</a>
</blockquote>
<br>
<input class="action-button" type="submit" name="make_accessible_and_publish" value="Make ${item_class_name} Accessible and Publish" method="POST">
<div class="toolParamHelp">Makes the ${item_class_name_lc} accessible via link (see above) and publishes the ${item_class_name_lc} to Galaxy's <a href='${h.url_for( action='list_published' )}' target='_top'>Published ${item_class_plural_name}</a> section, where it is publicly listed and searchable.</div>
</form>
%if item.published:
This ${item_class_name_lc} is publicly listed and searchable in Galaxy's <a href='${h.url_for( action='list_published' )}' target="_top">Published ${item_class_plural_name}</a> section.
%endif
</div>
<p>You can:
<div class="indent">
<form action="${h.url_for( action='sharing', id=trans.security.encode_id( item.id ) )}"
method="POST">
%if not item.published:
## Item is importable but not published. User can disable importable or publish.
<input class="action-button" type="submit" name="disable_link_access" value="Disable Access to ${item_class_name} Link">
<div class="toolParamHelp">Disables ${item_class_name_lc}'s link so that it is not accessible.</div>
<br>
<input class="action-button" type="submit" name="publish" value="Publish ${item_class_name}" method="POST">
<div class="toolParamHelp">Publishes the ${item_class_name_lc} to Galaxy's <a href='${h.url_for( action='list_published' )}' target="_top">Published ${item_class_plural_name}</a> section, where it is publicly listed and searchable.</div>
<br>
%else: ## item.published == True
## Item is importable and published. User can unpublish or disable import and unpublish.
<input class="action-button" type="submit" name="unpublish" value="Unpublish ${item_class_name}">
<div class="toolParamHelp">Removes ${item_class_name_lc} from Galaxy's <a href='${h.url_for( action='list_published' )}' target="_top">Published ${item_class_plural_name}</a> section so that it is not publicly listed or searchable.</div>
<br>
<input class="action-button" type="submit" name="disable_link_access_and_unpubish" value="Disable Access to ${item_class_name} via Link and Unpublish">
<div class="toolParamHelp">Disables ${item_class_name_lc}'s link so that it is not accessible and removes ${item_class_name_lc} from Galaxy's <a href='${h.url_for( action='list_published' )}' target='_top'>Published ${item_class_plural_name}</a> section so that it is not publicly listed or searchable.</div>
%endif
</form>
</div>
%else:
This ${item_class_name_lc} is currently restricted so that only you and the users listed below can access it. You can:
<p>
<form action="${h.url_for( action='sharing', id=trans.security.encode_id(item.id) )}" method="POST">
<input class="action-button" type="submit" name="make_accessible_via_link" value="Make ${item_class_name} Accessible via Link">
<div class="toolParamHelp">Generates a web link that you can share with other people so that they can view and import the ${item_class_name_lc}.</div>
<br>
<input class="action-button" type="submit" name="make_accessible_and_publish" value="Make ${item_class_name} Accessible and Publish" method="POST">
<div class="toolParamHelp">Makes the ${item_class_name_lc} accessible via link (see above) and publishes the ${item_class_name_lc} to Galaxy's <a href='${h.url_for( action='list_published' )}' target='_top'>Published ${item_class_plural_name}</a> section, where it is publicly listed and searchable.</div>
</form>
%endif
%endif
%endif
</div>
<h3>Sharing ${item_class_name} with Specific Users</h3>