commit/galaxy-central: greg: Add new long description and number of times downloaded features for tool shed repositories. Fix a bug when rating a repository. Fix a bug when calls to email_alerts are made.
1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/372577e7bc6a/ changeset: 372577e7bc6a user: greg date: 2011-06-28 21:45:56 summary: Add new long description and number of times downloaded features for tool shed repositories. Fix a bug when rating a repository. Fix a bug when calls to email_alerts are made. affected #: 11 files (3.4 KB) --- a/lib/galaxy/model/migrate/versions/0065_add_name_to_form_fields_and_values.py Tue Jun 28 11:03:55 2011 -0400 +++ b/lib/galaxy/model/migrate/versions/0065_add_name_to_form_fields_and_values.py Tue Jun 28 15:45:56 2011 -0400 @@ -14,8 +14,14 @@ import datetime now = datetime.datetime.utcnow -import logging +import sys, logging log = logging.getLogger( __name__ ) +log.setLevel(logging.DEBUG) +handler = logging.StreamHandler( sys.stdout ) +format = "%(name)s %(levelname)s %(asctime)s %(message)s" +formatter = logging.Formatter( format ) +handler.setFormatter( formatter ) +log.addHandler( handler ) metadata = MetaData( migrate_engine ) db_session = scoped_session( sessionmaker( bind=migrate_engine, autoflush=False, autocommit=True ) ) @@ -42,18 +48,24 @@ cmd = "SELECT f.id, f.fields FROM form_definition AS f" result = db_session.execute( cmd ) for row in result: + log.debug("Line 51 ROW: %s" % str( row )) form_definition_id = row[0] + log.debug("form_definition_id: %s" % str( form_definition_id )) fields = str( row[1] ) + log.debug("fields: %s" % str( fields )) if not fields.strip(): continue fields_list = from_json_string( fields ) + log.debug("fields_list: %s" % str( fields_list )) if len( fields_list ): for index, field in enumerate( fields_list ): field[ 'name' ] = 'field_%i' % index field[ 'helptext' ] = field[ 'helptext' ].replace("'", "''").replace('"', "") field[ 'label' ] = field[ 'label' ].replace("'", "''") fields_json = to_json_string( fields_list ) + log.debug("fields_json: %s" % str( fields_json )) cmd = "UPDATE form_definition AS f SET f.fields='%s' WHERE f.id=%i" %( fields_json, form_definition_id ) + log.debug("cmd: %s" % str( cmd )) db_session.execute( cmd ) # replace the values list in the content field of the form_values table with a name:value dict cmd = "SELECT form_values.id, form_values.content, form_definition.fields" \ @@ -115,6 +127,7 @@ cmd = "SELECT f.id, f.fields FROM form_definition AS f" result = db_session.execute( cmd ) for row in result: + og.debug("Line 124 ROW: %s" % str( row )) form_definition_id = row[0] fields = str( row[1] ) if not fields.strip(): --- a/lib/galaxy/webapps/community/controllers/repository.py Tue Jun 28 11:03:55 2011 -0400 +++ b/lib/galaxy/webapps/community/controllers/repository.py Tue Jun 28 15:45:56 2011 -0400 @@ -282,6 +282,7 @@ status=status ) ) 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 params.get( 'create_repository_button', False ): @@ -294,7 +295,10 @@ error = True if not error: # Add the repository record to the db - repository = trans.app.model.Repository( name=name, description=description, user_id=trans.user.id ) + repository = trans.app.model.Repository( name=name, + description=description, + long_description=long_description, + user_id=trans.user.id ) # Flush to get the id trans.sa_session.add( repository ) trans.sa_session.flush() @@ -333,6 +337,7 @@ return trans.fill_template( '/webapps/community/repository/create_repository.mako', name=name, description=description, + long_description=long_description, selected_categories=selected_categories, categories=categories, message=message, @@ -498,6 +503,7 @@ tip = get_repository_tip( repo ) repo_name = util.restore_text( params.get( 'repo_name', repository.name ) ) description = util.restore_text( params.get( 'description', repository.description ) ) + long_description = util.restore_text( params.get( 'long_description', repository.long_description ) ) avg_rating, num_ratings = self.get_ave_item_rating_data( trans.sa_session, repository, webapp_model=trans.model ) display_reviews = util.string_as_bool( params.get( 'display_reviews', False ) ) alerts = params.get( 'alerts', '' ) @@ -529,6 +535,9 @@ if description != repository.description: repository.description = description flush_needed = True + if long_description != repository.long_description: + repository.long_description = long_description + flush_needed = True if flush_needed: trans.sa_session.add( repository ) trans.sa_session.flush() @@ -572,6 +581,7 @@ return trans.fill_template( '/webapps/community/repository/manage_repository.mako', repo_name=repo_name, description=description, + long_description=long_description, current_allow_push_list=current_allow_push_list, allow_push_select_field=allow_push_select_field, repo=repo, @@ -666,6 +676,8 @@ message='Select a repository to rate', status='error' ) ) repository = get_repository( trans, id ) + repo = hg.repository( ui.ui(), repository.repo_path ) + tip = get_repository_tip( repo ) if repository.user == trans.user: return trans.response.send_redirect( web.url_for( controller='repository', action='browse_repositories', @@ -680,6 +692,7 @@ rra = self.get_user_item_rating( trans.sa_session, trans.user, repository, webapp_model=trans.model ) return trans.fill_template( '/webapps/community/repository/rate_repository.mako', repository=repository, + tip=tip, avg_rating=avg_rating, display_reviews=display_reviews, num_ratings=num_ratings, @@ -691,34 +704,35 @@ # Set email alerts for selected repositories params = util.Params( kwd ) user = trans.user - repository_ids = util.listify( kwd.get( 'id', '' ) ) - total_alerts_added = 0 - total_alerts_removed = 0 - for repository_id in repository_ids: - flush_needed = False - repository = get_repository( trans, repository_id ) - if repository.email_alerts: - email_alerts = from_json_string( repository.email_alerts ) - else: - email_alerts = [] - if user.email in email_alerts: - email_alerts.remove( user.email ) - repository.email_alerts = to_json_string( email_alerts ) - trans.sa_session.add( repository ) - flush_needed = True - total_alerts_removed += 1 - else: - email_alerts.append( user.email ) - repository.email_alerts = to_json_string( email_alerts ) - trans.sa_session.add( repository ) - flush_needed = True - total_alerts_added += 1 - if flush_needed: - trans.sa_session.flush() - message = 'Total alerts added: %d, total alerts removed: %d' % ( total_alerts_added, total_alerts_removed ) - kwd[ 'message' ] = message - kwd[ 'status' ] = 'done' - del( kwd[ 'operation' ] ) + if user: + repository_ids = util.listify( kwd.get( 'id', '' ) ) + total_alerts_added = 0 + total_alerts_removed = 0 + for repository_id in repository_ids: + flush_needed = False + repository = get_repository( trans, repository_id ) + if repository.email_alerts: + email_alerts = from_json_string( repository.email_alerts ) + else: + email_alerts = [] + if user.email in email_alerts: + email_alerts.remove( user.email ) + repository.email_alerts = to_json_string( email_alerts ) + trans.sa_session.add( repository ) + flush_needed = True + total_alerts_removed += 1 + else: + email_alerts.append( user.email ) + repository.email_alerts = to_json_string( email_alerts ) + trans.sa_session.add( repository ) + flush_needed = True + total_alerts_added += 1 + if flush_needed: + trans.sa_session.flush() + message = 'Total alerts added: %d, total alerts removed: %d' % ( total_alerts_added, total_alerts_removed ) + kwd[ 'message' ] = message + kwd[ 'status' ] = 'done' + del kwd[ 'operation' ] return trans.response.send_redirect( web.url_for( controller='repository', action='browse_repositories', **kwd ) ) @@ -737,6 +751,9 @@ file_type_str = 'tip.tar.bz2' elif file_type == 'gz': file_type_str = 'tip.tar.gz' + repository.times_downloaded += 1 + trans.sa_session.add( repository ) + trans.sa_session.flush() download_url = '/repos/%s/%s/archive/%s' % ( repository.user.username, repository.name, file_type_str ) return trans.response.send_redirect( download_url ) @web.json --- a/lib/galaxy/webapps/community/model/__init__.py Tue Jun 28 11:03:55 2011 -0400 +++ b/lib/galaxy/webapps/community/model/__init__.py Tue Jun 28 15:45:56 2011 -0400 @@ -89,12 +89,14 @@ MARKED_FOR_REMOVAL = 'r', MARKED_FOR_ADDITION = 'a', NOT_TRACKED = '?' ) - def __init__( self, name=None, description=None, user_id=None, private=False, email_alerts=None ): + def __init__( self, name=None, description=None, long_description=None, user_id=None, private=False, email_alerts=None, times_downloaded=0 ): self.name = name or "Unnamed repository" self.description = description + self.long_description = long_description self.user_id = user_id self.private = private self.email_alerts = email_alerts + self.times_downloaded = times_downloaded @property def repo_path( self ): # Repository locations on disk are defined in the hgweb.config file --- a/lib/galaxy/webapps/community/model/mapping.py Tue Jun 28 11:03:55 2011 -0400 +++ b/lib/galaxy/webapps/community/model/mapping.py Tue Jun 28 15:45:56 2011 -0400 @@ -104,10 +104,12 @@ Column( "update_time", DateTime, default=now, onupdate=now ), Column( "name", TrimmedString( 255 ), index=True ), Column( "description" , TEXT ), + Column( "long_description" , TEXT ), Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ), Column( "private", Boolean, default=False ), Column( "deleted", Boolean, index=True, default=False ), - Column( "email_alerts", JSONType, nullable=True ) ) + Column( "email_alerts", JSONType, nullable=True ), + Column( "times_downloaded", Integer ) ) RepositoryRatingAssociation.table = Table( "repository_rating_association", metadata, Column( "id", Integer, primary_key=True ), --- a/lib/galaxy/webapps/community/model/migrate/versions/0004_repository_tables.py Tue Jun 28 11:03:55 2011 -0400 +++ b/lib/galaxy/webapps/community/model/migrate/versions/0004_repository_tables.py Tue Jun 28 15:45:56 2011 -0400 @@ -30,7 +30,7 @@ Column( "create_time", DateTime, default=now ), Column( "update_time", DateTime, default=now, onupdate=now ), Column( "name", TrimmedString( 255 ), index=True ), - Column( "description" , TEXT ), + Column( "description", TEXT ), Column( "user_id", Integer, ForeignKey( "galaxy_user.id" ), index=True ), Column( "private", Boolean, default=False ), Column( "deleted", Boolean, index=True, default=False ) ) --- a/templates/webapps/community/repository/create_repository.mako Tue Jun 28 11:03:55 2011 -0400 +++ b/templates/webapps/community/repository/create_repository.mako Tue Jun 28 15:45:56 2011 -0400 @@ -24,11 +24,20 @@ <div style="clear: both"></div></div><div class="form-row"> - <label>Description:</label> + <label>Synopsis:</label><input name="description" type="textfield" value="${description}" size=80"/><div style="clear: both"></div></div><div class="form-row"> + <label>Detailed description:</label> + %if long_description: + <textarea name="long_description" rows="3" cols="80">${long_description}</textarea> + %else: + <textarea name="long_description" rows="3" cols="80"></textarea> + %endif + <div style="clear: both"></div> + </div> + <div class="form-row"><label>Category</label><div class="form-row"><select name="category_id" multiple> --- a/templates/webapps/community/repository/manage_repository.mako Tue Jun 28 11:03:55 2011 -0400 +++ b/templates/webapps/community/repository/manage_repository.mako Tue Jun 28 15:45:56 2011 -0400 @@ -101,37 +101,50 @@ </div><div class="form-row"><label>Name:</label> - <input name="repo_name" type="textfield" value="${repo_name}" size=40"/> + <input name="repo_name" type="textfield" value="${repo_name}" size="40"/><div style="clear: both"></div></div><div class="form-row"> - <label>Description:</label> - <input name="description" type="textfield" value="${description}" size=80"/> + <label>Synopsis:</label> + <input name="description" type="textfield" value="${description}" size="80"/> + <div style="clear: both"></div> + </div> + <div class="form-row"> + <label>Detailed description:</label> + %if long_description: + <textarea name="long_description" rows="3" cols="80">${long_description}</textarea> + %else: + <textarea name="long_description" rows="3" cols="80"></textarea> + %endif <div style="clear: both"></div></div><div class="form-row"><label>Version:</label> - %if can_view_change_log: - <a href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ) )}">${tip}</a> - %else: - ${tip} - %endif + %if can_view_change_log: + <a href="${h.url_for( controller='repository', action='view_changelog', id=trans.app.security.encode_id( repository.id ) )}">${tip}</a> + %else: + ${tip} + %endif </div><div class="form-row"><label>Owner:</label> ${repository.user.username} </div> + <div class="form-row"> + <label>Times downloaded:</label> + ${repository.times_downloaded} + </div> %if trans.user_is_admin(): <div class="form-row"><label>Location:</label> ${repository.repo_path} </div> + <div class="form-row"> + <label>Deleted:</label> + ${repository.deleted} + </div> %endif <div class="form-row"> - <label>Deleted:</label> - ${repository.deleted} - </div> - <div class="form-row"><input type="submit" name="edit_repository_button" value="Save"/></div></form> --- a/templates/webapps/community/repository/rate_repository.mako Tue Jun 28 11:03:55 2011 -0400 +++ b/templates/webapps/community/repository/rate_repository.mako Tue Jun 28 15:45:56 2011 -0400 @@ -103,7 +103,7 @@ </div><div class="form-row"><label>Version:</label> - ${repository.version} + ${tip} <div style="clear: both"></div></div><div class="form-row"> --- a/templates/webapps/community/repository/upload.mako Tue Jun 28 11:03:55 2011 -0400 +++ b/templates/webapps/community/repository/upload.mako Tue Jun 28 15:45:56 2011 -0400 @@ -96,29 +96,31 @@ some_file.tar contains some_contained_file.gz, the contained file will not be uncompressed. </div></div> - <div class="form-row"> - <% - if remove_repo_files_not_in_tar: - yes_selected = 'selected' - no_selected = '' - else: - yes_selected = '' - no_selected = 'selected' - %> - <label>Remove files in the repository (relative to the root or selected upload point) that are not in the uploaded archive?</label> - <div class="form-row-input"> - <select name="remove_repo_files_not_in_tar"> - <option value="true" ${yes_selected}>Yes - <option value="false" ${no_selected}>No - </select> + %if not is_new: + <div class="form-row"> + <% + if remove_repo_files_not_in_tar: + yes_selected = 'selected' + no_selected = '' + else: + yes_selected = '' + no_selected = 'selected' + %> + <label>Remove files in the repository (relative to the root or selected upload point) that are not in the uploaded archive?</label> + <div class="form-row-input"> + <select name="remove_repo_files_not_in_tar"> + <option value="true" ${yes_selected}>Yes + <option value="false" ${no_selected}>No + </select> + </div> + <div class="toolParamHelp" style="clear: both;"> + This selection pertains only to uploaded tar archives, not to single file uploads. If <b>Yes</b> is selected, files + that exist in the repository (relative to the root or selected upload point) but that are not in the uploaded archive + will be removed from the repository. Otherwise, all existing repository files will remain and the uploaded archive + files will be added to the repository. + </div></div> - <div class="toolParamHelp" style="clear: both;"> - This selection pertains only to uploaded tar archives, not to single file uploads. If <b>Yes</b> is selected, files - that exist in the repository (relative to the root or selected upload point) but that are not in the uploaded archive - will be removed from the repository. Otherwise, all existing repository files will remain and the uploaded archive - files will be added to the repository. - </div> - </div> + %endif <div class="form-row"><label>Change set commit message:</label><div class="form-row-input"> --- a/templates/webapps/community/repository/view_repository.mako Tue Jun 28 11:03:55 2011 -0400 +++ b/templates/webapps/community/repository/view_repository.mako Tue Jun 28 15:45:56 2011 -0400 @@ -107,9 +107,16 @@ %endif </div><div class="form-row"> - <label>Description:</label> + <label>Synopsis:</label> ${repository.description} </div> + %if repository.long_description: + <div class="form-row"> + <label>Detailed description:</label> + ${repository.long_description} + <div style="clear: both"></div> + </div> + %endif <div class="form-row"><label>Version:</label> %if can_view_change_log: @@ -122,16 +129,20 @@ <label>Owner:</label> ${repository.user.username} </div> + <div class="form-row"> + <label>Times downloaded:</label> + ${repository.times_downloaded} + </div> %if trans.user_is_admin(): <div class="form-row"><label>Location:</label> ${repository.repo_path} </div> + <div class="form-row"> + <label>Deleted:</label> + ${repository.deleted} + </div> %endif - <div class="form-row"> - <label>Deleted:</label> - ${repository.deleted} - </div></div></div> %if trans.user and trans.app.config.smtp_server: 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)
-
Bitbucket