commit/galaxy-central: greg: Clean up the main repositories by category grid and add a tools verified column.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/5138b63cc964/ Changeset: 5138b63cc964 User: greg Date: 2013-04-22 16:44:20 Summary: Clean up the main repositories by category grid and add a tools verified column. Affected #: 2 files diff -r cac1c2a9247bf1f2c7f78275a6d11bf209867fb2 -r 5138b63cc96435ea72415796aa3daabfbfe2f23f lib/galaxy/webapps/tool_shed/controllers/repository.py --- a/lib/galaxy/webapps/tool_shed/controllers/repository.py +++ b/lib/galaxy/webapps/tool_shed/controllers/repository.py @@ -61,6 +61,7 @@ my_writable_repositories_grid = repository_grids.MyWritableRepositoriesGrid() repositories_by_user_grid = repository_grids.RepositoriesByUserGrid() repositories_i_own_grid = repository_grids.RepositoriesIOwnGrid() + repositories_in_category_grid = repository_grids.RepositoriesInCategoryGrid() repository_dependencies_grid = repository_grids.RepositoryDependenciesGrid() repository_grid = repository_grids.RepositoryGrid() # The repository_metadata_grid is not currently displayed, but is sub-classed by several grids. @@ -202,13 +203,14 @@ elif operation == "my_writable_repositories": return self.my_writable_repositories_grid( trans, **kwd ) elif operation == "repositories_by_category": - # Eliminate the current filters if any exist. - for k, v in kwd.items(): - if k.startswith( 'f-' ): - del kwd[ k ] category_id = kwd.get( 'id', None ) - category = suc.get_category( trans, category_id ) - kwd[ 'f-Category.name' ] = category.name + message = kwd.get( 'message', '' ) + status = kwd.get( 'status', 'done' ) + return trans.response.send_redirect( web.url_for( controller='repository', + action='browse_repositories_in_category', + id=category_id, + message=message, + status=status ) ) elif operation == "receive email alerts": if trans.user: if kwd[ 'id' ]: @@ -244,7 +246,7 @@ **kwd ) ) user_id = kwd.get( 'user_id', None ) if user_id is None: - # The received id is the repository id, so we need to get the id of the user that uploaded the repository. + # The received id is the repository id, so we need to get the id of the user that owns the repository. repository_id = kwd.get( 'id', None ) if repository_id: repository = suc.get_repository_in_tool_shed( trans, repository_id ) @@ -263,6 +265,40 @@ return self.repositories_by_user_grid( trans, **kwd ) @web.expose + def browse_repositories_in_category( self, trans, **kwd ): + if 'operation' in kwd: + operation = kwd[ 'operation' ].lower() + if operation == "view_or_manage_repository": + return trans.response.send_redirect( web.url_for( controller='repository', + action='view_or_manage_repository', + **kwd ) ) + if operation == 'repositories_by_user': + user_id = kwd.get( 'user_id', None ) + if user_id is None: + # The received id is the repository id, so we need to get the id of the user that owns the repository. + repository_id = kwd.get( 'id', None ) + if repository_id: + repository = suc.get_repository_in_tool_shed( trans, repository_id ) + user_id = trans.security.encode_id( repository.user.id ) + user = suc.get_user( trans, user_id ) + self.repositories_by_user_grid.title = "Repositories owned by %s" % user.username + kwd[ 'user_id' ] = user_id + return self.repositories_by_user_grid( trans, **kwd ) + selected_changeset_revision, repository = self.__get_repository_from_refresh_on_change( trans, **kwd ) + if repository: + # The user selected a repository revision which results in a refresh_on_change. + return trans.response.send_redirect( web.url_for( controller='repository', + action='view_or_manage_repository', + id=trans.security.encode_id( repository.id ), + changeset_revision=selected_changeset_revision ) ) + category_id = kwd.get( 'id', None ) + if category_id: + category = suc.get_category( trans, category_id ) + if category: + self.repositories_in_category_grid.title = 'Category %s' % str( category.name ) + return self.repositories_in_category_grid( trans, **kwd ) + + @web.expose def browse_repository( self, trans, id, **kwd ): params = util.Params( kwd ) message = util.restore_text( params.get( 'message', '' ) ) diff -r cac1c2a9247bf1f2c7f78275a6d11bf209867fb2 -r 5138b63cc96435ea72415796aa3daabfbfe2f23f lib/tool_shed/grids/repository_grids.py --- a/lib/tool_shed/grids/repository_grids.py +++ b/lib/tool_shed/grids/repository_grids.py @@ -143,6 +143,19 @@ return escape_html( repository.revision( trans.app ) ) + class ToolsFunctionallyCorrectColumn( grids.BooleanColumn ): + + def get_value( self, trans, grid, repository ): + # This column will display the value associated with the currently displayed metadata revision. + displayed_metadata_revision = repository.metadata_revisions[ -1 ] + if displayed_metadata_revision.includes_tools: + if displayed_metadata_revision.tools_functionally_correct: + return 'yes' + else: + return 'no' + return 'not applicable' + + class DescriptionColumn( grids.TextColumn ): def get_value( self, trans, grid, repository ): @@ -261,6 +274,60 @@ .outerjoin( model.Category.table ) +class RepositoriesInCategoryGrid( RepositoryGrid ): + title = "Category" + + columns = [ + RepositoryGrid.NameColumn( "Name", + key="name", + link=( lambda item: dict( controller="repository", operation="view_or_manage_repository", id=item.id ) ), + attach_popup=False ), + RepositoryGrid.DescriptionColumn( "Synopsis", + key="description", + attach_popup=False ), + RepositoryGrid.MetadataRevisionColumn( "Metadata Revisions" ), + RepositoryGrid.ToolsFunctionallyCorrectColumn( "Tools Verified" ), + RepositoryGrid.UserColumn( "Owner", + model_class=model.User, + link=( lambda item: dict( controller="repository", operation="repositories_by_user", id=item.id ) ), + attach_popup=False, + key="User.username" ), + # Columns that are valid for filtering but are not visible. + RepositoryGrid.EmailColumn( "Email", + model_class=model.User, + key="email", + visible=False ) + ] + columns.append( grids.MulticolFilterColumn( "Search repository name, description", + cols_to_filter=[ columns[0], columns[1] ], + key="free-text-search", + visible=False, + filterable="standard" ) ) + operations = [ grids.GridOperation( "Receive email alerts", + allow_multiple=False, + condition=( lambda item: not item.deleted ), + async_compatible=False ) ] + + def build_initial_query( self, trans, **kwd ): + category_id = kwd.get( 'id', None ) + if category_id: + category = suc.get_category( trans, category_id ) + if category: + return trans.sa_session.query( model.Repository ) \ + .filter( and_( model.Repository.table.c.deleted == False, + model.Repository.table.c.deprecated == False ) ) \ + .join( model.User.table ) \ + .outerjoin( model.RepositoryCategoryAssociation.table ) \ + .outerjoin( model.Category.table ) \ + .filter( model.Category.table.c.name == category.name ) + return trans.sa_session.query( model.Repository ) \ + .filter( and_( model.Repository.table.c.deleted == False, + model.Repository.table.c.deprecated == False ) ) \ + .join( model.User.table ) \ + .outerjoin( model.RepositoryCategoryAssociation.table ) \ + .outerjoin( model.Category.table ) + + class RepositoriesByUserGrid( RepositoryGrid ): title = "Repositories by user" columns = [ @@ -268,11 +335,11 @@ key="name", link=( lambda item: dict( operation="view_or_manage_repository", id=item.id ) ), attach_popup=False ), - RepositoryGrid.MetadataRevisionColumn( "Metadata Revisions" ), - RepositoryGrid.TipRevisionColumn( "Tip Revision" ), RepositoryGrid.DescriptionColumn( "Synopsis", key="description", attach_popup=False ), + RepositoryGrid.MetadataRevisionColumn( "Metadata Revisions" ), + RepositoryGrid.ToolsFunctionallyCorrectColumn( "Tools Verified" ), RepositoryGrid.CategoryColumn( "Category", model_class=model.Category, key="Category.name", @@ -304,7 +371,7 @@ link=( lambda item: dict( operation="view_or_manage_repository", id=item.id ) ), attach_popup=True ), RepositoryGrid.MetadataRevisionColumn( "Metadata Revisions" ), - RepositoryGrid.TipRevisionColumn( "Tip Revision" ), + RepositoryGrid.ToolsFunctionallyCorrectColumn( "Tools Verified" ), RepositoryGrid.CategoryColumn( "Category", model_class=model.Category, key="Category.name", @@ -343,7 +410,7 @@ link=( lambda item: dict( operation="view_or_manage_repository", id=item.id ) ), attach_popup=True ), RepositoriesIOwnGrid.MetadataRevisionColumn( "Metadata Revisions" ), - RepositoriesIOwnGrid.TipRevisionColumn( "Tip Revision" ), + RepositoryGrid.ToolsFunctionallyCorrectColumn( "Tools Verified" ), RepositoriesIOwnGrid.CategoryColumn( "Category", model_class=model.Category, key="Category.name", @@ -403,7 +470,7 @@ link=( lambda item: dict( operation="view_or_manage_repository", id=item.id ) ), attach_popup=True ), RepositoryGrid.MetadataRevisionColumn( "Metadata Revisions" ), - RepositoryGrid.TipRevisionColumn( "Tip Revision" ), + RepositoryGrid.ToolsFunctionallyCorrectColumn( "Tools Verified" ), RepositoryGrid.UserColumn( "Owner", model_class=model.User, link=( lambda item: dict( operation="repositories_by_user", id=item.id ) ), @@ -480,7 +547,7 @@ return query.filter( model.Category.name == column_filter ) - class RevisionColumn( grids.GridColumn ): + class InstallableRevisionColumn( grids.GridColumn ): def __init__( self, col_name ): grids.GridColumn.__init__( self, col_name ) @@ -502,7 +569,8 @@ RepositoryGrid.DescriptionColumn( "Synopsis", key="description", attach_popup=False ), - RevisionColumn( "Installable Revisions" ), + InstallableRevisionColumn( "Installable Revisions" ), + RepositoryGrid.ToolsFunctionallyCorrectColumn( "Tools Verified" ), RepositoryGrid.UserColumn( "Owner", model_class=model.User, attach_popup=False ), @@ -668,9 +736,12 @@ class ToolsFunctionallyCorrectColumn( grids.BooleanColumn ): def get_value( self, trans, grid, repository_metadata ): - if repository_metadata.tools_functionally_correct: - return 'yes' - return '' + if repository_metadata.includes_tools: + if repository_metadata.tools_functionally_correct: + return 'yes' + else: + return 'no' + return 'not applicable' class DoNotTestColumn( grids.BooleanColumn ): Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org