Standardize the interface for creating new groups and roles and for associating users, groups, roles by eliminating the checkbox approach.

This commit is contained in:
Greg Von Kuster
2009-01-12 15:40:05 -05:00
parent 20f4b501c2
commit 41bedcfac3
21 changed files with 773 additions and 1341 deletions
+20
View File
@@ -318,6 +318,26 @@ class GalaxyRBACAgent( RBACAgent ):
for user in users:
self.associate_components( user=user, role=sharing_role )
self.set_dataset_permission( dataset, { self.permitted_actions.DATASET_ACCESS : [ sharing_role ] } )
def set_entity_user_associations( self, users=[], roles=[], groups=[], delete_existing_assocs=True ):
for user in users:
if delete_existing_assocs:
for a in user.non_private_roles + user.groups:
a.delete()
a.flush()
for role in roles:
self.associate_components( user=user, role=role )
for group in groups:
self.associate_components( user=user, group=group )
def set_entity_group_associations( self, groups=[], users=[], roles=[], delete_existing_assocs=True ):
for group in groups:
if delete_existing_assocs:
for a in group.roles + group.users:
a.delete()
a.flush()
for role in roles:
self.associate_components( group=group, role=role )
for user in users:
self.associate_components( group=group, user=user )
def set_entity_role_associations( self, roles=[], users=[], groups=[], delete_existing_assocs=True ):
for role in roles:
if delete_existing_assocs:
+3
View File
@@ -85,6 +85,7 @@ mapped_chars = { '>' :'__gt__',
']' :'__cb__',
'{' :'__oc__',
'}' :'__cc__',
'@' : '__at__'
}
def restore_text(text):
@@ -273,6 +274,8 @@ def listify( item ):
return []
elif isinstance( item, list ):
return item
elif isinstance( item, str ) and item.count( ',' ):
return item.split( ',' )
else:
return [ item ]
File diff suppressed because it is too large Load Diff
@@ -26,7 +26,7 @@
<td>
<ul>
%for role in roles:
<li>${role.description}</li>
<li>${role.name}</li>
%endfor
</ul>
%if not anchored:
@@ -9,7 +9,7 @@
<tr>
%endif
<td>
${role.description}
${role.name}
<a id="role-${role.id}-popup" class="popup-arrow" style="display: none;">&#9660;</a>
<div popupmenu="role-${role.id}-popup">
<a class="action-button" href="${h.url_for( action='undelete_role', role_id=role.id )}">Undelete</a>
@@ -78,10 +78,10 @@
groups = role_tuple[1]
users = role_tuple[2]
%>
%if render_quick_find and not role.description.upper().startswith( curr_anchor ):
%if render_quick_find and not role.name.upper().startswith( curr_anchor ):
<% anchored = False %>
%endif
%if render_quick_find and role.description.upper().startswith( curr_anchor ):
%if render_quick_find and role.name.upper().startswith( curr_anchor ):
%if not anchored:
${render_row( role, groups, users, ctr, anchored, curr_anchor )}
<% anchored = True %>
@@ -90,7 +90,7 @@
%endif
%elif render_quick_find:
%for anchor in anchors[ anchor_loc: ]:
%if role.description.upper().startswith( anchor ):
%if role.name.upper().startswith( anchor ):
%if not anchored:
<% curr_anchor = anchor %>
${render_row( role, groups, users, ctr, anchored, curr_anchor )}
+72 -46
View File
@@ -1,57 +1,83 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
## Render a role
<%def name="render_role( group, role )">
<li>
%if role and not role.type == trans.app.model.Role.types.PRIVATE:
<a href="${h.url_for( action='role', role_id=role.id, edit=True )}">${role.description}</a>
<a id="role-${role.id}-popup" class="popup-arrow" style="display: none;">&#9660;</a>
<div popupmenu="role-${role.id}-popup">
<a class="action-button" href="${h.url_for( controller='admin', action='remove_role_from_group', group_id=group.id, role_id=role.id )}">Remove role from group</a>
</div>
%elif role:
${role.description}
%endif
</li>
<%def name="javascripts()">
${parent.javascripts()}
<script type="text/javascript">
$(function(){
$("input:text:first").focus();
})
</script>
</%def>
## Render a user
<%def name="render_user( group, user )">
<li>
<a href="${h.url_for( controller='admin', action='user', user_id=user.id )}">${user.email}</a>
<a id="user-${user.id}-popup" class="popup-arrow" style="display: none;">&#9660;</a>
<div popupmenu="user-${user.id}-popup">
<a class="action-button" href="${h.url_for( controller='admin', action='remove_user_from_group', user_id=user.id, group_id=group.id )}">Remove user from group</a>
</div>
</li>
<%def name="render_select( name, options )">
<select name="${name}" id="${name}" style="min-width: 250px; height: 150px;" multiple>
%for option in options:
<option value="${option[0]}">${option[1]}</option>
%endfor
</select>
</%def>
<script type="text/javascript">
$().ready(function() {
$('#roles_add_button').click(function() {
return !$('#out_roles option:selected').remove().appendTo('#in_roles');
});
$('#roles_remove_button').click(function() {
return !$('#in_roles option:selected').remove().appendTo('#out_roles');
});
$('#users_add_button').click(function() {
return !$('#out_users option:selected').remove().appendTo('#in_users');
});
$('#users_remove_button').click(function() {
return !$('#in_users option:selected').remove().appendTo('#out_users');
});
$('form#associate_group_role_user').submit(function() {
$('#in_roles option').each(function(i) {
$(this).attr("selected", "selected");
});
$('#in_users option').each(function(i) {
$(this).attr("selected", "selected");
});
});
});
</script>
%if msg:
${render_msg( msg, messagetype )}
%endif
%if len( users ) > 0 or len( roles ) > 0:
<table class="manage-table colored" border="0" cellspacing="0" cellpadding="0" width="100%">
<tr class="header">
<td>Users associated with ${group.name}</td>
<td>Roles associated with ${group.name}</td>
</tr>
<tr>
<td>
<ul>
%for user in users:
${render_user( group, user )}
%endfor
</ul>
</td>
<td>
<ul>
%for role in roles:
${render_role( group, role )}
%endfor
</ul>
</td>
</tr>
</table>
%endif
<div class="toolForm">
<div class="toolFormTitle">Group '${group.name}'</div>
<div class="toolFormBody">
<form name="associate_group_role_user" id="associate_group_role_user" action="${h.url_for( action='group', group_id=group.id )}" method="post" >
<div class="form-row">
<div style="float: left; margin-right: 10px;">
Roles associated with '${group.name}'<br/>
${render_select( "in_roles", in_roles )}<br/>
<input type="submit" id="roles_remove_button" value=">>"/>
</div>
<div>
Roles not associated with '${group.name}'<br/>
${render_select( "out_roles", out_roles )}<br/>
<input type="submit" id="roles_add_button" value="<<"/>
</div>
</div>
<div class="form-row">
<div style="float: left; margin-right: 10px;">
Users associated with '${group.name}'<br/>
${render_select( "in_users", in_users )}<br/>
<input type="submit" id="users_remove_button" value=">>"/>
</div>
<div>
Users not associated with '${group.name}'<br/>
${render_select( "out_users", out_users )}<br/>
<input type="submit" id="users_add_button" value="<<"/>
</div>
</div>
<div class="form-row">
<input type="submit" name="group_roles_users_edit_button" value="Save"/>
</div>
</form>
</div>
</div>
@@ -1,115 +1,86 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
## Render a user row
<%def name="render_user_row( user, ctr )">
%if ctr % 2 == 1:
<tr class="odd_row">
%else:
<tr>
%endif
<td><input type="checkbox" name="members" value="${user.id}"/> ${user.email}</td>
</tr>
<%def name="javascripts()">
${parent.javascripts()}
<script type="text/javascript">
$(function(){
$("input:text:first").focus();
})
</script>
</%def>
## Render a role row
<%def name="render_role_row( role, ctr, anchored, curr_anchor )">
%if ctr % 2 == 1:
<tr class="odd_row">
%else:
<tr>
%endif
<td>
%if not anchored:
<div style="float: right;"><a href="#TOP">top</a></div>
<a name="${curr_anchor}"><input type="checkbox" name="roles" value="${role.id}"/>&nbsp;${role.name}:&nbsp;${role.description}</a>
%else:
<input type="checkbox" name="roles" value="${role.id}"/>&nbsp;${role.name}:&nbsp;${role.description}
%endif
</td>
</tr>
<%def name="render_select( name, options )">
<select name="${name}" id="${name}" style="min-width: 250px; height: 150px;" multiple>
%for option in options:
<option value="${option[0]}">${option[1]}</option>
%endfor
</select>
</%def>
<a name="TOP"><h2>Create Group</h2></a>
<script type="text/javascript">
$().ready(function() {
$('#roles_add_button').click(function() {
return !$('#out_roles option:selected').remove().appendTo('#in_roles');
});
$('#roles_remove_button').click(function() {
return !$('#in_roles option:selected').remove().appendTo('#out_roles');
});
$('#users_add_button').click(function() {
return !$('#out_users option:selected').remove().appendTo('#in_users');
});
$('#users_remove_button').click(function() {
return !$('#in_users option:selected').remove().appendTo('#out_users');
});
$('form#associate_group_role_user').submit(function() {
$('#in_roles option').each(function(i) {
$(this).attr("selected", "selected");
});
$('#in_users option').each(function(i) {
$(this).attr("selected", "selected");
});
});
});
</script>
%if msg:
${render_msg( msg, messagetype )}
%endif
<form name="group_create" action="${h.url_for( controller='admin', action='new_group' )}" method="post" >
<table class="manage-table colored" border="0" cellspacing="0" cellpadding="0" width="100%">
<tr><td colspan="2">Name: <input name="name" type="textfield" value="" size=40"/></td></tr>
<%
render_quick_find = len( users ) > 50
ctr = 0
%>
%if render_quick_find:
<%
anchors = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
anchor_loc = 0
anchored = False
curr_anchor = 'A'
%>
<tr style="background: #EEE">
<td colspan="2" style="border-bottom: 1px solid #D8B365; text-align: center;">
Jump to letter:
%for a in anchors:
| <a href="#${a}">${a}</a>
%endfor
</td>
</tr>
%endif
<tr class="header">
<td>Select to add users to group</td>
<td>Select to associate roles with group</td>
</tr>
<tr>
## Render users
<td valign="top">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
%for ctr, user in enumerate( users ):
${render_user_row( user, ctr )}
%endfor
</table>
</td>
## Render roles
<td valign="top">
<% curr_anchor = 'A' %>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
%for ctr, role in enumerate( roles ):
%if render_quick_find and not role.description.upper().startswith( curr_anchor ):
<% anchored = False %>
%endif
%if render_quick_find and role.description.upper().startswith( curr_anchor ):
%if not anchored:
${render_role_row( role, ctr, anchored, curr_anchor )}
<% anchored = True %>
%else:
${render_role_row( role, ctr, anchored, curr_anchor )}
%endif
%elif render_quick_find:
%for anchor in anchors[ anchor_loc: ]:
%if role.description.upper().startswith( anchor ):
%if not anchored:
<% curr_anchor = anchor %>
${render_role_row( role, ctr, anchored, curr_anchor )}
<% anchored = True %>
%else:
${render_role_row( role, ctr, anchored, curr_anchor )}
%endif
<%
anchor_loc = anchors.index( anchor )
break
%>
%endif
%endfor
%else:
${render_role_row( role, ctr, True, '' )}
%endif
%endfor
</table>
</td>
</tr>
<tr><td colspan="2"><input type="submit" name="create_group_button" value="Create"/></td></tr>
</table>
</form>
<div class="toolForm">
<div class="toolFormTitle">Create Role</div>
<div class="toolFormBody">
<form name="associate_group_role_user" id="associate_group_role_user" action="${h.url_for( action='create_group' )}" method="post" >
<div class="form-row">
Name: <input name="name" type="textfield" value="" size=40"/>
</div>
<div class="form-row">
<div style="float: left; margin-right: 10px;">
Groups associated with new role<br/>
${render_select( "in_roles", in_roles )}<br/>
<input type="submit" id="roles_remove_button" value=">>"/>
</div>
<div>
Groups not associated with new role<br/>
${render_select( "out_roles", out_roles )}<br/>
<input type="submit" id="roles_add_button" value="<<"/>
</div>
</div>
<div class="form-row">
<div style="float: left; margin-right: 10px;">
Users associated with new role<br/>
${render_select( "in_users", in_users )}<br/>
<input type="submit" id="users_remove_button" value=">>"/>
</div>
<div>
Users not associated with new role<br/>
${render_select( "out_users", out_users )}<br/>
<input type="submit" id="users_add_button" value="<<"/>
</div>
</div>
<div class="form-row">
<input type="submit" name="create_group_button" value="Save"/>
</div>
</form>
</div>
</div>
@@ -1,101 +0,0 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
## Render a row
<%def name="render_row( user, ctr, anchored, curr_anchor, check )">
%if ctr % 2 == 1:
<tr class="odd_row">
%else:
<tr>
%endif
<td>
%if check:
<input type="checkbox" name="members" value="${user.id}" checked/> ${user.email}
%else:
<input type="checkbox" name="members" value="${user.id}"/> ${user.email}
%endif
%if not anchored:
<a name="${curr_anchor}"></a>
<div style="float: right;"><a href="#TOP">top</a></div>
%endif
</td>
</tr>
</%def>
<a name="TOP">&nbsp;</a>
%if msg:
${render_msg( msg, messagetype )}
%endif
%if len( users ) == 0:
<tr><td>There are no Galaxy users</td></tr>
%else:
<form name="group_members_edit" action="${h.url_for( controller='admin', action='group_members_edit' )}" method="post" >
<input type="hidden" name="group_id" value="${group.id}" />
<table class="manage-table colored" border="0" cellspacing="0" cellpadding="0" width="100%">
<%
render_quick_find = len( users ) > 50
ctr = 0
%>
%if render_quick_find:
<%
anchors = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
anchor_loc = 0
anchored = False
curr_anchor = 'A'
%>
<tr style="background: #EEE">
<td colspan="3" style="border-bottom: 1px solid #D8B365; text-align: center;">
Jump to letter:
%for a in anchors:
| <a href="#${a}">${a}</a>
%endfor
</td>
</tr>
%endif
<tr class="header"><td>Select to add user to ${group.name}</td></tr>
%for ctr, user in enumerate( users ):
<% check = False %>
%for member in members:
%if member.email == user.email:
<%
check = True
break
%>
%endif
%endfor
%if render_quick_find and not user.email.upper().startswith( curr_anchor ):
<% anchored = False %>
%endif
%if render_quick_find and user.email.upper().startswith( curr_anchor ):
%if not anchored:
${render_row( user, ctr, anchored, curr_anchor, check )}
<% anchored = True %>
%else:
${render_row( user, ctr, anchored, curr_anchor, check )}
%endif
%elif render_quick_find:
%for anchor in anchors[ anchor_loc: ]:
%if user.email.upper().startswith( anchor ):
%if not anchored:
<% curr_anchor = anchor %>
${render_row( user, ctr, anchored, curr_anchor, check )}
<% anchored = True %>
%else:
${render_row( user, ctr, anchored, curr_anchor, check )}
%endif
<%
anchor_loc = anchors.index( anchor )
break
%>
%endif
%endfor
%else:
${render_row( user, ctr, True, '', check )}
%endif
%endfor
<tr><td><input type="submit" name="group_members_edit_button" value="Add selected users to group"/></td></tr>
</table>
</form>
%endif
@@ -1,110 +0,0 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
## Render a row
<%def name="render_row( role, ctr, anchored, curr_anchor, check )">
%if ctr % 2 == 1:
<tr class="odd_row">
%else:
<tr>
%endif
<td>
%if check:
<input type="checkbox" name="roles" value="${role.id}" checked/> ${role.name}
%else:
<input type="checkbox" name="roles" value="${role.id}"/> ${role.name}
%endif
</td>
<td>${role.description}</td>
<td>
${role.type}
%if not anchored:
<a name="${curr_anchor}"></a>
<div style="float: right;"><a href="#TOP">top</a></div>
%endif
</td>
</tr>
</%def>
<a name="TOP">&nbsp;</a>
%if msg:
${render_msg( msg, messagetype )}
%endif
%if len( roles ) == 0:
<tr><td>There are no Galaxy roles</td></tr>
%else:
<form name="group_roles_edit" action="${h.url_for( controller='admin', action='group_roles_edit' )}" method="post" >
<input type="hidden" name="group_id" value="${group.id}" />
<table class="manage-table colored" border="0" cellspacing="0" cellpadding="0" width="100%">
<%
render_quick_find = len( roles ) > 50
ctr = 0
%>
%if render_quick_find:
<%
anchors = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
anchor_loc = 0
anchored = False
curr_anchor = 'A'
%>
<tr style="background: #EEE">
<td style="border-bottom: 1px solid #D8B365; text-align: center;">
Jump to letter:
%for a in anchors:
| <a href="#${a}">${a}</a>
%endfor
</td>
</tr>
%endif
<tr class="header">
<td>Select to associate role with ${group.name}</td>
<td>Description</td>
<td>Role Type</td>
</tr>
%for ctr, role in enumerate( roles ):
<% check = False %>
%for group_role in group_roles:
%if group_role.name == role.name:
<%
check = True
break
%>
%endif
%endfor
%if render_quick_find and not role.description.upper().startswith( curr_anchor ):
<% anchored = False %>
%endif
%if render_quick_find and role.description.upper().startswith( curr_anchor ):
%if not anchored:
${render_row( role, ctr, anchored, curr_anchor, check )}
<% anchored = True %>
%else:
${render_row( role, ctr, anchored, curr_anchor, check )}
%endif
%elif render_quick_find:
%for anchor in anchors[ anchor_loc: ]:
%if role.description.upper().startswith( anchor ):
%if not anchored:
<% curr_anchor = anchor %>
${render_row( role, ctr, anchored, curr_anchor, check )}
<% anchored = True %>
%else:
${render_row( role, ctr, anchored, curr_anchor, check )}
%endif
<%
anchor_loc = anchors.index( anchor )
break
%>
%endif
%endfor
%else:
${render_row( role, ctr, True, '', check )}
%endif
%endfor
<tr><td><input type="submit" name="group_roles_edit_button" value="Update role associations" /></td></tr>
</table>
</form>
%endif
+14 -5
View File
@@ -13,15 +13,20 @@
<a id="group-${group.id}-popup" class="popup-arrow" style="display: none;">&#9660;</a>
<div popupmenu="group-${group.id}-popup">
<a class="action-button" href="${h.url_for( controller='admin', action='group', rename=True, group_id=group.id )}">Rename this group</a>
<a class="action-button" href="${h.url_for( controller='admin', action='group_members_edit', group_id=group.id )}">Change associated users</a>
<a class="action-button" href="${h.url_for( controller='admin', action='group_roles_edit', group_id=group.id )}">Change associated roles</a>
<a class="action-button" href="${h.url_for( controller='admin', action='group', group_id=group.id )}">Change associated users and roles</a>
<a class="action-button" href="${h.url_for( controller='admin', action='mark_group_deleted', group_id=group.id )}">Mark group deleted</a>
</div>
</td>
<td>
<ul>
%for user in members:
<li><a href="${h.url_for( controller='admin', action='user', user_id=user.id )}">${user.email}</a></li>
<li>
<a href="${h.url_for( controller='admin', action='user', user_id=user.id )}">${user.email}</a>
<a id="user-${user.id}-popup" class="popup-arrow" style="display: none;">&#9660;</a>
<div popupmenu="user-${user.id}-popup">
<a class="action-button" href="${h.url_for( controller='admin', action='remove_user_from_group', group_id=group.id, user_id=user.id )}">Remove user from group</a>
</div>
</li>
%endfor
</ul>
</td>
@@ -30,9 +35,13 @@
%for role in roles:
<li>
%if not role.type == trans.app.model.Role.types.PRIVATE:
<a href="${h.url_for( controller='admin', action='role', role_id=role.id )}">${role.description}</a>
<a href="${h.url_for( controller='admin', action='role', role_id=role.id )}">${role.name}</a>
<a id="role-${role.id}-popup" class="popup-arrow" style="display: none;">&#9660;</a>
<div popupmenu="role-${role.id}-popup">
<a class="action-button" href="${h.url_for( controller='admin', action='remove_role_from_group', group_id=group.id, role_id=role.id )}">Remove role from group</a>
</div>
%else:
${role.description}
${role.name}
%endif
</li>
%endfor
+75 -106
View File
@@ -1,118 +1,87 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
## Render a user row
<%def name="render_user_row( user, ctr )">
%if ctr % 2 == 1:
<tr class="odd_row">
%else:
<tr>
%endif
<td><input type="checkbox" name="users" value="${user.id}"/> ${user.email}</td>
</tr>
<%def name="javascripts()">
${parent.javascripts()}
<script type="text/javascript">
$(function(){
$("input:text:first").focus();
})
</script>
</%def>
## Render a group row
<%def name="render_group_row( group, ctr, anchored, curr_anchor )">
%if ctr % 2 == 1:
<tr class="odd_row">
%else:
<tr>
%endif
<td>
%if not anchored:
<div style="float: right;"><a href="#TOP">top</a></div>
<a name="${curr_anchor}"><input type="checkbox" name="groups" value="${group.id}"/> ${group.name}</a>
%else:
<input type="checkbox" name="groups" value="${group.id}"/> ${group.name}
%endif
</td>
</tr>
<%def name="render_select( name, options )">
<select name="${name}" id="${name}" style="min-width: 250px; height: 150px;" multiple>
%for option in options:
<option value="${option[0]}">${option[1]}</option>
%endfor
</select>
</%def>
<a name="TOP"><h2>Create Role</h2></a>
<script type="text/javascript">
$().ready(function() {
$('#groups_add_button').click(function() {
return !$('#out_groups option:selected').remove().appendTo('#in_groups');
});
$('#groups_remove_button').click(function() {
return !$('#in_groups option:selected').remove().appendTo('#out_groups');
});
$('#users_add_button').click(function() {
return !$('#out_users option:selected').remove().appendTo('#in_users');
});
$('#users_remove_button').click(function() {
return !$('#in_users option:selected').remove().appendTo('#out_users');
});
$('form#associate_role_group_user').submit(function() {
$('#in_groups option').each(function(i) {
$(this).attr("selected", "selected");
});
$('#in_users option').each(function(i) {
$(this).attr("selected", "selected");
});
});
});
</script>
%if msg:
${render_msg( msg, messagetype )}
%endif
<form name="role_create" action="${h.url_for( controller='admin', action='new_role' )}" method="post" >
<table class="manage-table colored" border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td>Name: <input name="name" type="textfield" value="" size=40"/></td>
<td>Description: <input name="description" type="textfield" value="" size=40"/></td>
</tr>
<%
render_quick_find = len( users ) > 50
ctr = 0
%>
%if render_quick_find:
<%
anchors = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
anchor_loc = 0
anchored = False
curr_anchor = 'A'
%>
<tr style="background: #EEE">
<td colspan="2" style="border-bottom: 1px solid #D8B365; text-align: center;">
Jump to letter:
%for a in anchors:
| <a href="#${a}">${a}</a>
%endfor
</td>
</tr>
%endif
<tr class="header">
<td>Select to associate users with role</td>
<td>Select to associate groups with role</td>
</tr>
<tr>
## Render users
<td valign="top">
<table border="0" cellspacing="0" cellpadding="0" width="100%">
%for ctr, user in enumerate( users ):
${render_user_row( user, ctr )}
%endfor
</table>
</td>
## Render roles
<td valign="top">
<% curr_anchor = 'A' %>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
%for ctr, group in enumerate( groups ):
%if render_quick_find and not group.name.upper().startswith( curr_anchor ):
<% anchored = False %>
%endif
%if render_quick_find and group.name.upper().startswith( curr_anchor ):
%if not anchored:
${render_group_row( group, ctr, anchored, curr_anchor )}
<% anchored = True %>
%else:
${render_group_row( group, ctr, anchored, curr_anchor )}
%endif
%elif render_quick_find:
%for anchor in anchors[ anchor_loc: ]:
%if group.name.upper().startswith( anchor ):
%if not anchored:
<% curr_anchor = anchor %>
${render_group_row( group, ctr, anchored, curr_anchor )}
<% anchored = True %>
%else:
${render_group_row( group, ctr, anchored, curr_anchor )}
%endif
<%
anchor_loc = anchors.index( anchor )
break
%>
%endif
%endfor
%else:
${render_group_row( group, ctr, True, '' )}
%endif
%endfor
</table>
</td>
</tr>
<tr><td colspan="2"><input type="submit" name="create_role_button" value="Create"/></td></tr>
</table>
</form>
<div class="toolForm">
<div class="toolFormTitle">Create Role</div>
<div class="toolFormBody">
<form name="associate_role_group_user" id="associate_role_group_user" action="${h.url_for( action='create_role' )}" method="post" >
<div class="form-row">
Name: <input name="name" type="textfield" value="" size=40"/>
Description: <input name="description" type="textfield" value="" size=40"/>
</div>
<div class="form-row">
<div style="float: left; margin-right: 10px;">
Groups associated with new role<br/>
${render_select( "in_groups", in_groups )}<br/>
<input type="submit" id="groups_remove_button" value=">>"/>
</div>
<div>
Groups not associated with new role<br/>
${render_select( "out_groups", out_groups )}<br/>
<input type="submit" id="groups_add_button" value="<<"/>
</div>
</div>
<div class="form-row">
<div style="float: left; margin-right: 10px;">
Users associated with new role<br/>
${render_select( "in_users", in_users )}<br/>
<input type="submit" id="users_remove_button" value=">>"/>
</div>
<div>
Users not associated with new role<br/>
${render_select( "out_users", out_users )}<br/>
<input type="submit" id="users_add_button" value="<<"/>
</div>
</div>
<div class="form-row">
<input type="submit" name="create_role_button" value="Save"/>
</div>
</form>
</div>
</div>
+1 -1
View File
@@ -9,7 +9,7 @@
<tr>
%endif
<td>
${role.name}
<a href="${h.url_for( controller='admin', action='role', role_id=role.id )}">${role.name}</a>
<a id="role-${role.id}-popup" class="popup-arrow" style="display: none;">&#9660;</a>
<div popupmenu="role-${role.id}-popup">
<a class="action-button" href="${h.url_for( controller='admin', action='role', rename=True, role_id=role.id )}">Rename this role</a>
+72 -46
View File
@@ -1,57 +1,83 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
## Render a role
<%def name="render_role( user, role )">
<li>
%if role and not role.type == trans.app.model.Role.types.PRIVATE:
<a href="${h.url_for( action='role', role_id=role.id, edit=True )}">${role.description}</a>
<a id="role-${role.id}-popup" class="popup-arrow" style="display: none;">&#9660;</a>
<div popupmenu="role-${role.id}-popup">
<a class="action-button" href="${h.url_for( controller='admin', action='remove_user_from_role', user_id=user.id, role_id=role.id )}">Remove user from role</a>
</div>
%elif role:
${role.description}
%endif
</li>
<%def name="javascripts()">
${parent.javascripts()}
<script type="text/javascript">
$(function(){
$("input:text:first").focus();
})
</script>
</%def>
## Render a group
<%def name="render_group( user, group )">
<li>
<a href="${h.url_for( controller='admin', action='group_members_edit', group_id=group.id )}">${group.name}</a>
<a id="group-${group.id}-popup" class="popup-arrow" style="display: none;">&#9660;</a>
<div popupmenu="group-${group.id}-popup">
<a class="action-button" href="${h.url_for( controller='admin', action='remove_user_from_group', user_id=user.id, group_id=group.id )}">Remove user from group</a>
</div>
</li>
<%def name="render_select( name, options )">
<select name="${name}" id="${name}" style="min-width: 250px; height: 150px;" multiple>
%for option in options:
<option value="${option[0]}">${option[1]}</option>
%endfor
</select>
</%def>
<script type="text/javascript">
$().ready(function() {
$('#roles_add_button').click(function() {
return !$('#out_roles option:selected').remove().appendTo('#in_roles');
});
$('#roles_remove_button').click(function() {
return !$('#in_roles option:selected').remove().appendTo('#out_roles');
});
$('#groups_add_button').click(function() {
return !$('#out_groups option:selected').remove().appendTo('#in_groups');
});
$('#groups_remove_button').click(function() {
return !$('#in_groups option:selected').remove().appendTo('#out_groups');
});
$('form#associate_user_role_group').submit(function() {
$('#in_roles option').each(function(i) {
$(this).attr("selected", "selected");
});
$('#in_groups option').each(function(i) {
$(this).attr("selected", "selected");
});
});
});
</script>
%if msg:
${render_msg( msg, messagetype )}
%endif
%if len( groups ) > 0 or len( roles ) > 0:
<table class="manage-table colored" border="0" cellspacing="0" cellpadding="0" width="100%">
<tr class="header">
<td>Groups of which ${user.email} is a member</td>
<td>Roles associated with ${user.email}</td>
</tr>
<tr>
<td>
<ul>
%for group in groups:
${render_group( user, group )}
%endfor
</ul>
</td>
<td>
<ul>
%for role in roles:
${render_role( user, role )}
%endfor
</ul>
</td>
</tr>
</table>
%endif
<div class="toolForm">
<div class="toolFormTitle">User '${user.email}'</div>
<div class="toolFormBody">
<form name="associate_user_role_group" id="associate_user_role_group" action="${h.url_for( action='user', user_id=user.id )}" method="post" >
<div class="form-row">
<div style="float: left; margin-right: 10px;">
Roles associated with '${user.email}'<br/>
${render_select( "in_roles", in_roles )}<br/>
<input type="submit" id="roles_remove_button" value=">>"/>
</div>
<div>
Roles not associated with '${user.email}'<br/>
${render_select( "out_roles", out_roles )}<br/>
<input type="submit" id="roles_add_button" value="<<"/>
</div>
</div>
<div class="form-row">
<div style="float: left; margin-right: 10px;">
Groups associated with '${user.email}'<br/>
${render_select( "in_groups", in_groups )}<br/>
<input type="submit" id="groups_remove_button" value=">>"/>
</div>
<div>
Groups not associated with '${user.email}'<br/>
${render_select( "out_groups", out_groups )}<br/>
<input type="submit" id="groups_add_button" value="<<"/>
</div>
</div>
<div class="form-row">
<input type="submit" name="user_roles_groups_edit_button" value="Save"/>
</div>
</form>
</div>
</div>
@@ -1,100 +0,0 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
## Render a row
<%def name="render_row( group, ctr, anchored, curr_anchor, check )">
%if ctr % 2 == 1:
<tr class="odd_row">
%else:
<tr>
%endif
<td>
%if check:
<input type="checkbox" name="groups" value="${group.id}" checked/> ${group.name}
%else:
<input type="checkbox" name="groups" value="${group.id}"/> ${group.name}
%endif
%if not anchored:
<a name="${curr_anchor}"></a>
<div style="float: right;"><a href="#TOP">top</a></div>
%endif
</td>
</tr>
</%def>
<a name="TOP">&nbsp;</a>
%if msg:
${render_msg( msg, messagetype )}
%endif
%if len( groups ) == 0:
<tr><td>There are no Galaxy groups</td></tr>
%else:
<form name="update_user_groups" action="${h.url_for( controller='admin', action='update_user_groups', user_id=user.id )}" method="post" >
<table class="manage-table colored" border="0" cellspacing="0" cellpadding="0" width="100%">
<%
render_quick_find = len( groups ) > 50
ctr = 0
%>
%if render_quick_find:
<%
anchors = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
anchor_loc = 0
anchored = False
curr_anchor = 'A'
%>
<tr style="background: #EEE">
<td colspan="3" style="border-bottom: 1px solid #D8B365; text-align: center;">
Jump to letter:
%for a in anchors:
| <a href="#${a}">${a}</a>
%endfor
</td>
</tr>
%endif
<tr class="header"><td>Select to add ${user.email} to group</td></tr>
%for ctr, group in enumerate( groups ):
<% check = False %>
%for user_group in user_groups:
%if user_group.id == group.id:
<%
check = True
break
%>
%endif
%endfor
%if render_quick_find and not group.name.upper().startswith( curr_anchor ):
<% anchored = False %>
%endif
%if render_quick_find and group.name.upper().startswith( curr_anchor ):
%if not anchored:
${render_row( group, ctr, anchored, curr_anchor, check )}
<% anchored = True %>
%else:
${render_row( group, ctr, anchored, curr_anchor, check )}
%endif
%elif render_quick_find:
%for anchor in anchors[ anchor_loc: ]:
%if group.name.upper().startswith( anchor ):
%if not anchored:
<% curr_anchor = anchor %>
${render_row( group, ctr, anchored, curr_anchor, check )}
<% anchored = True %>
%else:
${render_row( group, ctr, anchored, curr_anchor, check )}
%endif
<%
anchor_loc = anchors.index( anchor )
break
%>
%endif
%endfor
%else:
${render_row( group, ctr, True, '', check )}
%endif
%endfor
<tr><td><input type="submit" name="user_groups_edit_button" value="Add user to selected groups" /></td></tr>
</table>
</form>
%endif
@@ -1,101 +0,0 @@
<%inherit file="/base.mako"/>
<%namespace file="/message.mako" import="render_msg" />
## Render a row
<%def name="render_row( role, ctr, anchored, curr_anchor, check )">
%if ctr % 2 == 1:
<tr class="odd_row">
%else:
<tr>
%endif
<td>
%if check:
<input type="checkbox" name="roles" value="${role.id}" checked/> ${role.name}
%else:
<input type="checkbox" name="roles" value="${role.id}"/> ${role.name}
%endif
%if not anchored:
<a name="${curr_anchor}"></a>
<div style="float: right;"><a href="#TOP">top</a></div>
%endif
</td>
</tr>
</%def>
<a name="TOP">&nbsp;</a>
%if msg:
${render_msg( msg, messagetype )}
%endif
%if len( roles ) == 0:
<tr><td>There are no Galaxy roles</td></tr>
%else:
<form name="user_roles_edit" action="${h.url_for( controller='admin', action='user_roles_edit' )}" method="post" >
<input type="hidden" name="user_id" value="${user.id}" />
<table class="manage-table colored" border="0" cellspacing="0" cellpadding="0" width="100%">
<%
render_quick_find = len( roles ) > 50
ctr = 0
%>
%if render_quick_find:
<%
anchors = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
anchor_loc = 0
anchored = False
curr_anchor = 'A'
%>
<tr style="background: #EEE">
<td colspan="3" style="border-bottom: 1px solid #D8B365; text-align: center;">
Jump to letter:
%for a in anchors:
| <a href="#${a}">${a}</a>
%endfor
</td>
</tr>
%endif
<tr class="header"><td>Select to associate role with ${user.email}</td></tr>
%for ctr, role in enumerate( roles ):
<% check = False %>
%for user_role in user_roles:
%if user_role.id == role.id:
<%
check = True
break
%>
%endif
%endfor
%if render_quick_find and not role.name.upper().startswith( curr_anchor ):
<% anchored = False %>
%endif
%if render_quick_find and role.name.upper().startswith( curr_anchor ):
%if not anchored:
${render_row( role, ctr, anchored, curr_anchor, check )}
<% anchored = True %>
%else:
${render_row( role, ctr, anchored, curr_anchor, check )}
%endif
%elif render_quick_find:
%for anchor in anchors[ anchor_loc: ]:
%if role.name.upper().startswith( anchor ):
%if not anchored:
<% curr_anchor = anchor %>
${render_row( role, ctr, anchored, curr_anchor, check )}
<% anchored = True %>
%else:
${render_row( role, ctr, anchored, curr_anchor, check )}
%endif
<%
anchor_loc = anchors.index( anchor )
break
%>
%endif
%endfor
%else:
${render_row( role, ctr, True, '', check )}
%endif
%endfor
<tr><td><input type="submit" name="user_roles_edit_button" value="Associate user with selected roles" /></td></tr>
</table>
</form>
%endif
+15 -4
View File
@@ -13,8 +13,7 @@
<a id="user-${user.id}-popup" class="popup-arrow" style="display: none;">&#9660;</a>
<div popupmenu="user-${user.id}-popup">
<a class="action-button" href="${h.url_for( action='reset_user_password', user_id=user.id )}">Reset password</a>
<a class="action-button" href="${h.url_for( action='user_groups_edit', user_id=user.id )}">Change associated groups</a>
<a class="action-button" href="${h.url_for( action='user_roles_edit', user_id=user.id )}">Change associated roles</a>
<a class="action-button" href="${h.url_for( controller='admin', action='user', user_id=user.id )}">Change associated groups and roles</a>
%if allow_user_deletion:
<a class="action-button" href="${h.url_for( action='mark_user_deleted', user_id=user.id )}">Mark user deleted</a>
%endif
@@ -23,14 +22,26 @@
<td>
<ul>
%for group in groups:
<li><a href="${h.url_for( controller='admin', action='group', group_id=group.id )}">${group.name}</a></li>
<li>
<a href="${h.url_for( controller='admin', action='group', group_id=group.id )}">${group.name}</a>
<a id="group-${group.id}-popup" class="popup-arrow" style="display: none;">&#9660;</a>
<div popupmenu="group-${group.id}-popup">
<a class="action-button" href="${h.url_for( controller='admin', action='remove_group_from_user', user_id=user.id, group_id=group.id )}">Remove group from user</a>
</div>
</li>
%endfor
</ul>
</td>
<td>
<ul>
%for role in roles:
<li><a href="${h.url_for( controller='admin', action='role', role_id=role.id )}">${role.description}</a></li>
<li>
<a href="${h.url_for( controller='admin', action='role', role_id=role.id )}">${role.name}</a>
<a id="role-${role.id}-popup" class="popup-arrow" style="display: none;">&#9660;</a>
<div popupmenu="role-${role.id}-popup">
<a class="action-button" href="${h.url_for( controller='admin', action='remove_role_from_user', user_id=user.id, role_id=role.id )}">Remove role from user</a>
</div>
</li>
%endfor
</ul>
%if not anchored:
+1 -1
View File
@@ -93,7 +93,7 @@
<label>Restrict dataset access to specific roles:</label>
<select name="roles" multiple="true" size="5">
%for role in roles:
<option value="${role.id}">${role.description}</option>
<option value="${role.id}">${role.name}</option>
%endfor
</select>
</div>
+1 -1
View File
@@ -180,7 +180,7 @@
<li>${action.description}</li>
<ul>
%for role in roles:
<li>${role.description}</li>
<li>${role.name}</li>
%endfor
</ul>
%endif
+2 -2
View File
@@ -12,7 +12,7 @@
Roles associated:<br/>
<select name="${action_key}_in" id="${action_key}_in_select" class="in_select" style="max-width: 98%; width: 98%; height: 150px; font-size: 100%;" multiple>
%for role in in_roles:
<option value="${role.id}">${role.description}</option>
<option value="${role.id}">${role.name}</option>
%endfor
</select> <br/>
<div style="width: 98%; text-align: right"><input type="submit" id="${action_key}_remove_button" class="role_remove_button" value=">>"/></div>
@@ -21,7 +21,7 @@
Roles not associated:<br/>
<select name="${action_key}_out" id="${action_key}_out_select" style="max-width: 98%; width: 98%; height: 150px; font-size: 100%;" multiple>
%for role in out_roles:
<option value="${role.id}">${role.description}</option>
<option value="${role.id}">${role.name}</option>
%endfor
</select> <br/>
<input type="submit" id="${action_key}_add_button" class="role_add_button" value="<<"/>
+95 -127
View File
@@ -626,56 +626,51 @@ class TwillTestCase( unittest.TestCase ):
tc.submit( "reset_user_password_button" )
self.check_page_for_string( "Password reset" )
self.home()
def mark_user_deleted( self, user_id=4 ):
def mark_user_deleted( self, user_id=4, email='' ):
"""Mark a user as deleted"""
self.home()
self.visit_url( "%s/admin/mark_user_deleted?user_id=%s" % ( self.url, str( user_id ) ) )
self.check_page_for_string( "The user has been marked as deleted." )
check_str = "User '%s' has been marked as deleted." % email
self.check_page_for_string( check_str )
self.home()
def undelete_user( self, user_id ):
def undelete_user( self, user_id=4, email='' ):
"""Undelete a user"""
self.home()
self.visit_url( "%s/admin/undelete_user?user_id=%s" % ( self.url, user_id ) )
self.check_page_for_string( 'The user has been marked as not deleted' )
check_str = "User '%s' has been marked as not deleted" % email
self.check_page_for_string( check_str )
self.home()
def purge_user( self, user_id ):
def purge_user( self, user_id, email ):
"""Purge a user account"""
self.home()
self.visit_url( "%s/admin/purge_user?user_id=%s" % ( self.url, user_id ) )
self.check_page_for_string( 'The user has been marked as purged.' )
check_str = "User '%s' has been marked as purged." % email
self.check_page_for_string( check_str )
self.home()
def user_roles_edit( self, user_id, role_ids=[] ):
"""Change roles associated with an existing user"""
def associate_roles_and_groups_with_user( self, user_id, email, role_ids=[], group_ids=[] ):
self.home()
self.visit_url( "%s/admin/user_roles_edit?user_id=%s" % ( self.url, user_id ) )
self.check_page_for_string( 'Select to associate role with' )
for role_id in role_ids:
tc.fv( "1", "roles", role_id )
tc.submit( "user_roles_edit_button" )
self.check_page_for_string( 'User updated with a total of' )
url = "%s/admin/user?user_id=%s&user_roles_groups_edit_button=Save" % ( self.url, user_id )
if role_ids:
url += "&in_roles=%s" % ','.join( role_ids )
if group_ids:
url += "&in_groups=%s" % ','.join( group_ids )
self.visit_url( url )
check_str = "User '%s' has been updated with %d associated roles and %d associated groups" % ( email, len( role_ids ), len( group_ids ) )
self.check_page_for_string( check_str )
self.home()
# Tests associated with roles
def create_role( self, name='Role One', description="This is Role One", user_ids=[], group_ids=[], private_role='' ):
def create_role( self, name='Role One', description="This is Role One", in_user_ids=[], in_group_ids=[], private_role='' ):
"""Create a new role"""
url = "%s/admin/create_role?create_role_button=Save&name=%s&description=%s" % ( self.url, name.replace( ' ', '+' ), description.replace( ' ', '+' ) )
if in_user_ids:
url += "&in_users=%s" % ','.join( in_user_ids )
if in_group_ids:
url += "&in_groups=%s" % ','.join( in_group_ids )
self.home()
self.visit_url( "%s/admin/create_role" % self.url )
self.check_page_for_string( "Create Role" )
tc.fv( "1", "name", name )
tc.fv( "1", "description", description )
for user_id in user_ids:
tc.fv( "1", "users", user_id )
for group_id in group_ids:
tc.fv( "1", "groups", group_id )
tc.submit( "create_role_button" )
check_str = "The new role has been created with %s associated users and %s associated groups" % ( str( len( user_ids ) ), str( len( group_ids ) ) )
try:
self.check_page_for_string( check_str )
previously_created = False
except:
# The role may have been created on a previous test run
self.check_page_for_string( "A role with that name already exists" )
previously_created = True
self.visit_url( url )
check_str = "Role '%s' has been created with %d associated users and %d associated groups" % ( name, len( in_user_ids ), len( in_group_ids ) )
self.check_page_for_string( check_str )
if private_role:
# Make sure no private roles are displayed
try:
@@ -686,10 +681,9 @@ class TwillTestCase( unittest.TestCase ):
# Reaching here is the behavior we want since no private roles should be displayed
pass
self.home()
self.visit_page( "admin/roles" )
self.check_page_for_string( description )
self.visit_url( "%s/admin/roles" % self.url )
self.check_page_for_string( name )
self.home()
return previously_created
def rename_role( self, role_id, name='Role One Renamed', description='This is Role One Re-described' ):
"""Rename a role"""
self.home()
@@ -699,82 +693,56 @@ class TwillTestCase( unittest.TestCase ):
tc.fv( "1", "description", description )
tc.submit( "rename_role_button" )
self.home()
def mark_role_deleted( self, role_id ):
def mark_role_deleted( self, role_id, role_name ):
"""Mark a role as deleted"""
self.home()
self.visit_url( "%s/admin/mark_role_deleted?role_id=%s" % ( self.url, role_id ) )
self.check_page_for_string( 'The role has been marked as deleted' )
check_str = "Role '%s' has been marked as deleted" % role_name
self.check_page_for_string( check_str )
self.home()
def undelete_role( self, role_id ):
def undelete_role( self, role_id, role_name ):
"""Undelete an existing role"""
self.home()
self.visit_url( "%s/admin/undelete_role?role_id=%s" % ( self.url, role_id ) )
self.check_page_for_string( 'The role has been marked as not deleted' )
check_str = "Role '%s' has been marked as not deleted" % role_name
self.check_page_for_string( check_str )
self.home()
def purge_role( self, role_id ):
def purge_role( self, role_id, role_name ):
"""Purge an existing role"""
self.home()
self.visit_url( "%s/admin/purge_role?role_id=%s" % ( self.url, role_id ) )
check_str = "The following have been purged from the database for the role: "
check_str = "The following have been purged from the database for role '%s': " % role_name
check_str += "DefaultUserPermissions, DefaultHistoryPermissions, UserRoleAssociations, GroupRoleAssociations, ActionDatasetRoleAssociations."
self.check_page_for_string( check_str )
self.home()
def associate_groups_with_role( self, role_id, group_names=[] ):
"""Add groups to an existing role"""
# NOTE: To get this to work with twill, all select lists must contain at least 1 option value
# before tc.submit or twill throws an exception, which is: ParseError: OPTION outside of SELECT
def associate_users_and_groups_with_role( self, role_id, role_name, user_ids=[], group_ids=[] ):
self.home()
self.visit_url( "%s/admin/role?role_id=%s" % ( self.url, role_id ) )
self.check_page_for_string( 'Groups associated with' )
# All group_ids passed in MUST be in the out_groups form field
for group_name in group_names:
tc.fv( "1", "out_groups", group_name ) # note the buttons...
tc.submit( "groups_add_button" )
tc.submit( "role_members_edit_button" )
url = "%s/admin/role?role_id=%s&role_members_edit_button=Save" % ( self.url, role_id )
if user_ids:
url += "&in_users=%s" % ','.join( user_ids )
if group_ids:
url += "&in_groups=%s" % ','.join( group_ids )
self.visit_url( url )
check_str = "Role '%s' has been updated with %d associated users and %d associated groups" % ( role_name, len( user_ids ), len( group_ids ) )
self.check_page_for_string( check_str )
self.home()
def associate_users_with_role( self, role_id, user_emails=[] ):
"""Add a users to an existing role"""
# NOTE: To get this to work with twill, all select lists must contain at least 1 option value
# before tc.submit or twill throws an exception, which is: ParseError: OPTION outside of SELECT
self.home()
self.visit_url( "%s/admin/role?role_id=%s" % ( self.url, role_id ) )
self.check_page_for_string( 'Users associated with' )
for user_email in user_emails:
tc.fv( "1", "out_users", user_email )
tc.submit( "users_add_button" )
tc.submit( "role_members_edit_button" )
self.home()
# Tests associated with groups
def create_group( self, name='Group One', user_ids=[], role_ids=[] ):
"""Create a new group with members and associated role"""
def create_group( self, name='Group One', in_user_ids=[], in_role_ids=[] ):
"""Create a new group"""
url = "%s/admin/create_group?create_group_button=Save&name=%s" % ( self.url, name.replace( ' ', '+' ) )
if in_user_ids:
url += "&in_users=%s" % ','.join( in_user_ids )
if in_role_ids:
url += "&in_roles=%s" % ','.join( in_role_ids )
self.home()
self.visit_url( "%s/admin/create_group" % self.url )
self.check_page_for_string( "Create Group" )
# Make sure no private roles are displayed
try:
self.check_page_for_string( 'Private Role for' )
raise AssertionError( 'Private role displayed on Create Group page' )
except AssertionError:
# Reaching here is the behavior we want since no private roles should be displayed
pass
tc.fv( "1", "name", name )
for user_id in user_ids:
tc.fv( "1", "members", user_id )
for role_id in role_ids:
tc.fv( "1", "roles", role_id )
tc.submit( "create_group_button" )
try:
self.check_page_for_string( "The new group has been created" )
previously_created = False
except:
self.check_page_for_string( "A group with that name already exists" )
previously_created = True
self.visit_url( url )
check_str = "Group '%s' has been created with %d associated users and %d associated roles" % ( name, len( in_user_ids ), len( in_role_ids ) )
self.check_page_for_string( check_str )
self.home()
self.visit_page( "admin/groups" )
self.visit_url( "%s/admin/groups" % self.url )
self.check_page_for_string( name )
self.home()
return previously_created
def rename_group( self, group_id, name='Group One Renamed' ):
"""Rename a group"""
self.home()
@@ -783,63 +751,60 @@ class TwillTestCase( unittest.TestCase ):
tc.fv( "1", "name", name )
tc.submit( "rename_group_button" )
self.home()
def group_members_edit( self, group_id, user_ids=[] ):
"""Add members to an existing group"""
def associate_users_and_roles_with_group( self, group_id, group_name, user_ids=[], role_ids=[] ):
self.home()
self.visit_url( "%s/admin/group_members_edit?group_id=%s" % ( self.url, group_id ) )
self.check_page_for_string( 'Select to add user to' )
for user_id in user_ids:
tc.fv( "1", "members", user_id )
tc.submit( "group_members_edit_button" )
self.check_page_for_string( 'Group membership has been updated' )
url = "%s/admin/group?group_id=%s&group_roles_users_edit_button=Save" % ( self.url, group_id )
if user_ids:
url += "&in_users=%s" % ','.join( user_ids )
if role_ids:
url += "&in_roles=%s" % ','.join( role_ids )
self.visit_url( url )
check_str = "Group '%s' has been updated with %d associated roles and %d associated users" % ( group_name, len( role_ids ), len( user_ids ) )
self.check_page_for_string( check_str )
self.home()
def group_roles_edit( self, group_id, role_ids=[] ):
"""Change roles associated with an existing group"""
self.home()
self.visit_url( "%s/admin/group_roles_edit?group_id=%s" % ( self.url, group_id ) )
self.check_page_for_string( 'Select to associate role with' )
for role_id in role_ids:
tc.fv( "1", "roles", role_id )
tc.submit( "group_roles_edit_button" )
self.check_page_for_string( 'Group updated with a total of' )
self.home()
def mark_group_deleted( self, group_id ):
def mark_group_deleted( self, group_id, group_name ):
"""Mark a group as deleted"""
self.home()
self.visit_url( "%s/admin/mark_group_deleted?group_id=%s" % ( self.url, group_id ) )
self.check_page_for_string( 'The group has been marked as deleted' )
check_str = "Group '%s' has been marked as deleted" % group_name
self.check_page_for_string( check_str )
self.home()
def undelete_group( self, group_id ):
def undelete_group( self, group_id, group_name ):
"""Undelete an existing group"""
self.home()
self.visit_url( "%s/admin/undelete_group?group_id=%s" % ( self.url, group_id ) )
self.check_page_for_string( 'The group has been marked as not deleted' )
check_str = "Group '%s' has been marked as not deleted" % group_name
self.check_page_for_string( check_str )
self.home()
def purge_group( self, group_id ):
def purge_group( self, group_id, group_name ):
"""Purge an existing group"""
self.home()
self.visit_url( "%s/admin/purge_group?group_id=%s" % ( self.url, group_id ) )
self.check_page_for_string( "The following have been purged from the database for the group: UserGroupAssociations, GroupRoleAssociations." )
check_str = "The following have been purged from the database for group '%s': UserGroupAssociations, GroupRoleAssociations." % group_name
self.check_page_for_string( check_str )
self.home()
# Utility methods to test removal of associations
def remove_role_from_group( self, role_id, group_id ):
def remove_role_from_group( self, role_id, role_name, group_id, group_name ):
"""Remove a role from a group"""
self.home()
self.visit_url( "%s/admin/remove_role_from_group?role_id=%s&group_id=%s" % ( self.url, role_id, group_id ) )
self.check_page_for_string( 'Role removed from group' )
check_str = "Role '%s' removed from group '%s'" % ( role_name, group_name )
self.check_page_for_string( check_str )
self.home()
def remove_user_from_group( self, user_id, group_id ):
def remove_user_from_group( self, user_id, email, group_id, group_name ):
"""Remove a user from a group"""
self.home()
self.visit_url( "%s/admin/remove_user_from_group?user_id=%s&group_id=%s" % ( self.url, user_id, group_id ) )
self.check_page_for_string( 'User removed from group' )
check_str = "User '%s' removed from group '%s'" % ( email, group_name )
self.check_page_for_string( check_str )
self.home()
def remove_user_from_role( self, user_id, role_id ):
def remove_user_from_role( self, user_id, email, role_id, role_name ):
"""Remove a user from a role"""
self.home()
self.visit_url( "%s/admin/remove_user_from_role?user_id=%s&role_id=%s" % ( self.url, user_id, role_id ) )
self.check_page_for_string( 'User removed from role' )
check_str = "User '%s' removed from role '%s'" % ( email, role_name )
self.check_page_for_string( check_str )
self.home()
# Library stuff
@@ -921,25 +886,28 @@ class TwillTestCase( unittest.TestCase ):
library_dir = "%s" % self.file_dir
tc.fv( "1", "server_dir", "library" )
for role_tuple in roles_tuple:
tc.fv( "1", "roles", role_tuple[1] ) # role_tuple[1] is the role description
tc.fv( "1", "roles", role_tuple[1] ) # role_tuple[1] is the role name
tc.submit( "new_dataset_button" )
self.check_page_for_string( '3 new datasets added to the library' )
self.home()
def mark_library_deleted( self, library_id ):
def mark_library_deleted( self, library_id, library_name ):
"""Mark a library as deleted"""
self.home()
self.visit_url( "%s/admin/library?id=%s&delete=True" % ( self.url, library_id ) )
self.check_page_for_string( 'The library and all of its contents have been marked deleted' )
check_str = "Library '%s' and all of its contents have been marked deleted" % library_name
self.check_page_for_string( check_str )
self.home()
def undelete_library( self, library_id ):
def undelete_library( self, library_id, library_name ):
"""Mark a library as not deleted"""
self.home()
self.visit_url( "%s/admin/undelete_library?id=%s" % ( self.url, library_id ) )
self.check_page_for_string( 'The library and all of its contents have been marked not deleted' )
check_str = "Library '%s' and all of its contents have been marked not deleted" % library_name
self.check_page_for_string( check_str )
self.home()
def purge_library( self, library_id ):
def purge_library( self, library_id, library_name ):
"""Purge a library"""
self.home()
self.visit_url( "%s/admin/purge_library?id=%s" % ( self.url, library_id ) )
self.check_page_for_string( 'The library and all of its contents have been purged' )
check_str = "Library '%s' and all of its contents have been purged" % library_name
self.check_page_for_string( check_str )
self.home()
+67 -127
View File
@@ -17,7 +17,7 @@ class TestSecurityAndLibraries( TwillTestCase ):
self.check_page_for_string( not_logged_in_security_msg )
self.visit_url( "%s/admin/create_role" % self.url )
self.check_page_for_string( not_logged_in_security_msg )
self.visit_url( "%s/admin/new_role" % self.url )
self.visit_url( "%s/admin/create_role" % self.url )
self.check_page_for_string( not_logged_in_security_msg )
self.visit_url( "%s/admin/role" % self.url )
self.check_page_for_string( not_logged_in_security_msg )
@@ -25,7 +25,6 @@ class TestSecurityAndLibraries( TwillTestCase ):
self.check_page_for_string( not_logged_in_security_msg )
self.visit_url( "%s/admin/create_group" % self.url )
self.check_page_for_string( not_logged_in_security_msg )
self.visit_url( "%s/admin/group_members_edit?group_id=0" % self.url )
self.check_page_for_string( not_logged_in_security_msg )
self.visit_url( "%s/admin/users" % self.url )
self.check_page_for_string( not_logged_in_security_msg )
@@ -281,30 +280,24 @@ class TestSecurityAndLibraries( TwillTestCase ):
self.reset_password_as_admin( user_id=regular_user3.id, password='testuser' )
def test_035_mark_user_deleted( self ):
"""Testing marking a user account as deleted"""
self.mark_user_deleted( user_id=regular_user3.id )
self.mark_user_deleted( user_id=regular_user3.id, email=regular_user3.email )
# Deleting a user should not delete any associations
regular_user3.refresh()
if not regular_user3.active_histories:
raise AssertionError( 'HistoryDatasetAssociations for regular_user3 were incorrectly deleted when the user was marked deleted' )
def test_040_undelete_user( self ):
"""Testing undeleting a user account"""
self.undelete_user( user_id=regular_user3.id )
self.undelete_user( user_id=regular_user3.id, email=regular_user3.email )
def test_045_create_role( self ):
"""Testing creating new role with 3 members, then renaming it"""
name = 'Role One'
description = "This is Role One's description"
description = "This is Role Ones description"
user_ids=[ str( admin_user.id ), str( regular_user1.id ), str( regular_user3.id ) ]
previously_created = self.create_role( name=name, description=description, user_ids=user_ids, private_role=admin_user.email )
self.create_role( name=name, description=description, in_user_ids=user_ids, in_group_ids=[], private_role=admin_user.email )
# Get the role object for later tests
global role_one
role_one = galaxy.model.Role.filter( galaxy.model.Role.table.c.name==name ).first()
assert role_one is not None, 'Problem retrieving role named "Role One" from the database'
if previously_created:
# Since the role was created in a previous test run, we need to associate the required users with it
role_ids = [ str( role_one.id ) ]
for user_id in user_ids:
self.user_roles_edit( user_id, role_ids=role_ids )
role_one.refresh()
# Make sure UserRoleAssociations are correct
if len( role_one.users ) != len( user_ids ):
raise AssertionError( '%d UserRoleAssociations were created for role id %d when it was created ( should have been %d )' \
@@ -312,13 +305,13 @@ class TestSecurityAndLibraries( TwillTestCase ):
# Each of the following users should now have 3 role associations, their private role, role_one and sharing_role
for user in [ admin_user, regular_user1 ]:
user.refresh()
if not previously_created and len( user.roles ) != 3:
if len( user.roles ) != 3:
raise AssertionError( '%d UserRoleAssociations are associated with user %s ( should be 3 )' \
% ( len( user.roles ), user.email ) )
# Each of the following users should now have 2 role associations, their private role and role_one
for user in [ regular_user3 ]:
user.refresh()
if not previously_created and len( user.roles ) != 2:
if len( user.roles ) != 2:
raise AssertionError( '%d UserRoleAssociations are associated with user %s ( should be 2 )' \
% ( len( user.roles ), user.email ) )
# Rename the role
@@ -336,15 +329,11 @@ class TestSecurityAndLibraries( TwillTestCase ):
name = "Group One's Name"
user_ids=[ str( admin_user.id ), str( regular_user1.id ), str( regular_user3.id ) ]
role_ids=[ str( role_one.id ) ]
previously_created = self.create_group( name=name, user_ids=user_ids, role_ids=role_ids )
self.create_group( name=name, in_user_ids=user_ids, in_role_ids=role_ids )
# Get the group object for later tests
global group_one
group_one = galaxy.model.Group.filter( galaxy.model.Group.table.c.name==name ).first()
assert group_one is not None, 'Problem retrieving group named "Group One" from the database'
if previously_created:
# group_one was created during a previous test run, so create associations
self.group_members_edit( str( group_one.id ), user_ids=user_ids )
self.group_roles_edit( str( group_one.id ), role_ids=role_ids )
# Make sure UserGroupAssociations are correct
if len( group_one.users ) != len( user_ids ):
raise AssertionError( '%d UserGroupAssociations were created for group id %d when it was created ( should have been %d )' \
@@ -369,7 +358,7 @@ class TestSecurityAndLibraries( TwillTestCase ):
def test_055_add_members_and_role_to_group( self ):
"""Testing editing user membership and role associations of an existing group"""
name = 'Group Two'
previously_created = self.create_group( name=name, user_ids=[], role_ids=[] )
self.create_group( name=name, in_user_ids=[], in_role_ids=[] )
# Get the group object for later tests
global group_two
group_two = galaxy.model.Group.filter( galaxy.model.Group.table.c.name==name ).first()
@@ -383,58 +372,25 @@ class TestSecurityAndLibraries( TwillTestCase ):
% ( len( group_two.roles ), group_two.id ) )
group_two_id = str( group_two.id )
user_ids = [ str( regular_user1.id ) ]
# Add users to group_two based on user_ids
self.group_members_edit( group_two_id, user_ids=user_ids )
self.home()
self.visit_url( "%s/admin/group_members_edit?group_id=%s" % ( self.url, group_two_id ) )
# Make sure UserGroupAssociations are correct
check_str = '%s currently has %d members' % ( name, len( user_ids ) )
self.check_page_for_string( check_str )
role_ids = [ str( role_one.id ) ]
# Associate roles with group_two based on roles_ids
self.group_roles_edit( group_two_id, role_ids=role_ids )
self.home()
self.visit_url( "%s/admin/group_roles_edit?group_id=%s" % ( self.url, group_two_id ) )
# Make sure GroupRoleAssociation are correct
check_str = '%s is currently associated with %d roles' % ( name, len( role_ids ) )
self.check_page_for_string( check_str )
# Create another group -needed for the following test
name = 'Group Three'
previously_created = self.create_group( name=name, user_ids=[], role_ids=[] )
# Get the group object for later tests
global group_three
group_three = galaxy.model.Group.filter( galaxy.model.Group.table.c.name==name ).first()
assert group_three is not None, 'Problem retrieving group named "Group Three" from the database'
group_three_id = str( group_three.id )
self.associate_users_and_roles_with_group( group_two.id, group_two.name, user_ids=user_ids, role_ids=role_ids )
def test_060_create_role_with_user_and_group_associations( self ):
"""Testing creating a role with user and group associations"""
# NOTE: To get this to work with twill, all select lists on the ~/admin/role page must contain at least
# 1 option value or twill throws an exception, which is: ParseError: OPTION outside of SELECT
# Due to this bug in twill, we create the role, associating it with at least 1 user and 1 group. We
# also must ensure that each of the form fields will contain at least 1 value prior to submitting the form,
# so we had to create group_three in the previous test
# Due to this bug in twill, we create the role, we bypass the page and visit the URL in the
# associate_users_and_groups_with_role() method.
name = 'Role Two'
description = 'This is Role Two'
user_ids=[ str( admin_user.id ) ]
group_ids=[ str( group_two.id ) ]
private_role=admin_user.email
# STEP 1: create the role
previously_created = self.create_role( name=name,
description=description,
user_ids=user_ids,
group_ids=group_ids,
private_role=private_role )
# Create the role
self.create_role( name=name, description=description, in_user_ids=user_ids, in_group_ids=group_ids, private_role=private_role )
# Get the role object for later tests
global role_two
role_two = galaxy.model.Role.filter( galaxy.model.Role.table.c.name==name ).first()
assert role_two is not None, 'Problem retrieving role named "Role Two" from the database'
if previously_created:
# role_two was created during a previous test run, so create associations
user_id = user_ids[0]
role_ids = [ str( role_two.id) ]
self.user_roles_edit( user_id, role_ids=role_ids )
group_id = group_ids[0]
self.group_roles_edit( group_id, role_ids=role_ids )
# Make sure UserRoleAssociations are correct
if len( role_two.users ) != len( user_ids ):
raise AssertionError( '%d UserRoleAssociations were created for role id %d when it was created with %d members' \
@@ -452,12 +408,6 @@ class TestSecurityAndLibraries( TwillTestCase ):
group_two.refresh()
if len( group_two.roles ) != 2:
raise AssertionError( '%d GroupRoleAssociations are associated with group id %d ( should be 2 )' % ( len( group_two.roles ), group_two.id ) )
# STEP 2: associate the role with a group not yet associated
# TODO: Twill throws an exception on this...
#group_names = [ group_one.name ]
#self.associate_groups_with_role( str( role_two.id ), group_names=group_names )
#self.visit_page( 'admin/roles' )
#self.check_page_for_string( group_one.name )
def test_065_change_user_role_associations( self ):
"""Testing changing roles associated with a user"""
# Create a new role with no associations
@@ -466,18 +416,21 @@ class TestSecurityAndLibraries( TwillTestCase ):
user_ids=[]
group_ids=[]
private_role=admin_user.email
previously_created = self.create_role( name=name,
description=description,
user_ids=user_ids,
group_ids=group_ids,
private_role=private_role )
self.create_role( name=name, description=description, in_user_ids=user_ids, in_group_ids=group_ids, private_role=private_role )
# Get the role object for later tests
global role_three
role_three = galaxy.model.Role.filter( galaxy.model.Role.table.c.name==name ).first()
assert role_three is not None, 'Problem retrieving role named "Role Three" from the database'
# Associate the role with a user
role_ids = [ str( role_three.id ) ]
self.user_roles_edit( str( admin_user.id ), role_ids=role_ids )
admin_user.refresh()
role_ids = []
for ura in admin_user.non_private_roles:
role_ids.append( str( ura.role_id ) )
role_ids.append( str( role_three.id ) )
group_ids = []
for uga in admin_user.groups:
group_ids.append( str( uga.group_id ) )
self.associate_roles_and_groups_with_user( str( admin_user.id ), str( admin_user.email ), role_ids=role_ids, group_ids=group_ids )
admin_user.refresh()
# admin_user should now be associated with 5 roles: private, role_one, role_two, role_three and sharing_role
if len( admin_user.roles ) != 5:
@@ -742,7 +695,7 @@ class TestSecurityAndLibraries( TwillTestCase ):
str( adra.action ) )
def test_115_add_datasets_from_library_dir( self ):
"""Testing adding 3 datasets from a library directory to a folder"""
roles_tuple = [ ( str( role_one.id ), role_one.description ) ]
roles_tuple = [ ( str( role_one.id ), role_one.name ) ]
self.add_datasets_from_library_dir( str( folder_one.id ), roles_tuple=roles_tuple )
def test_120_change_permissions_on_datasets_imported_from_library( self ):
"""Testing changing the permissions on library datasets imported into a history"""
@@ -833,7 +786,7 @@ class TestSecurityAndLibraries( TwillTestCase ):
self.home()
self.visit_url( '%s/admin/groups' % self.url )
self.check_page_for_string( group_two.name )
self.mark_group_deleted( str( group_two.id ) )
self.mark_group_deleted( str( group_two.id ), group_two.name )
group_two.refresh()
if not group_two.deleted:
raise AssertionError( '%s was not correctly marked as deleted.' % group_two.name )
@@ -844,7 +797,7 @@ class TestSecurityAndLibraries( TwillTestCase ):
raise AssertionError( '%s incorrectly lost all role associations when it was marked as deleted.' % group_two.name )
def test_130_undelete_group( self ):
"""Testing undeleting a deleted group"""
self.undelete_group( str( group_two.id ) )
self.undelete_group( str( group_two.id ), group_two.name )
group_two.refresh()
if group_two.deleted:
raise AssertionError( '%s was not correctly marked as not deleted.' % group_two.name )
@@ -853,7 +806,7 @@ class TestSecurityAndLibraries( TwillTestCase ):
self.home()
self.visit_url( '%s/admin/roles' % self.url )
self.check_page_for_string( role_two.name )
self.mark_role_deleted( str( role_two.id ) )
self.mark_role_deleted( str( role_two.id ), role_two.name )
role_two.refresh()
if not role_two.deleted:
raise AssertionError( '%s was not correctly marked as deleted.' % role_two.name )
@@ -864,10 +817,10 @@ class TestSecurityAndLibraries( TwillTestCase ):
raise AssertionError( '%s incorrectly lost all group associations when it was marked as deleted.' % role_two.name )
def test_140_undelete_role( self ):
"""Testing undeleting a deleted role"""
self.undelete_role( str( role_two.id ) )
self.undelete_role( str( role_two.id ), role_two.name )
def test_145_mark_library_deleted( self ):
"""Testing marking a library as deleted"""
self.mark_library_deleted( str( library_one.id ) )
self.mark_library_deleted( str( library_one.id ), library_one.name )
# Make sure the library was deleted
library_one.refresh()
if not library_one.deleted:
@@ -893,7 +846,7 @@ class TestSecurityAndLibraries( TwillTestCase ):
check_folder( library_one.root_folder )
def test_150_undelete_library( self ):
"""Testing marking a library as not deleted"""
self.undelete_library( str( library_one.id ) )
self.undelete_library( str( library_one.id ), library_one.name )
# Make sure the library is undeleted
library_one.refresh()
if library_one.deleted:
@@ -917,7 +870,7 @@ class TestSecurityAndLibraries( TwillTestCase ):
raise AssertionError( 'The dataset with id "%s" has not been marked as undeleted.' % lfda.dataset.id )
check_folder( library_one.root_folder )
# Mark library as deleted again so we can test purging it
self.mark_library_deleted( str( library_one.id ) )
self.mark_library_deleted( str( library_one.id ), library_one.name )
# Make sure the library is deleted again
library_one.refresh()
if not library_one.deleted:
@@ -925,8 +878,8 @@ class TestSecurityAndLibraries( TwillTestCase ):
( str( library_one.id ), library_one.name ) )
def test_155_purge_user( self ):
"""Testing purging a user account"""
self.mark_user_deleted( user_id=regular_user3.id )
self.purge_user( user_id=regular_user3.id )
self.mark_user_deleted( user_id=regular_user3.id, email=regular_user3.email )
self.purge_user( str( regular_user3.id ), regular_user3.email )
regular_user3.refresh()
if not regular_user3.purged:
raise AssertionError( 'User %s was not marked as purged.' % regular_user3.email )
@@ -979,8 +932,8 @@ class TestSecurityAndLibraries( TwillTestCase ):
def test_165_purge_group( self ):
"""Testing purging a group"""
group_id = str( group_two.id )
self.mark_group_deleted( group_id )
self.purge_group( group_id )
self.mark_group_deleted( group_id, group_two.name )
self.purge_group( group_id, group_two.name )
# Make sure there are no UserGroupAssociations
uga = galaxy.model.UserGroupAssociation.filter( galaxy.model.UserGroupAssociation.table.c.group_id == group_id ).all()
if uga:
@@ -990,12 +943,12 @@ class TestSecurityAndLibraries( TwillTestCase ):
if gra:
raise AssertionError( "Purging the group did not delete the GroupRoleAssociations for group_id '%s'" % group_id )
# Undelete the group for later test runs
self.undelete_group( group_id )
self.undelete_group( group_id, group_two.name )
def test_170_purge_role( self ):
"""Testing purging a role"""
role_id = str( role_two.id )
self.mark_role_deleted( role_id )
self.purge_role( role_id )
self.mark_role_deleted( role_id, role_two.name )
self.purge_role( role_id, role_two.name )
# Make sure there are no UserRoleAssociations
uras = galaxy.model.UserRoleAssociation.filter( galaxy.model.UserRoleAssociation.table.c.role_id == role_id ).all()
if uras:
@@ -1022,10 +975,10 @@ class TestSecurityAndLibraries( TwillTestCase ):
# TODO: If we decide to implement the GUI feature for un-purging a role, replace this with a method call
role_two.purged = False
role_two.flush()
self.undelete_role( str( role_two.id ) )
self.undelete_role( str( role_two.id ), role_two.name )
def test_180_purge_library( self ):
"""Testing purging a library"""
self.purge_library( str( library_one.id ) )
self.purge_library( str( library_one.id ), library_one.name )
# Make sure the library was purged
library_one.refresh()
if not library_one.purged:
@@ -1053,22 +1006,34 @@ class TestSecurityAndLibraries( TwillTestCase ):
def test_185_reset_data_for_later_test_runs( self ):
"""Reseting data to enable later test runs to pass"""
##################
# Reset admin_user
# Eliminate all non-private roles
##################
# Eliminate all role associations except private
self.remove_user_from_role( str( admin_user.id ), str( role_one.id ) )
self.remove_user_from_role( str( admin_user.id ), str( role_three.id ) )
self.remove_user_from_role( str( admin_user.id ), str( sharing_role.id ) )
admin_user.refresh()
if len( admin_user.roles) != 1:
raise AssertionError( '%d UserRoleAssociations are associated with %s ( should be 1 )' % ( len( admin_user.roles ), admin_user.email ) )
# Eliminate all group associations
self.remove_user_from_group( str( admin_user.id ), str( group_one.id ) )
admin_user.refresh()
if admin_user.groups:
raise AssertionError( '%d UserGroupAssociations are associated with %s ( should be 0 )' % ( len( admin_user.groups ), admin_user.email ) )
for role in [ role_one, role_two, role_three, sharing_role ]:
self.mark_role_deleted( str( role.id ), role.name )
self.purge_role( str( role.id ), role.name )
# Manually delete the role from the database
role.refresh()
role.delete()
role.flush()
##################
# Eliminate all groups
##################
for group in [ group_one, group_two ]:
self.mark_group_deleted( str( group.id ), group.name )
self.purge_group( str( group.id ), group.name )
# Manually delete the group from the database
group.refresh()
group.delete()
group.flush()
##################
# Make sure all users are associated only with their private roles
##################
for user in [ admin_user, regular_user1, regular_user2, regular_user3 ]:
user.refresh()
if len( user.roles) != 1:
raise AssertionError( '%d UserRoleAssociations are associated with %s ( should be 1 )' % ( len( user.roles ), user.email ) )
#####################
# Reset regular_user1
# Reset DefaultHistoryPermissions for regular_user1
#####################
self.logout()
self.login( email='test1@bx.psu.edu' )
@@ -1079,28 +1044,3 @@ class TestSecurityAndLibraries( TwillTestCase ):
self.user_set_default_permissions( permissions_in=permissions_in, permissions_out=permissions_out, role_id=role_id )
self.logout()
self.login( email='test@bx.psu.edu' )
# Eliminate all role associations except private
self.remove_user_from_role( str( regular_user1.id ), str( role_one.id ) )
self.remove_user_from_role( str( regular_user1.id ), str( sharing_role.id ) )
regular_user1.refresh()
if len( regular_user1.roles) != 1:
raise AssertionError( '%d UserRoleAssociations are associated with %s ( should be 1 )' % ( len( regular_user1.roles ), regular_user1.email ) )
# Eliminate all group associations
self.remove_user_from_group( str( regular_user1.id ), str( group_one.id ) )
regular_user1.refresh()
if regular_user1.groups:
raise AssertionError( '%d UserGroupAssociations are associated with %s ( should be 0 )' % ( len( regular_user1.groups ), regular_user1.email ) )
# Delete the record for sharing_role from the role table so that it can be created correctly in later test runs
self.mark_role_deleted( str( sharing_role.id ) )
self.purge_role( str( sharing_role.id ) )
sharing_role.refresh()
sharing_role.delete()
sharing_role.flush()
#################
# Reset group_one
#################
# Eliminate all role associations
self.remove_role_from_group( str( role_one.id ), str( group_one.id ) )
group_one.refresh()
if group_one.roles:
raise AssertionError( '%d GroupRoleAssociations are associated with group %s ( should be 0 )' % ( len( group_one.roles ), group_one.name ) )