1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/af9b19b57969/ changeset: af9b19b57969 user: greg date: 2011-07-12 19:51:28 summary: Make a backup copy of the tool shed's hgweb.config file just before changes are made to it. Add the ability for a repository owner to change categories associated with their repository. affected #: 4 files (3.8 KB) --- a/lib/galaxy/webapps/community/controllers/repository.py Tue Jul 12 10:07:15 2011 -0400 +++ b/lib/galaxy/webapps/community/controllers/repository.py Tue Jul 12 13:51:28 2011 -0400 @@ -356,11 +356,19 @@ if not( VALID_REPOSITORYNAME_RE.match( name ) ): return "Repository names must contain only lower-case letters, numbers and underscore '_'." return '' + def __make_hgweb_config_copy( self, trans, hgweb_config ): + # Make a backup of the hgweb.config file + today = date.today() + backup_date = today.strftime( "%Y_%m_%d" ) + hgweb_config_copy = '%s/hgweb.config_%s_backup' % ( trans.app.config.root, backup_date ) + shutil.copy( os.path.abspath( hgweb_config ), os.path.abspath( hgweb_config_copy ) ) def __add_hgweb_config_entry( self, trans, repository, repository_path ): # Add an entry in the hgweb.config file for a new repository. # An entry looks something like: # repos/test/mira_assembler = database/community_files/000/repo_123. hgweb_config = "%s/hgweb.config" % trans.app.config.root + # Make a backup of the hgweb.config file since we're going to be changing it. + self.__make_hgweb_config_copy( trans, hgweb_config ) entry = "repos/%s/%s = %s" % ( repository.user.username, repository.name, repository_path.lstrip( './' ) ) if os.path.exists( hgweb_config ): output = open( hgweb_config, 'a' ) @@ -374,6 +382,8 @@ # the owner changes the name of the repository. An entry looks something like: # repos/test/mira_assembler = database/community_files/000/repo_123. hgweb_config = "%s/hgweb.config" % trans.app.config.root + # Make a backup of the hgweb.config file since we're going to be changing it. + self.__make_hgweb_config_copy( trans, hgweb_config ) repo_dir = repository.repo_path old_lhs = "repos/%s/%s" % ( repository.user.username, old_repository_name ) old_entry = "%s = %s" % ( old_lhs, repo_dir ) @@ -537,6 +547,7 @@ display_reviews = util.string_as_bool( params.get( 'display_reviews', False ) ) alerts = params.get( 'alerts', '' ) alerts_checked = CheckboxField.is_checked( alerts ) + category_ids = util.listify( params.get( 'category_id', '' ) ) if repository.email_alerts: email_alerts = from_json_string( repository.email_alerts ) else: @@ -572,7 +583,21 @@ if flush_needed: trans.sa_session.add( repository ) trans.sa_session.flush() - message = "The repository information has been updated." + message = "The repository information has been updated." + elif params.get( 'manage_categories_button', False ): + flush_needed = False + # Delete all currently existing categories. + for rca in repository.categories: + trans.sa_session.delete( rca ) + trans.sa_session.flush() + if category_ids: + # Create category associations + for category_id in category_ids: + category = trans.app.model.Category.get( trans.security.decode_id( category_id ) ) + rca = trans.app.model.RepositoryCategoryAssociation( repository, category ) + trans.sa_session.add( rca ) + trans.sa_session.flush() + message = "The repository information has been updated." elif params.get( 'user_access_button', False ): if allow_push not in [ 'none' ]: remove_auth = params.get( 'remove_auth', '' ) @@ -586,6 +611,7 @@ usernames.append( user.username ) usernames = ','.join( usernames ) repository.set_allow_push( usernames, remove_auth=remove_auth ) + message = "The repository information has been updated." elif params.get( 'receive_email_alerts_button', False ): flush_needed = False if alerts_checked: @@ -601,6 +627,7 @@ if flush_needed: trans.sa_session.add( repository ) trans.sa_session.flush() + message = "The repository information has been updated." if error: status = 'error' if repository.allow_push: @@ -615,6 +642,8 @@ metadata = repository_metadata.metadata else: metadata = None + categories = get_categories( trans ) + selected_categories = [ rca.category_id for rca in repository.categories ] return trans.fill_template( '/webapps/community/repository/manage_repository.mako', repo_name=repo_name, description=description, @@ -623,6 +652,8 @@ allow_push_select_field=allow_push_select_field, repo=repo, repository=repository, + selected_categories=selected_categories, + categories=categories, metadata=metadata, avg_rating=avg_rating, display_reviews=display_reviews, --- a/templates/webapps/community/repository/create_repository.mako Tue Jul 12 10:07:15 2011 -0400 +++ b/templates/webapps/community/repository/create_repository.mako Tue Jul 12 13:51:28 2011 -0400 @@ -38,7 +38,7 @@ <div style="clear: both"></div></div><div class="form-row"> - <label>Category</label> + <label>Categories</label><div class="form-row"><select name="category_id" multiple> %for category in categories: @@ -50,6 +50,9 @@ %endfor </select></div> + <div class="toolParamHelp" style="clear: both;"> + Multi-select list - hold the appropriate key while clicking to select multiple categories. + </div><div style="clear: both"></div></div><div class="form-row"> --- a/templates/webapps/community/repository/manage_repository.mako Tue Jul 12 10:07:15 2011 -0400 +++ b/templates/webapps/community/repository/manage_repository.mako Tue Jul 12 13:51:28 2011 -0400 @@ -151,6 +151,34 @@ </form></div></div> +<p/> +<div class="toolForm"> + <div class="toolFormTitle">Manage categories</div> + <div class="toolFormBody"> + <form name="categories" id="categories" action="${h.url_for( controller='repository', action='manage_repository', id=trans.security.encode_id( repository.id ) )}" method="post" > + <div class="form-row"> + <label>Categories</label> + <select name="category_id" multiple> + %for category in categories: + %if category.id in selected_categories: + <option value="${trans.security.encode_id( category.id )}" selected>${category.name}</option> + %else: + <option value="${trans.security.encode_id( category.id )}">${category.name}</option> + %endif + %endfor + </select> + <div class="toolParamHelp" style="clear: both;"> + Multi-select list - hold the appropriate key while clicking to select multiple categories. + </div> + <div style="clear: both"></div> + </div> + <div class="form-row"> + <input type="submit" name="manage_categories_button" value="Save"/> + </div> + </form> + </div> +</div> +<p/> %if can_set_metadata: <p/><div class="toolForm"> @@ -215,7 +243,7 @@ %if trans.app.config.smtp_server: <p/><div class="toolForm"> - <div class="toolFormTitle">${repository.name}</div> + <div class="toolFormTitle">Notification on update</div><div class="toolFormBody"><form name="receive_email_alerts" id="receive_email_alerts" action="${h.url_for( controller='repository', action='manage_repository', id=trans.security.encode_id( repository.id ) )}" method="post" ><div class="form-row"> --- a/templates/webapps/community/repository/view_repository.mako Tue Jul 12 10:07:15 2011 -0400 +++ b/templates/webapps/community/repository/view_repository.mako Tue Jul 12 13:51:28 2011 -0400 @@ -145,6 +145,20 @@ %endif </div></div> +%if repository.categories: + <p/> + <div class="toolForm"> + <div class="toolFormTitle">Categories</div> + <div class="toolFormBody"> + %for rca in repository.categories: + <div class="form-row"> + ${rca.category.name} + </div> + %endfor + <div style="clear: both"></div> + </div> + </div> +%endif %if metadata: <p/><div class="toolForm"> @@ -197,7 +211,7 @@ %if trans.user and trans.app.config.smtp_server: <p/><div class="toolForm"> - <div class="toolFormTitle">${repository.name}</div> + <div class="toolFormTitle">Notification on update</div><div class="toolFormBody"><form name="receive_email_alerts" id="receive_email_alerts" action="${h.url_for( controller='repository', action='view_repository', id=trans.security.encode_id( repository.id ) )}" method="post" ><div class="form-row"> 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.