Allow users to change the default permissions assigned to new datasets (not relying on input) for their current history.

This commit is contained in:
Daniel Blankenberg
2008-07-28 12:32:09 -04:00
parent 404d86d2ea
commit 9a010cc626
3 changed files with 87 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
from galaxy.web.base.controller import *
import logging
log = logging.getLogger( __name__ )
class HistoryController( BaseController ):
@web.expose
def index( self, trans, **kwd ):
raise 'Unimplemented'
@web.expose
def set_default_permissions( self, trans, **kwd ):
"""Sets the user's default permissions for the current history"""
#TODO: allow changing of default roles associated with history
if trans.user:
if 'set_permissions' in kwd:
"""The user clicked the set_permissions button on the set_permissions form"""
history = trans.get_history()
group_in = []
group_out = []
#collect groups as entered by user
for name, value in kwd.items():
if name.startswith( "group_" ):
group = trans.app.model.GalaxyGroup.get( name.replace( "group_", "", 1 ) )
if not group:
return trans.show_error_message( 'You have specified an invalid group.' )
if value == 'in':
group_in.append( group )
else:
group_out.append( group )
if not group_in:
return trans.show_error_message( "You must specify at least one default group." )
cur_groups = [ assoc.group for assoc in history.default_groups ]
group_in.sort()
cur_groups.sort()
if cur_groups != group_in:
history.set_default_access( groups = group_in )
return trans.show_ok_message( 'Default history permissions have been changed.' )
else:
return trans.show_error_message( "You did not specify any changes to this history's default permissions." )
return trans.fill_template( 'history/permissions.mako' )
else:
#user not logged in, history group must be only public
return trans.show_error_message( "You must be logged in to change a history's default permissions." )
+1
View File
@@ -18,6 +18,7 @@
%endif
%if app.config.enable_beta_features:
<li><a href="${h.url_for( controller='workflow', action='build_from_current_history' )}">Construct workflow</a> from the current history</li>
<li><a href="${h.url_for( controller='history', action='set_default_permissions' )}">Change default permissions</a> for the current history</li>
%endif
<li><a href="${h.url_for( action='history_share' )}" target="galaxy_main">Share</a> current history</div>
%endif
+42
View File
@@ -0,0 +1,42 @@
<%inherit file="/base.mako"/>
<%def name="title()">Change Default History Permissions</%def>
%if trans.user:
<div class="toolForm">
<div class="toolFormTitle">Change Default History Permissions</div>
<div class="toolFormBody">
<form name="set_permissions" method="post">
<div class="form-row">
<% user_groups = [ assoc.group for assoc in trans.user.groups ] %>
<% cur_groups = [ assoc.group for assoc in trans.get_history().default_groups ] %>
<div style="float: left; width: 250px; margin-right: 10px;">
<table>
<tr><th>Group</th><th>In</th><th>Out</th></tr>
%for group in user_groups:
<tr><td>${group.name}</td><td><input type="radio" name="group_${group.id}" value="in"
%if group in cur_groups:
checked
%endif
></td><td><input type="radio" name="group_${group.id}" value="out"
%if group not in cur_groups:
checked
%endif
></td></tr>
%endfor
</table>
</div>
<div style="clear: both"></div>
<div class="toolParamHelp" style="clear: both;">
This will change the default permissions assigned to new datasets for your current history.
</div>
<div style="clear: both"></div>
</div>
<div class="form-row">
<input type="submit" name="set_permissions" value="Save">
</div>
</form>
</div>
</div>
%endif