commit/galaxy-central: 2 new changesets
2 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/c5d124552c0b/ changeset: c5d124552c0b branch: next-stable user: inithello date: 2013-03-21 14:51:51 summary: Add columns for rating and approval status to repositories with reviews grid. affected #: 3 files diff -r 8910b01b8addcc3967b46206be1d0518629dbdf9 -r c5d124552c0b00b39f519ae491d4c64ed4472c08 lib/galaxy/webapps/tool_shed/controllers/repository_review.py --- a/lib/galaxy/webapps/tool_shed/controllers/repository_review.py +++ b/lib/galaxy/webapps/tool_shed/controllers/repository_review.py @@ -3,6 +3,7 @@ from galaxy.web.base.controller import BaseUIController from galaxy.web.form_builder import SelectField, CheckboxField from sqlalchemy.sql.expression import func +from galaxy.model.orm import and_ from galaxy.webapps.tool_shed.util import common_util from galaxy.webapps.tool_shed.util.container_util import STRSEP import tool_shed.util.shed_util_common as suc @@ -315,7 +316,9 @@ if flushed: # Update the repository rating value to be the average of all component review ratings. average_rating = trans.sa_session.query( func.avg( trans.model.ComponentReview.table.c.rating ) ) \ - .filter( trans.model.ComponentReview.table.c.repository_review_id == review.id ) \ + .filter( and_( trans.model.ComponentReview.table.c.repository_review_id == review.id, + trans.model.ComponentReview.table.c.deleted == False, + trans.model.ComponentReview.table.c.approved != trans.model.ComponentReview.approved_states.NA ) ) \ .scalar() review.rating = int( average_rating ) trans.sa_session.add( review ) diff -r 8910b01b8addcc3967b46206be1d0518629dbdf9 -r c5d124552c0b00b39f519ae491d4c64ed4472c08 lib/tool_shed/grids/repository_review_grids.py --- a/lib/tool_shed/grids/repository_review_grids.py +++ b/lib/tool_shed/grids/repository_review_grids.py @@ -71,6 +71,7 @@ class WithoutReviewsRevisionColumn( grids.GridColumn ): + def get_value( self, trans, grid, repository ): # Restrict the options to revisions that have not yet been reviewed. repository_metadata_revisions = metadata_util.get_repository_metadata_revisions_for_review( repository, reviewed=False ) @@ -96,6 +97,35 @@ rval += '%s</a> | ' % user.username rval = rval.rstrip( ' | ' ) return rval + + + class RatingColumn( grids.TextColumn ): + + def get_value( self, trans, grid, repository ): + rval = '' + for review in repository.reviews: + if review.rating: + for index in range( 1, 6 ): + rval += '<input ' + rval += 'name="star1-%s" ' % trans.security.encode_id( review.id ) + rval += 'type="radio" ' + rval += 'class="community_rating_star star" ' + rval += 'disabled="disabled" ' + rval += 'value="%s" ' % str( review.rating ) + if review.rating > ( index - 0.5 ) and review.rating < ( index + 0.5 ): + rval += 'checked="checked" ' + rval += '/>' + rval += '<br/>' + return rval + + class ApprovedColumn( grids.TextColumn ): + + def get_value( self, trans, grid, repository ): + rval = '' + for review in repository.reviews: + rval += '%s<br/>' % review.approved + return rval + title = "All reviewed repositories" model_class = model.Repository template='/webapps/tool_shed/repository_review/grid.mako' @@ -105,10 +135,11 @@ key="name", link=( lambda item: dict( operation="view_or_manage_repository", id=item.id ) ), attach_popup=True ), + RepositoryGrid.UserColumn( "Owner", attach_popup=False ), WithReviewsRevisionColumn( "Reviewed revisions" ), - WithoutReviewsRevisionColumn( "Revisions for review" ), - RepositoryGrid.UserColumn( "Owner", attach_popup=False ), - ReviewersColumn( "Reviewers", attach_popup=False ) + ReviewersColumn( "Reviewers", attach_popup=False ), + RatingColumn( "Rating", attach_popup=False ), + ApprovedColumn( "Approved", attach_popup=False ) ] columns.append( grids.MulticolFilterColumn( "Search repository name", cols_to_filter=[ columns[ 0 ] ], @@ -253,13 +284,16 @@ def get_value( self, trans, grid, review ): if review.rating: - rval = '<input ' - rval += 'name="star1-%s" ' % trans.security.encode_id( review.id ) - rval += 'type="radio" ' - rval += 'class="community_rating_star star" ' - rval += 'disabled="disabled" ' - rval += 'value="%s"' % str( review.rating ) - rval += '/>' + for index in range( 1, 6 ): + rval = '<input ' + rval += 'name="star1-%s" ' % trans.security.encode_id( review.id ) + rval += 'type="radio" ' + rval += 'class="community_rating_star star" ' + rval += 'disabled="disabled" ' + rval += 'value="%s" ' % str( review.rating ) + if review.rating > ( index - 0.5 ) and review.rating < ( index + 0.5 ): + rval += 'checked="checked" ' + rval += '/>' return rval return '' diff -r 8910b01b8addcc3967b46206be1d0518629dbdf9 -r c5d124552c0b00b39f519ae491d4c64ed4472c08 lib/tool_shed/grids/util.py --- a/lib/tool_shed/grids/util.py +++ b/lib/tool_shed/grids/util.py @@ -8,6 +8,8 @@ ( 'Yes', trans.model.ComponentReview.approved_states.YES ) ] if for_component: options.append( ( 'Not applicable', trans.model.ComponentReview.approved_states.NA ) ) + if selected_value is None: + selected_value = trans.model.ComponentReview.approved_states.NA select_field = SelectField( name=name ) for option_tup in options: selected = selected_value and option_tup[ 1 ] == selected_value https://bitbucket.org/galaxy/galaxy-central/commits/deb9b395f110/ changeset: deb9b395f110 user: inithello date: 2013-03-21 14:52:57 summary: Merge in changes from next-stable affected #: 3 files diff -r 2a19abf0f450adbae1cc119abe3e50edbf05a18d -r deb9b395f110750fa8e069a7b0ac5c494b67e985 lib/galaxy/webapps/tool_shed/controllers/repository_review.py --- a/lib/galaxy/webapps/tool_shed/controllers/repository_review.py +++ b/lib/galaxy/webapps/tool_shed/controllers/repository_review.py @@ -3,6 +3,7 @@ from galaxy.web.base.controller import BaseUIController from galaxy.web.form_builder import SelectField, CheckboxField from sqlalchemy.sql.expression import func +from galaxy.model.orm import and_ from galaxy.webapps.tool_shed.util import common_util from galaxy.webapps.tool_shed.util.container_util import STRSEP import tool_shed.util.shed_util_common as suc @@ -315,7 +316,9 @@ if flushed: # Update the repository rating value to be the average of all component review ratings. average_rating = trans.sa_session.query( func.avg( trans.model.ComponentReview.table.c.rating ) ) \ - .filter( trans.model.ComponentReview.table.c.repository_review_id == review.id ) \ + .filter( and_( trans.model.ComponentReview.table.c.repository_review_id == review.id, + trans.model.ComponentReview.table.c.deleted == False, + trans.model.ComponentReview.table.c.approved != trans.model.ComponentReview.approved_states.NA ) ) \ .scalar() review.rating = int( average_rating ) trans.sa_session.add( review ) diff -r 2a19abf0f450adbae1cc119abe3e50edbf05a18d -r deb9b395f110750fa8e069a7b0ac5c494b67e985 lib/tool_shed/grids/repository_review_grids.py --- a/lib/tool_shed/grids/repository_review_grids.py +++ b/lib/tool_shed/grids/repository_review_grids.py @@ -71,6 +71,7 @@ class WithoutReviewsRevisionColumn( grids.GridColumn ): + def get_value( self, trans, grid, repository ): # Restrict the options to revisions that have not yet been reviewed. repository_metadata_revisions = metadata_util.get_repository_metadata_revisions_for_review( repository, reviewed=False ) @@ -96,6 +97,35 @@ rval += '%s</a> | ' % user.username rval = rval.rstrip( ' | ' ) return rval + + + class RatingColumn( grids.TextColumn ): + + def get_value( self, trans, grid, repository ): + rval = '' + for review in repository.reviews: + if review.rating: + for index in range( 1, 6 ): + rval += '<input ' + rval += 'name="star1-%s" ' % trans.security.encode_id( review.id ) + rval += 'type="radio" ' + rval += 'class="community_rating_star star" ' + rval += 'disabled="disabled" ' + rval += 'value="%s" ' % str( review.rating ) + if review.rating > ( index - 0.5 ) and review.rating < ( index + 0.5 ): + rval += 'checked="checked" ' + rval += '/>' + rval += '<br/>' + return rval + + class ApprovedColumn( grids.TextColumn ): + + def get_value( self, trans, grid, repository ): + rval = '' + for review in repository.reviews: + rval += '%s<br/>' % review.approved + return rval + title = "All reviewed repositories" model_class = model.Repository template='/webapps/tool_shed/repository_review/grid.mako' @@ -105,10 +135,11 @@ key="name", link=( lambda item: dict( operation="view_or_manage_repository", id=item.id ) ), attach_popup=True ), + RepositoryGrid.UserColumn( "Owner", attach_popup=False ), WithReviewsRevisionColumn( "Reviewed revisions" ), - WithoutReviewsRevisionColumn( "Revisions for review" ), - RepositoryGrid.UserColumn( "Owner", attach_popup=False ), - ReviewersColumn( "Reviewers", attach_popup=False ) + ReviewersColumn( "Reviewers", attach_popup=False ), + RatingColumn( "Rating", attach_popup=False ), + ApprovedColumn( "Approved", attach_popup=False ) ] columns.append( grids.MulticolFilterColumn( "Search repository name", cols_to_filter=[ columns[ 0 ] ], @@ -253,13 +284,16 @@ def get_value( self, trans, grid, review ): if review.rating: - rval = '<input ' - rval += 'name="star1-%s" ' % trans.security.encode_id( review.id ) - rval += 'type="radio" ' - rval += 'class="community_rating_star star" ' - rval += 'disabled="disabled" ' - rval += 'value="%s"' % str( review.rating ) - rval += '/>' + for index in range( 1, 6 ): + rval = '<input ' + rval += 'name="star1-%s" ' % trans.security.encode_id( review.id ) + rval += 'type="radio" ' + rval += 'class="community_rating_star star" ' + rval += 'disabled="disabled" ' + rval += 'value="%s" ' % str( review.rating ) + if review.rating > ( index - 0.5 ) and review.rating < ( index + 0.5 ): + rval += 'checked="checked" ' + rval += '/>' return rval return '' diff -r 2a19abf0f450adbae1cc119abe3e50edbf05a18d -r deb9b395f110750fa8e069a7b0ac5c494b67e985 lib/tool_shed/grids/util.py --- a/lib/tool_shed/grids/util.py +++ b/lib/tool_shed/grids/util.py @@ -8,6 +8,8 @@ ( 'Yes', trans.model.ComponentReview.approved_states.YES ) ] if for_component: options.append( ( 'Not applicable', trans.model.ComponentReview.approved_states.NA ) ) + if selected_value is None: + selected_value = trans.model.ComponentReview.approved_states.NA select_field = SelectField( name=name ) for option_tup in options: selected = selected_value and option_tup[ 1 ] == selected_value 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