details: http://www.bx.psu.edu/hg/galaxy/rev/d0c905db68db changeset: 2374:d0c905db68db user: Greg Von Kuster <greg@bx.psu.edu> date: Mon Apr 27 16:03:44 2009 -0400 description: Display only the number of associations on the main users, groups, roles pages rather than the associated objects - much faster display times. Also a tweek to my last fix for the column_maker tool. 6 file(s) affected in this change: lib/galaxy/web/controllers/admin.py templates/admin/dataset_security/groups.mako templates/admin/dataset_security/roles.mako templates/admin/dataset_security/users.mako test/base/twilltestcase.py tools/stats/column_maker.py diffs (483 lines): diff -r 22118cf46b0a -r d0c905db68db lib/galaxy/web/controllers/admin.py --- a/lib/galaxy/web/controllers/admin.py Mon Apr 27 13:33:47 2009 -0400 +++ b/lib/galaxy/web/controllers/admin.py Mon Apr 27 16:03:44 2009 -0400 @@ -280,23 +280,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==False ) \ .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/groups.mako', - groups_members_roles=groups_members_roles, + groups=groups, msg=msg, messagetype=messagetype ) @web.expose @@ -647,20 +636,9 @@ params = util.Params( kwd ) msg = util.restore_text( params.get( 'msg', '' ) ) messagetype = params.get( 'messagetype', 'done' ) - # Build a list of tuples which are users followed by lists of groups and roles - # [ ( user, [ group, group, group ], [ role, role ] ), ( user, [ group, group ], [ role ] ) ] - users_groups_roles = [] users = trans.app.model.User.filter( trans.app.model.User.table.c.deleted==False ).order_by( trans.app.model.User.table.c.email ).all() - for user in users: - groups = [] - for uga in user.groups: - groups.append( trans.app.model.Group.get( uga.group_id ) ) - roles = [] - for ura in user.non_private_roles: - roles.append( trans.app.model.Role.get( ura.role_id ) ) - users_groups_roles.append( ( user, groups, roles ) ) return trans.fill_template( '/admin/dataset_security/users.mako', - users_groups_roles=users_groups_roles, + users=users, allow_user_deletion=trans.app.config.allow_user_deletion, msg=msg, messagetype=messagetype ) @@ -702,91 +680,6 @@ out_groups=out_groups, msg=msg, messagetype=messagetype ) - # Utility methods to enable removal of associations - redirects are key - @web.expose - @web.require_admin - def remove_group_from_role( self, trans, **kwd ): - params = util.Params( kwd ) - group_id = int( params.group_id ) - group = trans.app.model.Group.get( group_id ) - role_id = int( params.role_id ) - role = trans.app.model.Role.get( role_id ) - gra = trans.app.model.GroupRoleAssociation.filter( and_( trans.app.model.GroupRoleAssociation.table.c.group_id==group_id, - trans.app.model.GroupRoleAssociation.table.c.role_id==role_id ) ).first() - gra.delete() - gra.flush() - msg = "Group '%s' removed from role '%s'" % ( group.name, role.name ) - trans.response.send_redirect( web.url_for( action='roles', msg=util.sanitize_text( msg ), messagetype='done' ) ) - @web.expose - @web.require_admin - def remove_group_from_user( self, trans, **kwd ): - params = util.Params( kwd ) - group_id = int( params.group_id ) - group = trans.app.model.Group.get( group_id ) - user_id = int( params.user_id ) - user = trans.app.model.User.get( user_id ) - uga = trans.app.model.UserGroupAssociation.filter( and_( trans.app.model.UserGroupAssociation.table.c.group_id==group_id, - trans.app.model.UserGroupAssociation.table.c.user_id==user_id ) ).first() - uga.delete() - uga.flush() - msg = "Group '%s' removed from user '%s'" % ( group.name, user.email ) - trans.response.send_redirect( web.url_for( action='users', msg=util.sanitize_text( msg ), messagetype='done' ) ) - @web.expose - @web.require_admin - def remove_role_from_group( self, trans, **kwd ): - params = util.Params( kwd ) - role_id = int( params.role_id ) - role = trans.app.model.Role.get( role_id ) - group_id = int( params.group_id ) - group = trans.app.model.Group.get( group_id ) - gra = trans.app.model.GroupRoleAssociation.filter( and_( trans.app.model.GroupRoleAssociation.table.c.role_id==role_id, - trans.app.model.GroupRoleAssociation.table.c.group_id==group_id ) ).first() - gra.delete() - gra.flush() - msg = "Role '%s' removed from group '%s'" % ( role.name, group.name ) - trans.response.send_redirect( web.url_for( action='groups', msg=util.sanitize_text( msg ), messagetype='done' ) ) - @web.expose - @web.require_admin - def remove_role_from_user( self, trans, **kwd ): - params = util.Params( kwd ) - user_id = int( params.user_id ) - user = trans.app.model.User.get( user_id ) - role_id = int( params.role_id ) - role = trans.app.model.Role.get( role_id ) - ura = trans.app.model.UserRoleAssociation.filter( and_( trans.app.model.UserRoleAssociation.table.c.user_id==user_id, - trans.app.model.UserRoleAssociation.table.c.role_id==role_id ) ).first() - ura.delete() - ura.flush() - msg = "Role '%s' removed from user '%s'" % ( role.name, user.email ) - trans.response.send_redirect( web.url_for( action='users', msg=util.sanitize_text( msg ), messagetype='done' ) ) - @web.expose - @web.require_admin - def remove_user_from_group( self, trans, **kwd ): - params = util.Params( kwd ) - user_id = int( params.user_id ) - user = trans.app.model.User.get( user_id ) - group_id = int( params.group_id ) - group = trans.app.model.Group.get( group_id ) - uga = trans.app.model.UserGroupAssociation.filter( and_( trans.app.model.UserGroupAssociation.table.c.user_id==user_id, - trans.app.model.UserGroupAssociation.table.c.group_id==group_id ) ).first() - uga.delete() - uga.flush() - msg = "User '%s' removed from group '%s'" % ( user.email, group.name ) - trans.response.send_redirect( web.url_for( action='groups', msg=util.sanitize_text( msg ), messagetype='done' ) ) - @web.expose - @web.require_admin - def remove_user_from_role( self, trans, **kwd ): - params = util.Params( kwd ) - user_id = int( params.user_id ) - user = trans.app.model.User.get( user_id ) - role_id = int( params.role_id ) - role = trans.app.model.Role.get( role_id ) - ura = trans.app.model.UserRoleAssociation.filter( and_( trans.app.model.UserRoleAssociation.table.c.user_id==user_id, - trans.app.model.UserRoleAssociation.table.c.role_id==role_id ) ).first() - ura.delete() - ura.flush() - msg = "User '%s' removed from role '%s'" % ( user.email, role.name ) - trans.response.send_redirect( web.url_for( action='roles', msg=util.sanitize_text( msg ), messagetype='done' ) ) # Galaxy Library Stuff @web.expose diff -r 22118cf46b0a -r d0c905db68db templates/admin/dataset_security/groups.mako --- a/templates/admin/dataset_security/groups.mako Mon Apr 27 13:33:47 2009 -0400 +++ b/templates/admin/dataset_security/groups.mako Mon Apr 27 16:03:44 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: @@ -18,34 +18,10 @@ </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> - <a id="user-${user.id}-popup" class="popup-arrow" style="display: none;">▼</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> + ${len( group.members )} </td> <td> - <ul> - %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.name}</a> - <a id="role-${role.id}-popup" class="popup-arrow" style="display: none;">▼</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.name} - %endif - </li> - %endfor - </ul> + ${len( group.roles )} %if not anchored: <a name="${curr_anchor}"></a> <div style="float: right;"><a href="#TOP">top</a></div> @@ -65,12 +41,12 @@ ${render_msg( msg, messagetype )} %endif -%if len( groups_members_roles ) == 0: +%if len( groups ) == 0: There are no 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: @@ -91,34 +67,29 @@ %endif <tr class="header"> <td>Name</td> - <td>Associated Users</td> - <td>Associated Roles</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 ) @@ -127,7 +98,7 @@ %endif %endfor %else: - ${render_row( group, members, roles, ctr, True, '' )} + ${render_row( group, ctr, True, '' )} %endif %endfor </table> diff -r 22118cf46b0a -r d0c905db68db templates/admin/dataset_security/roles.mako --- a/templates/admin/dataset_security/roles.mako Mon Apr 27 13:33:47 2009 -0400 +++ b/templates/admin/dataset_security/roles.mako Mon Apr 27 16:03:44 2009 -0400 @@ -20,30 +20,10 @@ <td>${role.description}</td> <td>${role.type}</td> <td> - <ul> - %for ura in role.users: - <li> - <a href="${h.url_for( controller='admin', action='user', user_id=ura.user.id )}">${ura.user.email}</a> - <a id="user-${ura.user.id}-popup" class="popup-arrow" style="display: none;">▼</a> - <div popupmenu="user-${ura.user.id}-popup"> - <a class="action-button" href="${h.url_for( controller='admin', action='remove_role_from_user', role_id=role.id, user_id=ura.user.id )}">Remove user from role</a> - </div> - </li> - %endfor - </ul> + ${len( role.users )} </td> <td> - <ul> - %for gra in role.groups: - <li> - <a href="${h.url_for( controller='admin', action='group', group_id=gra.group.id )}">${gra.group.name}</a> - <a id="group-${gra.group.id}-popup" class="popup-arrow" style="display: none;">▼</a> - <div popupmenu="group-${gra.group.id}-popup"> - <a class="action-button" href="${h.url_for( controller='admin', action='remove_group_from_role', role_id=role.id, group_id=gra.group.id )}">Remove group from role</a> - </div> - </li> - %endfor - </ul> + ${len( role.groups )} %if not anchored: <a name="${curr_anchor}"></a> <div style="float: right;"><a href="#TOP">top</a></div> @@ -91,8 +71,8 @@ <td>Name</td> <td>Description</td> <td>Type</td> - <td>Associated Users</td> - <td>Associated Groups</td> + <td>Users</td> + <td>Groups</td> </tr> %for ctr, role in enumerate( roles ): %if render_quick_find and not role.name.upper().startswith( curr_anchor ): diff -r 22118cf46b0a -r d0c905db68db templates/admin/dataset_security/users.mako --- a/templates/admin/dataset_security/users.mako Mon Apr 27 13:33:47 2009 -0400 +++ b/templates/admin/dataset_security/users.mako Mon Apr 27 16:03:44 2009 -0400 @@ -2,7 +2,7 @@ <%namespace file="/message.mako" import="render_msg" /> ## Render a row -<%def name="render_row( user, groups, roles, ctr, anchored, curr_anchor )"> +<%def name="render_row( user, ctr, anchored, curr_anchor )"> %if ctr % 2 == 1: <tr class="odd_row"> %else: @@ -20,30 +20,10 @@ </div> </td> <td> - <ul> - %for group in groups: - <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;">▼</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> + ${len( user.groups )} </td> <td> - <ul> - %for role in roles: - <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;">▼</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> + ${len( user.roles )} %if not anchored: <a name="${curr_anchor}"></a> <div style="float: right;"><a href="#TOP">top</a></div> @@ -65,12 +45,12 @@ ${render_msg( msg, messagetype )} %endif -%if len( users_groups_roles ) == 0: +%if len( users ) == 0: There are no Galaxy users %else: <table class="manage-table colored" border="0" cellspacing="0" cellpadding="0" width="100%"> <% - render_quick_find = len( users_groups_roles ) > 50 + render_quick_find = len( users ) > 50 ctr = 0 %> %if render_quick_find: @@ -91,34 +71,29 @@ %endif <tr class="header"> <td>Email</td> - <td>Associated Groups</td> - <td>Associated Roles</td> + <td>Groups</td> + <td>Roles</td> </tr> - %for ctr, user_tuple in enumerate( users_groups_roles ): - <% - user = user_tuple[0] - groups = user_tuple[1] - roles = user_tuple[2] - %> + %for ctr, user in enumerate( users ): %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, groups, roles, ctr, anchored, curr_anchor )} + ${render_row( user, ctr, anchored, curr_anchor )} <% anchored = True %> %else: - ${render_row( user, groups, roles, ctr, anchored, curr_anchor )} + ${render_row( user, ctr, anchored, curr_anchor )} %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, groups, roles, ctr, anchored, curr_anchor )} + ${render_row( user, ctr, anchored, curr_anchor )} <% anchored = True %> %else: - ${render_row( user, groups, roles, ctr, anchored, curr_anchor )} + ${render_row( user, ctr, anchored, curr_anchor )} %endif <% anchor_loc = anchors.index( anchor ) @@ -127,7 +102,7 @@ %endif %endfor %else: - ${render_row( user, groups, roles, ctr, True, '' )} + ${render_row( user, ctr, True, '' )} %endif %endfor </table> diff -r 22118cf46b0a -r d0c905db68db test/base/twilltestcase.py --- a/test/base/twilltestcase.py Mon Apr 27 13:33:47 2009 -0400 +++ b/test/base/twilltestcase.py Mon Apr 27 16:03:44 2009 -0400 @@ -787,29 +787,6 @@ self.check_page_for_string( check_str ) self.home() - # Utility methods to test removal of associations - 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 ) ) - 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, 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 ) ) - 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, 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 ) ) - check_str = "User '%s' removed from role '%s'" % ( email, role_name ) - self.check_page_for_string( check_str ) - self.home() - # Library stuff def create_library( self, name='Library One', description='This is Library One' ): """Create a new library""" diff -r 22118cf46b0a -r d0c905db68db tools/stats/column_maker.py --- a/tools/stats/column_maker.py Mon Apr 27 13:33:47 2009 -0400 +++ b/tools/stats/column_maker.py Mon Apr 27 16:03:44 2009 -0400 @@ -13,10 +13,6 @@ sys.stderr.write( msg ) sys.exit() -data_err = "This tool can only be used with tab-delimited data." -columns_err = "Missing or invalid 'columns' metadata value, click the pencil icon in the history item and select the Auto-detect option to correct it. " -column_types_err = "Missing or invalid 'column_types' metadata value, click the pencil icon in the history item and select the Auto-detect option to correct it. " -invalid_metadata_err = "The 'columns' metadata setting does not conform to the 'column_types' metadata setting, click the pencil icon in the history item and select the Auto-detect option to correct it. " inp_file = sys.argv[1] out_file = sys.argv[2] expr = sys.argv[3] @@ -24,16 +20,16 @@ try: in_columns = int( sys.argv[5] ) except: - stop_err( columns_err + data_err ) + stop_err( "Missing or invalid 'columns' metadata value, click the pencil icon in the history item and select the Auto-detect option to correct it. This tool can only be used with tab-delimited data." ) if in_columns < 2: # To be considered tabular, data must fulfill requirements of the sniff.is_column_based() method. - stop_err( columns_err + data_err ) + stop_err( "Missing or invalid 'columns' metadata value, click the pencil icon in the history item and select the Auto-detect option to correct it. This tool can only be used with tab-delimited data." ) try: in_column_types = sys.argv[6].split( ',' ) except: - stop_err( column_types_err + data_err ) + stop_err( "Missing or invalid 'column_types' metadata value, click the pencil icon in the history item and select the Auto-detect option to correct it. This tool can only be used with tab-delimited data." ) if len( in_column_types ) != in_columns: - stop_err( invalid_metadata_err + data_err ) + stop_err( "The 'columns' metadata setting does not conform to the 'column_types' metadata setting, click the pencil icon in the history item and select the Auto-detect option to correct it. This tool can only be used with tab-delimited data." ) # Unescape if input has been escaped mapped_str = {