details: http://www.bx.psu.edu/hg/galaxy/rev/87885ab394a0 changeset: 2376:87885ab394a0 user: Greg Von Kuster greg@bx.psu.edu date: Tue Apr 28 09:44:35 2009 -0400 description: Can now optionally create a new group with the same name as a role when creating the role, along with more cleanup on the various users / groups / roles templates.
9 file(s) affected in this change:
lib/galaxy/web/controllers/admin.py templates/admin/dataset_security/deleted_groups.mako templates/admin/dataset_security/deleted_roles.mako templates/admin/dataset_security/group.mako templates/admin/dataset_security/group_create.mako templates/admin/dataset_security/role.mako templates/admin/dataset_security/role_create.mako templates/admin/dataset_security/user.mako templates/admin/user/create.mako
diffs (485 lines):
diff -r 7fd4f748b0ca -r 87885ab394a0 lib/galaxy/web/controllers/admin.py --- a/lib/galaxy/web/controllers/admin.py Mon Apr 27 16:30:08 2009 -0400 +++ b/lib/galaxy/web/controllers/admin.py Tue Apr 28 09:44:35 2009 -0400 @@ -60,6 +60,7 @@ description = util.restore_text( params.description ) in_users = util.listify( params.get( 'in_users', [] ) ) in_groups = util.listify( params.get( 'in_groups', [] ) ) + create_group_for_role = params.get( 'create_group_for_role', 'no' ) if not name or not description: msg = "Enter a valid name and a description" elif trans.app.model.Role.filter( trans.app.model.Role.table.c.name==name ).first(): @@ -76,7 +77,14 @@ for group in [ trans.app.model.Group.get( x ) for x in in_groups ]: gra = trans.app.model.GroupRoleAssociation( group, role ) gra.flush() - msg = "Role '%s' has been created with %d associated users and %d associated groups" % ( role.name, len( in_users ), len( in_groups ) ) + if create_group_for_role == 'yes': + # Create the group + group = trans.app.model.Group( name=name ) + group.flush() + msg = "Group '%s' has been created, and role '%s' has been created with %d associated users and %d associated groups" % \ + ( group.name, role.name, len( in_users ), len( in_groups ) ) + else: + msg = "Role '%s' has been created with %d associated users and %d associated groups" % ( role.name, len( in_users ), len( in_groups ) ) trans.response.send_redirect( web.url_for( controller='admin', action='roles', msg=util.sanitize_text( msg ), messagetype='done' ) ) trans.response.send_redirect( web.url_for( controller='admin', action='create_role', msg=util.sanitize_text( msg ), messagetype='error' ) ) out_users = [] @@ -201,23 +209,12 @@ params = util.Params( kwd ) msg = util.restore_text( params.get( 'msg', '' ) ) messagetype = params.get( 'messagetype', 'done' ) - # Build a list of tuples which are roles followed by lists of groups and users - # [ ( role, [ group, group, group ], [ user, user ] ), ( role, [ group, group ], [ user ] ) ] - roles_groups_users = [] roles = trans.app.model.Role.query() \ .filter( trans.app.model.Role.table.c.deleted==True ) \ .order_by( trans.app.model.Role.table.c.name ) \ .all() - for role in roles: - groups = [] - for gra in role.groups: - groups.append( trans.app.model.Group.get( gra.group_id ) ) - users = [] - for ura in role.users: - users.append( trans.app.model.User.get( ura.user_id ) ) - roles_groups_users.append( ( role, groups, users ) ) return trans.fill_template( '/admin/dataset_security/deleted_roles.mako', - roles_groups_users=roles_groups_users, + roles=roles, msg=msg, messagetype=messagetype ) @web.expose @@ -398,23 +395,12 @@ params = util.Params( kwd ) msg = util.restore_text( params.get( 'msg', '' ) ) messagetype = params.get( 'messagetype', 'done' ) - # Build a list of tuples which are groups followed by lists of members and roles - # [ ( group, [ member, member, member ], [ role, role ] ), ( group, [ member, member ], [ role ] ) ] - groups_members_roles = [] groups = trans.app.model.Group.query() \ .filter( trans.app.model.Group.table.c.deleted==True ) \ .order_by( trans.app.model.Group.table.c.name ) \ .all() - for group in groups: - members = [] - for uga in group.members: - members.append( trans.app.model.User.get( uga.user_id ) ) - roles = [] - for gra in group.roles: - roles.append( trans.app.model.Role.get( gra.role_id ) ) - groups_members_roles.append( ( group, members, roles ) ) return trans.fill_template( '/admin/dataset_security/deleted_groups.mako', - groups_members_roles=groups_members_roles, + groups=groups, msg=msg, messagetype=messagetype ) @web.expose @@ -627,8 +613,8 @@ msg = util.restore_text( params.get( 'msg', '' ) ) messagetype = params.get( 'messagetype', 'done' ) users = trans.app.model.User.filter( and_( trans.app.model.User.table.c.deleted==True, trans.app.model.User.table.c.purged==False ) ) \ - .order_by( trans.app.model.User.table.c.email ) \ - .all() + .order_by( trans.app.model.User.table.c.email ) \ + .all() return trans.fill_template( '/admin/user/deleted_users.mako', users=users, msg=msg, messagetype=messagetype ) @web.expose @web.require_admin diff -r 7fd4f748b0ca -r 87885ab394a0 templates/admin/dataset_security/deleted_groups.mako --- a/templates/admin/dataset_security/deleted_groups.mako Mon Apr 27 16:30:08 2009 -0400 +++ b/templates/admin/dataset_security/deleted_groups.mako Tue Apr 28 09:44:35 2009 -0400 @@ -2,7 +2,7 @@ <%namespace file="/message.mako" import="render_msg" />
## Render a row -<%def name="render_row( group, members, roles, ctr, anchored, curr_anchor )"> +<%def name="render_row( group, ctr, anchored, curr_anchor )"> %if ctr % 2 == 1: <tr class="odd_row"> %else: @@ -17,18 +17,10 @@ </div> </td> <td> - <ul> - %for user in members: - <li>${user.email}</li> - %endfor - </ul> + ${len( group.members )} </td> <td> - <ul> - %for role in roles: - <li>${role.name}</li> - %endfor - </ul> + ${len( group.roles )} %if not anchored: <a name="${curr_anchor}"></a> <div style="float: right;"><a href="#TOP">top</a></div> @@ -43,12 +35,12 @@ ${render_msg( msg, messagetype )} %endif
-%if len( groups_members_roles ) == 0: +%if len( groups ) == 0: There are no deleted Galaxy groups %else: <table class="manage-table colored" border="0" cellspacing="0" cellpadding="0" width="100%"> <% - render_quick_find = len( groups_members_roles ) > 50 + render_quick_find = len( groups ) > 50 ctr = 0 %> %if render_quick_find: @@ -69,34 +61,29 @@ %endif <tr class="header"> <td>Name</td> - <td>Members</td> + <td>Users</td> <td>Roles</td> </tr> - %for ctr, group_tuple in enumerate( groups_members_roles ): - <% - group = group_tuple[0] - members = group_tuple[1] - roles = group_tuple[2] - %> + %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_row( group, members, roles, ctr, anchored, curr_anchor )} + ${render_row( group, ctr, anchored, curr_anchor )} <% anchored = True %> %else: - ${render_row( group, members, roles, ctr, anchored, curr_anchor )} + ${render_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_row( group, members, roles, ctr, anchored, curr_anchor )} + ${render_row( group, ctr, anchored, curr_anchor )} <% anchored = True %> %else: - ${render_row( group, members, roles, ctr, anchored, curr_anchor )} + ${render_row( group, ctr, anchored, curr_anchor )} %endif <% anchor_loc = anchors.index( anchor ) @@ -105,7 +92,7 @@ %endif %endfor %else: - ${render_row( group, members, roles, ctr, True, '' )} + ${render_row( group, ctr, True, '' )} %endif %endfor </table> diff -r 7fd4f748b0ca -r 87885ab394a0 templates/admin/dataset_security/deleted_roles.mako --- a/templates/admin/dataset_security/deleted_roles.mako Mon Apr 27 16:30:08 2009 -0400 +++ b/templates/admin/dataset_security/deleted_roles.mako Tue Apr 28 09:44:35 2009 -0400 @@ -2,7 +2,7 @@ <%namespace file="/message.mako" import="render_msg" />
## Render a row -<%def name="render_row( role, groups, users, ctr, anchored, curr_anchor )"> +<%def name="render_row( role, ctr, anchored, curr_anchor )"> %if ctr % 2 == 1: <tr class="odd_row"> %else: @@ -16,19 +16,13 @@ <a class="action-button" href="${h.url_for( action='purge_role', role_id=role.id )}">Purge</a> </div> </td> + <td>${role.description}</td> + <td>${role.type}</td> <td> - <ul> - %for group in groups: - <li>${group.name}</li> - %endfor - </ul> + ${len( role.users )} </td> <td> - <ul> - %for user in users: - <li>${user.email}</li> - %endfor - </ul> + ${len( role.groups )} %if not anchored: <a name="${curr_anchor}"></a> <div style="float: right;"><a href="#TOP">top</a></div> @@ -43,12 +37,12 @@ ${render_msg( msg, messagetype )} %endif
-%if len( roles_groups_users ) == 0: +%if len( roles ) == 0: There are no deleted Galaxy roles %else: <table class="manage-table colored" border="0" cellspacing="0" cellpadding="0" width="100%"> <% - render_quick_find = len( roles_groups_users ) > 50 + render_quick_find = len( roles ) > 50 ctr = 0 %> %if render_quick_find: @@ -69,34 +63,31 @@ %endif <tr class="header"> <td>Name</td> - <td>Associated Groups</td> - <td>Associated Users</td> + <td>Description</td> + <td>Type</td> + <td>Users</td> + <td>Groups</td> </tr> - %for ctr, role_tuple in enumerate( roles_groups_users ): - <% - role = role_tuple[0] - groups = role_tuple[1] - users = role_tuple[2] - %> + %for ctr, role in enumerate( roles ): %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, groups, users, ctr, anchored, curr_anchor )} + ${render_row( role, ctr, anchored, curr_anchor )} <% anchored = True %> %else: - ${render_row( role, groups, users, ctr, anchored, curr_anchor )} + ${render_row( role, ctr, anchored, curr_anchor )} %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, groups, users, ctr, anchored, curr_anchor )} + ${render_row( role, ctr, anchored, curr_anchor )} <% anchored = True %> %else: - ${render_row( role, groups, users, ctr, anchored, curr_anchor )} + ${render_row( role, ctr, anchored, curr_anchor )} %endif <% anchor_loc = anchors.index( anchor ) @@ -105,7 +96,7 @@ %endif %endfor %else: - ${render_row( role, groups, users, ctr, True, '' )} + ${render_row( role, ctr, True, '' )} %endif %endfor </table> diff -r 7fd4f748b0ca -r 87885ab394a0 templates/admin/dataset_security/group.mako --- a/templates/admin/dataset_security/group.mako Mon Apr 27 16:30:08 2009 -0400 +++ b/templates/admin/dataset_security/group.mako Tue Apr 28 09:44:35 2009 -0400 @@ -53,24 +53,24 @@ <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/> + <label>Roles associated with '${group.name}'</label> ${render_select( "in_roles", in_roles )}<br/> <input type="submit" id="roles_remove_button" value=">>"/> </div> <div> - Roles not associated with '${group.name}'<br/> + <label>Roles not associated with '${group.name}'</label> ${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/> + <label>Users associated with '${group.name}'</label> ${render_select( "in_users", in_users )}<br/> <input type="submit" id="users_remove_button" value=">>"/> </div> <div> - Users not associated with '${group.name}'<br/> + <label>Users not associated with '${group.name}'</label> ${render_select( "out_users", out_users )}<br/> <input type="submit" id="users_add_button" value="<<"/> </div> diff -r 7fd4f748b0ca -r 87885ab394a0 templates/admin/dataset_security/group_create.mako --- a/templates/admin/dataset_security/group_create.mako Mon Apr 27 16:30:08 2009 -0400 +++ b/templates/admin/dataset_security/group_create.mako Tue Apr 28 09:44:35 2009 -0400 @@ -52,28 +52,29 @@ <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"/> + <label>Name:</label> + <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/> + <label>Groups associated with new role</label> ${render_select( "in_roles", in_roles )}<br/> <input type="submit" id="roles_remove_button" value=">>"/> </div> <div> - Groups not associated with new role<br/> + <label>Groups not associated with new role</label> ${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/> + <label>Users associated with new role</label> ${render_select( "in_users", in_users )}<br/> <input type="submit" id="users_remove_button" value=">>"/> </div> <div> - Users not associated with new role<br/> + <label>Users not associated with new role</label> ${render_select( "out_users", out_users )}<br/> <input type="submit" id="users_add_button" value="<<"/> </div> diff -r 7fd4f748b0ca -r 87885ab394a0 templates/admin/dataset_security/role.mako --- a/templates/admin/dataset_security/role.mako Mon Apr 27 16:30:08 2009 -0400 +++ b/templates/admin/dataset_security/role.mako Tue Apr 28 09:44:35 2009 -0400 @@ -53,24 +53,24 @@ <form name="associate_role_user_group" id="associate_role_user_group" action="${h.url_for( action='role', role_id=role.id )}" method="post" > <div class="form-row"> <div style="float: left; margin-right: 10px;"> - Users associated with '${role.name}'<br/> + <label>Users associated with '${role.name}'</label> ${render_select( "in_users", in_users )}<br/> <input type="submit" id="users_remove_button" value=">>"/> </div> <div> - Users not associated with '${role.name}'<br/> + <label>Users not associated with '${role.name}'</label> ${render_select( "out_users", out_users )}<br/> <input type="submit" id="users_add_button" value="<<"/> </div> </div> <div class="form-row"> <div style="float: left; margin-right: 10px;"> - Groups associated with '${role.name}'<br/> + <label>Groups associated with '${role.name}'</label> ${render_select( "in_groups", in_groups )}<br/> <input type="submit" id="groups_remove_button" value=">>"/> </div> <div> - Groups not associated with '${role.name}'<br/> + <label>Groups not associated with '${role.name}'</label> ${render_select( "out_groups", out_groups )}<br/> <input type="submit" id="groups_add_button" value="<<"/> </div> diff -r 7fd4f748b0ca -r 87885ab394a0 templates/admin/dataset_security/role_create.mako --- a/templates/admin/dataset_security/role_create.mako Mon Apr 27 16:30:08 2009 -0400 +++ b/templates/admin/dataset_security/role_create.mako Tue Apr 28 09:44:35 2009 -0400 @@ -52,32 +52,39 @@ <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"/> + <label>Name:</label> + <input name="name" type="textfield" value="" size=40"/> + </div> + <div class="form-row"> + <label>Description:</label> + <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/> + <label>Groups associated with new role</label> ${render_select( "in_groups", in_groups )}<br/> <input type="submit" id="groups_remove_button" value=">>"/> </div> <div> - Groups not associated with new role<br/> + <label>Groups not associated with new role</label> ${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/> + <label>Users associated with new role</label> ${render_select( "in_users", in_users )}<br/> <input type="submit" id="users_remove_button" value=">>"/> </div> <div> - Users not associated with new role<br/> + <label>Users not associated with new role</label> ${render_select( "out_users", out_users )}<br/> <input type="submit" id="users_add_button" value="<<"/> </div> + </div> + <div class="form-row"> + <input type="checkbox" name="create_group_for_role" value="yes" />Create a new group of the same name for this role </div> <div class="form-row"> <input type="submit" name="create_role_button" value="Save"/> diff -r 7fd4f748b0ca -r 87885ab394a0 templates/admin/dataset_security/user.mako --- a/templates/admin/dataset_security/user.mako Mon Apr 27 16:30:08 2009 -0400 +++ b/templates/admin/dataset_security/user.mako Tue Apr 28 09:44:35 2009 -0400 @@ -53,24 +53,24 @@ <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/> + <label>Roles associated with '${user.email}'</label> ${render_select( "in_roles", in_roles )}<br/> <input type="submit" id="roles_remove_button" value=">>"/> </div> <div> - Roles not associated with '${user.email}'<br/> + <label>Roles not associated with '${user.email}'</label> ${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/> + <label>Groups associated with '${user.email}'</label> ${render_select( "in_groups", in_groups )}<br/> <input type="submit" id="groups_remove_button" value=">>"/> </div> <div> - Groups not associated with '${user.email}'<br/> + <label>Groups not associated with '${user.email}'</label> ${render_select( "out_groups", out_groups )}<br/> <input type="submit" id="groups_add_button" value="<<"/> </div> diff -r 7fd4f748b0ca -r 87885ab394a0 templates/admin/user/create.mako --- a/templates/admin/user/create.mako Mon Apr 27 16:30:08 2009 -0400 +++ b/templates/admin/user/create.mako Tue Apr 28 09:44:35 2009 -0400 @@ -6,7 +6,7 @@ %endif
<div class="toolForm"> - <div class="toolFormTitle">Create account</div> + <div class="toolFormTitle">Create user account</div> <div class="toolFormBody"> <form name="form" action="${h.url_for( controller='admin', action='create_new_user' )}" method="post" > <div class="form-row">
galaxy-dev@lists.galaxyproject.org