commit/galaxy-central: greg: Add the ability for a user to reset metadata on a selected list of repositories in the tool shed for those repositories for which they are authorized to change.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/d336d338debe/ Changeset: d336d338debe User: greg Date: 2013-05-30 21:32:25 Summary: Add the ability for a user to reset metadata on a selected list of repositories in the tool shed for those repositories for which they are authorized to change. Affected #: 7 files diff -r 052c1a1080a2ef5812a0b25c4e65f6d437b9fa52 -r d336d338debe8c79b3587b4ff6cf677eb4b6a85d lib/galaxy/webapps/tool_shed/controllers/admin.py --- a/lib/galaxy/webapps/tool_shed/controllers/admin.py +++ b/lib/galaxy/webapps/tool_shed/controllers/admin.py @@ -307,7 +307,7 @@ message = util.restore_text( kwd.get( 'message', '' ) ) status = kwd.get( 'status', 'done' ) repositories_select_field = suc.build_repository_ids_select_field( trans ) - return trans.fill_template( '/webapps/tool_shed/admin/reset_metadata_on_selected_repositories.mako', + return trans.fill_template( '/webapps/tool_shed/common/reset_metadata_on_selected_repositories.mako', repositories_select_field=repositories_select_field, message=message, status=status ) diff -r 052c1a1080a2ef5812a0b25c4e65f6d437b9fa52 -r d336d338debe8c79b3587b4ff6cf677eb4b6a85d 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 @@ -657,9 +657,10 @@ @web.expose def browse_repository( self, trans, id, **kwd ): - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) - commit_message = kwd.get( 'commit_message', 'Deleted selected files' ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) + commit_message = util.restore_text( params.get( 'commit_message', 'Deleted selected files' ) ) repository = suc.get_repository_in_tool_shed( trans, id ) repo = hg.repository( suc.get_configured_ui(), repository.repo_path( trans.app ) ) # Update repository files for browsing. @@ -832,13 +833,14 @@ @web.expose def check_for_updates( self, trans, **kwd ): """Handle a request from a local Galaxy instance.""" - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) # If the request originated with the UpdateManager, it will not include a galaxy_url. galaxy_url = suc.handle_galaxy_url( trans, **kwd ) - name = kwd.get( 'name', None ) - owner = kwd.get( 'owner', None ) - changeset_revision = kwd.get( 'changeset_revision', None ) + name = params.get( 'name', None ) + owner = params.get( 'owner', None ) + changeset_revision = params.get( 'changeset_revision', None ) repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) repo_dir = repository.repo_path( trans.app ) repo = hg.repository( suc.get_configured_ui(), repo_dir ) @@ -911,8 +913,9 @@ @web.expose def contact_owner( self, trans, id, **kwd ): - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) repository = suc.get_repository_in_tool_shed( trans, id ) metadata = self.get_metadata( trans, id, repository.tip( trans.app ) ) if trans.user and trans.user.email: @@ -945,8 +948,9 @@ @web.expose def create_repository( self, trans, **kwd ): - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) categories = suc.get_categories( trans ) if not categories: message = 'No categories have been configured in this instance of the Galaxy Tool Shed. ' + \ @@ -956,12 +960,12 @@ action='browse_repositories', message=message, status=status ) ) - name = kwd.get( 'name', '' ) - description = kwd.get( 'description', '' ) - long_description = kwd.get( 'long_description', '' ) - category_ids = util.listify( kwd.get( 'category_id', '' ) ) + name = util.restore_text( params.get( 'name', '' ) ) + description = util.restore_text( params.get( 'description', '' ) ) + long_description = util.restore_text( params.get( 'long_description', '' ) ) + category_ids = util.listify( params.get( 'category_id', '' ) ) selected_categories = [ trans.security.decode_id( id ) for id in category_ids ] - if kwd.get( 'create_repository_button', False ): + if params.get( 'create_repository_button', False ): error = False message = self.__validate_repository_name( name, trans.user ) if message: @@ -1027,11 +1031,12 @@ """Mark a repository in the tool shed as deprecated or not deprecated.""" # Marking a repository in the tool shed as deprecated has no effect on any downloadable changeset revisions that may be associated with the # repository. Revisions are not marked as not downlaodable because those that have installed the repository must be allowed to get updates. - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) - repository_id = kwd.get( 'id', None ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) + repository_id = params.get( 'id', None ) repository = suc.get_repository_in_tool_shed( trans, repository_id ) - mark_deprecated = util.string_as_bool( kwd.get( 'mark_deprecated', False ) ) + mark_deprecated = util.string_as_bool( params.get( 'mark_deprecated', False ) ) repository.deprecated = mark_deprecated trans.sa_session.add( repository ) trans.sa_session.flush() @@ -1047,8 +1052,9 @@ @web.expose def display_tool( self, trans, repository_id, tool_config, changeset_revision, **kwd ): - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) repository, tool, message = tool_util.load_tool_from_changeset_revision( trans, repository_id, changeset_revision, tool_config ) if message: status = 'error' @@ -1099,6 +1105,7 @@ @web.expose def download( self, trans, repository_id, changeset_revision, file_type, **kwd ): # Download an archive of the repository files compressed as zip, gz or bz2. + params = util.Params( kwd ) repository = suc.get_repository_in_tool_shed( trans, repository_id ) # Allow hgweb to handle the download. This requires the tool shed # server account's .hgrc file to include the following setting: @@ -1118,8 +1125,9 @@ @web.expose def find_tools( self, trans, **kwd ): - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) galaxy_url = suc.handle_galaxy_url( trans, **kwd ) if 'operation' in kwd: item_id = kwd.get( 'id', '' ) @@ -1161,7 +1169,7 @@ tool_ids = [ item.lower() for item in util.listify( kwd.get( 'tool_id', '' ) ) ] tool_names = [ item.lower() for item in util.listify( kwd.get( 'tool_name', '' ) ) ] tool_versions = [ item.lower() for item in util.listify( kwd.get( 'tool_version', '' ) ) ] - exact_matches = kwd.get( 'exact_matches', '' ) + exact_matches = params.get( 'exact_matches', '' ) exact_matches_checked = CheckboxField.is_checked( exact_matches ) match_tuples = [] ok = True @@ -1202,8 +1210,9 @@ @web.expose def find_workflows( self, trans, **kwd ): - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) galaxy_url = suc.handle_galaxy_url( trans, **kwd ) if 'operation' in kwd: item_id = kwd.get( 'id', '' ) @@ -1244,7 +1253,7 @@ return trans.show_error_message( "No items were selected." ) if 'find_workflows_button' in kwd: workflow_names = [ item.lower() for item in util.listify( kwd.get( 'workflow_name', '' ) ) ] - exact_matches = kwd.get( 'exact_matches', '' ) + exact_matches = params.get( 'exact_matches', '' ) exact_matches_checked = CheckboxField.is_checked( exact_matches ) match_tuples = [] ok = True @@ -1318,11 +1327,12 @@ if 'workflows' in metadata: includes_workflows = True return includes_data_managers, includes_datatypes, includes_tools, includes_tools_for_display_in_tool_panel, includes_tool_dependencies, has_repository_dependencies, includes_workflows - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) - name = kwd.get( 'name', None ) - owner = kwd.get( 'owner', None ) - changeset_revision = kwd.get( 'changeset_revision', None ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) + name = params.get( 'name', None ) + owner = params.get( 'owner', None ) + changeset_revision = params.get( 'changeset_revision', None ) repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) repository_metadata = suc.get_repository_metadata_by_changeset_revision( trans, trans.security.encode_id( repository.id ), @@ -1522,9 +1532,10 @@ @web.json def get_repository_dependencies( self, trans, **kwd ): """Return an encoded dictionary of all repositories upon which the contents of the received repository depends.""" - name = kwd.get( 'name', None ) - owner = kwd.get( 'owner', None ) - changeset_revision = kwd.get( 'changeset_revision', None ) + params = util.Params( kwd ) + name = params.get( 'name', None ) + owner = params.get( 'owner', None ) + changeset_revision = params.get( 'changeset_revision', None ) repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) repository_id = trans.security.encode_id( repository.id ) repository_metadata = suc.get_repository_metadata_by_changeset_revision( trans, repository_id, changeset_revision ) @@ -1618,9 +1629,10 @@ @web.expose def get_tool_dependencies( self, trans, **kwd ): """Handle a request from a Galaxy instance to get the tool_dependencies entry from the metadata for a specified changeset revision.""" - name = kwd.get( 'name', None ) - owner = kwd.get( 'owner', None ) - changeset_revision = kwd.get( 'changeset_revision', None ) + params = util.Params( kwd ) + name = params.get( 'name', None ) + owner = params.get( 'owner', None ) + changeset_revision = params.get( 'changeset_revision', None ) repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) for downloadable_revision in repository.downloadable_revisions: if downloadable_revision.changeset_revision == changeset_revision: @@ -1634,9 +1646,10 @@ @web.expose def get_tool_dependencies_config_contents( self, trans, **kwd ): """Handle a request from a Galaxy instance to get the tool_dependencies.xml file contents for a specified changeset revision.""" - name = kwd.get( 'name', None ) - owner = kwd.get( 'owner', None ) - changeset_revision = kwd.get( 'changeset_revision', None ) + params = util.Params( kwd ) + name = params.get( 'name', None ) + owner = params.get( 'owner', None ) + changeset_revision = params.get( 'changeset_revision', None ) repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) # TODO: We're currently returning the tool_dependencies.xml file that is available on disk. We need to enhance this process # to retrieve older versions of the tool-dependencies.xml file from the repository manafest. @@ -1773,8 +1786,9 @@ @web.expose def help( self, trans, **kwd ): - message = util.restore_text( kwd.get( 'message', '' ) ) - status = kwd.get( 'status', 'done' ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) return trans.fill_template( '/webapps/tool_shed/repository/help.mako', message=message, status=status, **kwd ) def __in_tool_dict( self, tool_dict, exact_matches_checked, tool_id=None, tool_name=None, tool_version=None ): @@ -1826,8 +1840,9 @@ @web.expose def index( self, trans, **kwd ): - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) # See if there are any RepositoryMetadata records since menu items require them. repository_metadata = trans.sa_session.query( model.RepositoryMetadata ).first() current_user = trans.user @@ -1846,9 +1861,9 @@ break # Route in may have been from a sharable URL, in whcih case we'll have a user_id and possibly a name # The received user_id will be the id of the repository owner. - user_id = kwd.get( 'user_id', None ) - repository_id = kwd.get( 'repository_id', None ) - changeset_revision = kwd.get( 'changeset_revision', None ) + user_id = params.get( 'user_id', None ) + repository_id = params.get( 'repository_id', None ) + changeset_revision = params.get( 'changeset_revision', None ) return trans.fill_template( '/webapps/tool_shed/index.mako', repository_metadata=repository_metadata, has_reviewed_repositories=has_reviewed_repositories, @@ -1889,8 +1904,9 @@ @web.expose def load_invalid_tool( self, trans, repository_id, tool_config, changeset_revision, **kwd ): - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'error' ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'error' ) repository, tool, error_message = tool_util.load_tool_from_changeset_revision( trans, repository_id, changeset_revision, tool_config ) tool_state = self.__new_state( trans ) invalid_file_tups = [] @@ -1942,12 +1958,13 @@ @web.expose @web.require_login( "manage email alerts" ) def manage_email_alerts( self, trans, **kwd ): - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) - new_repo_alert = kwd.get( 'new_repo_alert', '' ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) + new_repo_alert = params.get( 'new_repo_alert', '' ) new_repo_alert_checked = CheckboxField.is_checked( new_repo_alert ) user = trans.user - if kwd.get( 'new_repo_alert_button', False ): + if params.get( 'new_repo_alert_button', False ): user.new_repo_alert = new_repo_alert_checked trans.sa_session.add( user ) trans.sa_session.flush() @@ -2206,8 +2223,9 @@ @web.expose @web.require_login( "multi select email alerts" ) def multi_select_email_alerts( self, trans, **kwd ): - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) if 'operation' in kwd: operation = kwd[ 'operation' ].lower() if operation == "receive email alerts": @@ -2245,12 +2263,13 @@ @web.expose def preview_tools_in_changeset( self, trans, repository_id, **kwd ): - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) repository = suc.get_repository_in_tool_shed( trans, repository_id ) repo_dir = repository.repo_path( trans.app ) repo = hg.repository( suc.get_configured_ui(), repo_dir ) - changeset_revision = kwd.get( 'changeset_revision', repository.tip( trans.app ) ) + changeset_revision = util.restore_text( params.get( 'changeset_revision', repository.tip( trans.app ) ) ) repository_metadata = suc.get_repository_metadata_by_changeset_revision( trans, repository_id, changeset_revision ) if repository_metadata: repository_metadata_id = trans.security.encode_id( repository_metadata.id ), @@ -2297,11 +2316,12 @@ older changeset_revsion, but later the repository was updated in the tool shed and the Galaxy admin is trying to install the latest changeset revision of the same repository instead of updating the one that was previously installed. """ - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) - name = kwd.get( 'name', None ) - owner = kwd.get( 'owner', None ) - changeset_revision = kwd.get( 'changeset_revision', None ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) + name = params.get( 'name', None ) + owner = params.get( 'owner', None ) + changeset_revision = params.get( 'changeset_revision', None ) repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) repo_dir = repository.repo_path( trans.app ) repo = hg.repository( suc.get_configured_ui(), repo_dir ) @@ -2320,9 +2340,10 @@ @web.require_login( "rate repositories" ) def rate_repository( self, trans, **kwd ): """ Rate a repository and return updated rating data. """ - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) - id = kwd.get( 'id', None ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) + id = params.get( 'id', None ) if not id: return trans.response.send_redirect( web.url_for( controller='repository', action='browse_repositories', @@ -2335,12 +2356,12 @@ action='browse_repositories', message="You are not allowed to rate your own repository", status='error' ) ) - if kwd.get( 'rate_button', False ): - rating = int( kwd.get( 'rating', '0' ) ) - comment = kwd.get( 'comment', '' ) + if params.get( 'rate_button', False ): + rating = int( params.get( 'rating', '0' ) ) + comment = util.restore_text( params.get( 'comment', '' ) ) rating = self.rate_item( trans, trans.user, repository, rating, comment ) avg_rating, num_ratings = self.get_ave_item_rating_data( trans.sa_session, repository, webapp_model=trans.model ) - display_reviews = util.string_as_bool( kwd.get( 'display_reviews', False ) ) + display_reviews = util.string_as_bool( params.get( 'display_reviews', False ) ) rra = self.get_user_item_rating( trans.sa_session, trans.user, repository, webapp_model=trans.model ) metadata = self.get_metadata( trans, id, repository.tip( trans.app ) ) return trans.fill_template( '/webapps/tool_shed/repository/rate_repository.mako', @@ -2371,6 +2392,19 @@ message=message, status=status ) ) + @web.expose + def reset_metadata_on_my_writable_repositories_in_tool_shed( self, trans, **kwd ): + if 'reset_metadata_on_selected_repositories_button' in kwd: + message, status = metadata_util.reset_metadata_on_selected_repositories( trans, **kwd ) + else: + message = util.restore_text( kwd.get( 'message', '' ) ) + status = kwd.get( 'status', 'done' ) + repositories_select_field = suc.build_repository_ids_select_field( trans, my_writable=True ) + return trans.fill_template( '/webapps/tool_shed/common/reset_metadata_on_selected_repositories.mako', + repositories_select_field=repositories_select_field, + message=message, + status=status ) + def __search_ids_names( self, tool_dict, exact_matches_checked, match_tuples, repository_metadata, tool_ids, tool_names ): for i, tool_id in enumerate( tool_ids ): tool_name = tool_names[ i ] @@ -2473,14 +2507,15 @@ @web.expose def select_files_to_delete( self, trans, id, **kwd ): - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) - commit_message = kwd.get( 'commit_message', 'Deleted selected files' ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) + commit_message = util.restore_text( params.get( 'commit_message', 'Deleted selected files' ) ) repository = suc.get_repository_in_tool_shed( trans, id ) repo_dir = repository.repo_path( trans.app ) repo = hg.repository( suc.get_configured_ui(), repo_dir ) - selected_files_to_delete = kwd.get( 'selected_files_to_delete', '' ) - if kwd.get( 'select_files_to_delete_button', False ): + selected_files_to_delete = util.restore_text( params.get( 'selected_files_to_delete', '' ) ) + if params.get( 'select_files_to_delete_button', False ): if selected_files_to_delete: selected_files_to_delete = selected_files_to_delete.split( ',' ) # Get the current repository tip. @@ -2736,9 +2771,10 @@ revision for the required repository, making it impossible to discover the repository without knowledge of revisions to which it could have been updated. """ - name = kwd.get( 'name', None ) - owner = kwd.get( 'owner', None ) - changeset_revision = kwd.get( 'changeset_revision', None ) + params = util.Params( kwd ) + name = params.get( 'name', None ) + owner = params.get( 'owner', None ) + changeset_revision = params.get( 'changeset_revision', None ) repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) repo_dir = repository.repo_path( trans.app ) repo = hg.repository( suc.get_configured_ui(), repo_dir ) @@ -2775,8 +2811,9 @@ @web.expose def view_changelog( self, trans, id, **kwd ): - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) repository = suc.get_repository_in_tool_shed( trans, id ) repo = hg.repository( suc.get_configured_ui(), repository.repo_path( trans.app ) ) changesets = [] @@ -2810,8 +2847,9 @@ @web.expose def view_changeset( self, trans, id, ctx_str, **kwd ): - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) repository = suc.get_repository_in_tool_shed( trans, id ) repo = hg.repository( suc.get_configured_ui(), repository.repo_path( trans.app ) ) ctx = suc.get_changectx_for_changeset( repo, ctx_str ) @@ -2887,14 +2925,15 @@ @web.expose def view_repository( self, trans, id, **kwd ): - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) repository = suc.get_repository_in_tool_shed( trans, id ) repo = hg.repository( suc.get_configured_ui(), repository.repo_path( trans.app ) ) avg_rating, num_ratings = self.get_ave_item_rating_data( trans.sa_session, repository, webapp_model=trans.model ) - changeset_revision = kwd.get( 'changeset_revision', repository.tip( trans.app ) ) - display_reviews = util.string_as_bool( kwd.get( 'display_reviews', False ) ) - alerts = kwd.get( 'alerts', '' ) + changeset_revision = util.restore_text( params.get( 'changeset_revision', repository.tip( trans.app ) ) ) + display_reviews = util.string_as_bool( params.get( 'display_reviews', False ) ) + alerts = params.get( 'alerts', '' ) alerts_checked = CheckboxField.is_checked( alerts ) if repository.email_alerts: email_alerts = json.from_json_string( repository.email_alerts ) @@ -2902,7 +2941,7 @@ email_alerts = [] repository_dependencies = None user = trans.user - if user and kwd.get( 'receive_email_alerts_button', False ): + if user and params.get( 'receive_email_alerts_button', False ): flush_needed = False if alerts_checked: if user.email not in email_alerts: @@ -2970,8 +3009,9 @@ @web.expose def view_tool_metadata( self, trans, repository_id, changeset_revision, tool_id, **kwd ): - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) repository = suc.get_repository_in_tool_shed( trans, repository_id ) repo_files_dir = repository.repo_path( trans.app ) repo = hg.repository( suc.get_configured_ui(), repo_files_dir ) @@ -3041,8 +3081,9 @@ @web.expose def view_workflow( self, trans, workflow_name, repository_metadata_id, **kwd ): """Retrieve necessary information about a workflow from the database so that it can be displayed in an svg image.""" - message = kwd.get( 'message', '' ) - status = kwd.get( 'status', 'done' ) + params = util.Params( kwd ) + message = util.restore_text( params.get( 'message', '' ) ) + status = params.get( 'status', 'done' ) if workflow_name: workflow_name = encoding_util.tool_shed_decode( workflow_name ) repository_metadata = metadata_util.get_repository_metadata_by_id( trans, repository_metadata_id ) diff -r 052c1a1080a2ef5812a0b25c4e65f6d437b9fa52 -r d336d338debe8c79b3587b4ff6cf677eb4b6a85d lib/tool_shed/grids/repository_grids.py --- a/lib/tool_shed/grids/repository_grids.py +++ b/lib/tool_shed/grids/repository_grids.py @@ -121,7 +121,7 @@ return escape_html( repository.revision( trans.app ) ) - class ToolsFunctionallyCorrectColumn( grids.TextColumn ): + class ToolsFunctionallyCorrectColumn( grids.BooleanColumn ): def get_value( self, trans, grid, repository ): # This column will display the value associated with the currently displayed metadata revision. @@ -1130,7 +1130,7 @@ return '' - class ToolsFunctionallyCorrectColumn( grids.TextColumn ): + class ToolsFunctionallyCorrectColumn( grids.BooleanColumn ): def get_value( self, trans, grid, repository ): # This column will display the value associated with the currently displayed metadata revision. diff -r 052c1a1080a2ef5812a0b25c4e65f6d437b9fa52 -r d336d338debe8c79b3587b4ff6cf677eb4b6a85d lib/tool_shed/util/shed_util_common.py --- a/lib/tool_shed/util/shed_util_common.py +++ b/lib/tool_shed/util/shed_util_common.py @@ -12,6 +12,7 @@ from galaxy.web.form_builder import SelectField from galaxy.datatypes import checkers from galaxy.model.orm import and_ +from galaxy.model.orm import or_ import sqlalchemy.orm.exc from tool_shed.util import common_util from tool_shed.util import xml_util @@ -88,19 +89,39 @@ '${host}' """ -def build_repository_ids_select_field( trans, name='repository_ids', multiple=True, display='checkboxes' ): +def build_repository_ids_select_field( trans, name='repository_ids', multiple=True, display='checkboxes', my_writable=False ): """Method called from both Galaxy and the Tool Shed to generate the current list of repositories for resetting metadata.""" repositories_select_field = SelectField( name=name, multiple=multiple, display=display ) if trans.webapp.name == 'tool_shed': # We're in the tool shed. - for repository in trans.sa_session.query( trans.model.Repository ) \ - .filter( trans.model.Repository.table.c.deleted == False ) \ - .order_by( trans.model.Repository.table.c.name, - trans.model.Repository.table.c.user_id ): - owner = repository.user.username - option_label = '%s (%s)' % ( repository.name, owner ) - option_value = '%s' % trans.security.encode_id( repository.id ) - repositories_select_field.add_option( option_label, option_value ) + if my_writable: + username = trans.user.username + clause_list = [] + for repository in trans.sa_session.query( trans.model.Repository ) \ + .filter( trans.model.Repository.table.c.deleted == False ): + allow_push = repository.allow_push( trans.app ) + if allow_push: + allow_push_usernames = allow_push.split( ',' ) + if username in allow_push_usernames: + clause_list.append( trans.model.Repository.table.c.id == repository.id ) + if clause_list: + for repository in trans.sa_session.query( trans.model.Repository ) \ + .filter( or_( *clause_list ) ) \ + .order_by( trans.model.Repository.table.c.name, + trans.model.Repository.table.c.user_id ): + owner = repository.user.username + option_label = '%s (%s)' % ( repository.name, owner ) + option_value = '%s' % trans.security.encode_id( repository.id ) + repositories_select_field.add_option( option_label, option_value ) + else: + for repository in trans.sa_session.query( trans.model.Repository ) \ + .filter( trans.model.Repository.table.c.deleted == False ) \ + .order_by( trans.model.Repository.table.c.name, + trans.model.Repository.table.c.user_id ): + owner = repository.user.username + option_label = '%s (%s)' % ( repository.name, owner ) + option_value = '%s' % trans.security.encode_id( repository.id ) + repositories_select_field.add_option( option_label, option_value ) else: # We're in Galaxy. for repository in trans.sa_session.query( trans.model.ToolShedRepository ) \ diff -r 052c1a1080a2ef5812a0b25c4e65f6d437b9fa52 -r d336d338debe8c79b3587b4ff6cf677eb4b6a85d templates/webapps/tool_shed/admin/reset_metadata_on_selected_repositories.mako --- a/templates/webapps/tool_shed/admin/reset_metadata_on_selected_repositories.mako +++ /dev/null @@ -1,40 +0,0 @@ -<%inherit file="/base.mako"/> -<%namespace file="/message.mako" import="render_msg" /> -<%namespace file="/webapps/tool_shed/common/common.mako" import="common_misc_javascripts" /> - -<%def name="javascripts()"> - ${parent.javascripts()} - ${common_misc_javascripts()} -</%def> - -%if message: - ${render_msg( message, status )} -%endif - -<div class="warningmessage"> - Resetting metadata may take a while because this process clones each change set in each selected repository's change log to a temporary location on disk. - Wait until this page redirects after clicking the <b>Reset metadata on selected repositories</b> button, as doing anything else will not be helpful. Watch - the tool shed paster log to pass the time if necessary. -</div> - -<div class="toolForm"> - <div class="toolFormTitle">Reset all metadata on each selected repository</div> - <form name="reset_metadata_on_selected_repositories" id="reset_metadata_on_selected_repositories" action="${h.url_for( controller='admin', action='reset_metadata_on_selected_repositories_in_tool_shed' )}" method="post" > - <div class="form-row"> - Check each repository for which you want to reset metadata. Repository names are followed by owners in parentheses. - </div> - <div style="clear: both"></div> - <div class="form-row"> - <input type="checkbox" id="checkAll" name="select_all_repositories_checkbox" value="true" onclick="checkAllFields('repository_ids');"/><input type="hidden" name="select_all_repositories_checkbox" value="true"/><b>Select/unselect all repositories</b> - </div> - <div style="clear: both"></div> - <div class="form-row"> - ${repositories_select_field.get_html()} - </div> - <div style="clear: both"></div> - <div class="form-row"> - <input type="submit" name="reset_metadata_on_selected_repositories_button" value="Reset metadata on selected repositories"/> - </div> - </form> - </div> -</div> diff -r 052c1a1080a2ef5812a0b25c4e65f6d437b9fa52 -r d336d338debe8c79b3587b4ff6cf677eb4b6a85d templates/webapps/tool_shed/common/reset_metadata_on_selected_repositories.mako --- /dev/null +++ b/templates/webapps/tool_shed/common/reset_metadata_on_selected_repositories.mako @@ -0,0 +1,40 @@ +<%inherit file="/base.mako"/> +<%namespace file="/message.mako" import="render_msg" /> +<%namespace file="/webapps/tool_shed/common/common.mako" import="common_misc_javascripts" /> + +<%def name="javascripts()"> + ${parent.javascripts()} + ${common_misc_javascripts()} +</%def> + +%if message: + ${render_msg( message, status )} +%endif + +<div class="warningmessage"> + Resetting metadata may take a while because this process clones each change set in each selected repository's change log to a temporary location on disk. + Wait until this page redirects after clicking the <b>Reset metadata on selected repositories</b> button, as doing anything else will not be helpful. Watch + the tool shed paster log to pass the time if necessary. +</div> + +<div class="toolForm"> + <div class="toolFormTitle">Reset all metadata on each selected repository</div> + <form name="reset_metadata_on_selected_repositories" id="reset_metadata_on_selected_repositories" action="${h.url_for( controller='admin', action='reset_metadata_on_selected_repositories_in_tool_shed' )}" method="post" > + <div class="form-row"> + Check each repository for which you want to reset metadata. Repository names are followed by owners in parentheses. + </div> + <div style="clear: both"></div> + <div class="form-row"> + <input type="checkbox" id="checkAll" name="select_all_repositories_checkbox" value="true" onclick="checkAllFields('repository_ids');"/><input type="hidden" name="select_all_repositories_checkbox" value="true"/><b>Select/unselect all repositories</b> + </div> + <div style="clear: both"></div> + <div class="form-row"> + ${repositories_select_field.get_html()} + </div> + <div style="clear: both"></div> + <div class="form-row"> + <input type="submit" name="reset_metadata_on_selected_repositories_button" value="Reset metadata on selected repositories"/> + </div> + </form> + </div> +</div> diff -r 052c1a1080a2ef5812a0b25c4e65f6d437b9fa52 -r d336d338debe8c79b3587b4ff6cf677eb4b6a85d templates/webapps/tool_shed/index.mako --- a/templates/webapps/tool_shed/index.mako +++ b/templates/webapps/tool_shed/index.mako @@ -114,6 +114,9 @@ <a target="galaxy_main" href="${h.url_for( controller='repository', action='browse_my_writable_repositories' )}">My writable repositories</a></div><div class="toolTitle"> + <a target="galaxy_main" href="${h.url_for( controller='repository', action='reset_metadata_on_my_writable_repositories_in_tool_shed' )}">Reset metadata on my repositories</a> + </div> + <div class="toolTitle"><a target="galaxy_main" href="${h.url_for( controller='repository', action='browse_my_writable_repositories_missing_tool_test_components' )}">Latest revision: missing tool tests</a></div><div class="toolTitle"> 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