1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/dd8329aa8d9e/ Changeset: dd8329aa8d9e User: greg Date: 2013-08-26 20:37:28 Summary: Rename ~/lib/galaxy/webapps/tool_shed/util/common_util.py to be ratings_util. Affected #: 5 files diff -r a8baee5722c3d6df9d71bfdd5ed40c7890b2a473 -r dd8329aa8d9e84397fd226adb9e54589bd1aea2f 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 @@ -17,7 +17,7 @@ from galaxy.util import json from galaxy.model.orm import and_ import tool_shed.util.shed_util_common as suc -from tool_shed.util import common_util as scu +from tool_shed.util import common_util from tool_shed.util import container_util from tool_shed.util import encoding_util from tool_shed.util import export_util @@ -31,7 +31,7 @@ from tool_shed.util import tool_util from tool_shed.util import workflow_util from tool_shed.galaxy_install import repository_util -from galaxy.webapps.tool_shed.util import common_util +from galaxy.webapps.tool_shed.util import ratings_util import galaxy.tools import tool_shed.grids.repository_grids as repository_grids import tool_shed.grids.util as grids_util @@ -51,7 +51,7 @@ malicious_error_can_push = " Correct this changeset as soon as possible, it potentially produces malicious behavior or contains inappropriate content." -class RepositoryController( BaseUIController, common_util.ItemRatings ): +class RepositoryController( BaseUIController, ratings_util.ItemRatings ): category_grid = repository_grids.CategoryGrid() datatypes_grid = repository_grids.DatatypesGrid() @@ -1233,7 +1233,7 @@ return self.install_matched_repository_grid( trans, **kwd ) else: kwd[ 'message' ] = "tool id: <b>%s</b><br/>tool name: <b>%s</b><br/>tool version: <b>%s</b><br/>exact matches only: <b>%s</b>" % \ - ( common_util.stringify( tool_ids ), common_util.stringify( tool_names ), common_util.stringify( tool_versions ), str( exact_matches_checked ) ) + ( suc.stringify( tool_ids ), suc.stringify( tool_names ), suc.stringify( tool_versions ), str( exact_matches_checked ) ) self.matched_repository_grid.title = "Repositories with matching tools" return self.matched_repository_grid( trans, **kwd ) else: @@ -1241,9 +1241,9 @@ status = "error" exact_matches_check_box = CheckboxField( 'exact_matches', checked=exact_matches_checked ) return trans.fill_template( '/webapps/tool_shed/repository/find_tools.mako', - tool_id=common_util.stringify( tool_ids ), - tool_name=common_util.stringify( tool_names ), - tool_version=common_util.stringify( tool_versions ), + tool_id=suc.stringify( tool_ids ), + tool_name=suc.stringify( tool_names ), + tool_version=suc.stringify( tool_versions ), exact_matches_check_box=exact_matches_check_box, message=message, status=status ) @@ -1317,7 +1317,7 @@ return self.install_matched_repository_grid( trans, **kwd ) else: kwd[ 'message' ] = "workflow name: <b>%s</b><br/>exact matches only: <b>%s</b>" % \ - ( common_util.stringify( workflow_names ), str( exact_matches_checked ) ) + ( suc.stringify( workflow_names ), str( exact_matches_checked ) ) self.matched_repository_grid.title = "Repositories with matching workflows" return self.matched_repository_grid( trans, **kwd ) else: @@ -1328,7 +1328,7 @@ workflow_names = [] exact_matches_check_box = CheckboxField( 'exact_matches', checked=exact_matches_checked ) return trans.fill_template( '/webapps/tool_shed/repository/find_workflows.mako', - workflow_name=common_util.stringify( workflow_names ), + workflow_name=suc.stringify( workflow_names ), exact_matches_check_box=exact_matches_check_box, message=message, status=status ) @@ -1645,7 +1645,8 @@ encoded_repository_ids = [] changeset_revisions = [] for required_repository_tup in decoded_required_repository_tups: - tool_shed, name, owner, changeset_revision, prior_installation_required = scu.parse_repository_dependency_tuple( required_repository_tup ) + tool_shed, name, owner, changeset_revision, prior_installation_required = \ + common_util.parse_repository_dependency_tuple( required_repository_tup ) repository = suc.get_repository_by_name_and_owner( trans.app, name, owner ) encoded_repository_ids.append( trans.security.encode_id( repository.id ) ) changeset_revisions.append( changeset_revision ) diff -r a8baee5722c3d6df9d71bfdd5ed40c7890b2a473 -r dd8329aa8d9e84397fd226adb9e54589bd1aea2f 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 @@ -4,7 +4,7 @@ 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 import ratings_util from tool_shed.util.container_util import STRSEP import tool_shed.util.shed_util_common as suc from tool_shed.util import review_util @@ -19,7 +19,7 @@ log = logging.getLogger( __name__ ) -class RepositoryReviewController( BaseUIController, common_util.ItemRatings ): +class RepositoryReviewController( BaseUIController, ratings_util.ItemRatings ): component_grid = repository_review_grids.ComponentGrid() repositories_ready_for_review_grid = repository_review_grids.RepositoriesReadyForReviewGrid() diff -r a8baee5722c3d6df9d71bfdd5ed40c7890b2a473 -r dd8329aa8d9e84397fd226adb9e54589bd1aea2f lib/galaxy/webapps/tool_shed/util/common_util.py --- a/lib/galaxy/webapps/tool_shed/util/common_util.py +++ /dev/null @@ -1,32 +0,0 @@ -import logging -from galaxy.model.item_attrs import UsesItemRatings - -log = logging.getLogger( __name__ ) - -class ItemRatings( UsesItemRatings ): - """Overrides rate_item method since we also allow for comments""" - def rate_item( self, trans, user, item, rating, comment='' ): - """ Rate an item. Return type is <item_class>RatingAssociation. """ - item_rating = self.get_user_item_rating( trans.sa_session, user, item, webapp_model=trans.model ) - if not item_rating: - # User has not yet rated item; create rating. - item_rating_assoc_class = self._get_item_rating_assoc_class( item, webapp_model=trans.model ) - item_rating = item_rating_assoc_class() - item_rating.user = trans.user - item_rating.set_item( item ) - item_rating.rating = rating - item_rating.comment = comment - trans.sa_session.add( item_rating ) - trans.sa_session.flush() - elif item_rating.rating != rating or item_rating.comment != comment: - # User has previously rated item; update rating. - item_rating.rating = rating - item_rating.comment = comment - trans.sa_session.add( item_rating ) - trans.sa_session.flush() - return item_rating - -def stringify( list ): - if list: - return ','.join( list ) - return '' diff -r a8baee5722c3d6df9d71bfdd5ed40c7890b2a473 -r dd8329aa8d9e84397fd226adb9e54589bd1aea2f lib/galaxy/webapps/tool_shed/util/ratings_util.py --- /dev/null +++ b/lib/galaxy/webapps/tool_shed/util/ratings_util.py @@ -0,0 +1,27 @@ +import logging +from galaxy.model.item_attrs import UsesItemRatings + +log = logging.getLogger( __name__ ) + +class ItemRatings( UsesItemRatings ): + """Overrides rate_item method since we also allow for comments""" + def rate_item( self, trans, user, item, rating, comment='' ): + """ Rate an item. Return type is <item_class>RatingAssociation. """ + item_rating = self.get_user_item_rating( trans.sa_session, user, item, webapp_model=trans.model ) + if not item_rating: + # User has not yet rated item; create rating. + item_rating_assoc_class = self._get_item_rating_assoc_class( item, webapp_model=trans.model ) + item_rating = item_rating_assoc_class() + item_rating.user = trans.user + item_rating.set_item( item ) + item_rating.rating = rating + item_rating.comment = comment + trans.sa_session.add( item_rating ) + trans.sa_session.flush() + elif item_rating.rating != rating or item_rating.comment != comment: + # User has previously rated item; update rating. + item_rating.rating = rating + item_rating.comment = comment + trans.sa_session.add( item_rating ) + trans.sa_session.flush() + return item_rating diff -r a8baee5722c3d6df9d71bfdd5ed40c7890b2a473 -r dd8329aa8d9e84397fd226adb9e54589bd1aea2f 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 @@ -1401,7 +1401,12 @@ # Return the boolean value of prior_installation_required, which defaults to False. return required_rd_tup[ 4 ] return False - + +def stringify( list ): + if list: + return ','.join( list ) + return '' + def strip_path( fpath ): """Attempt to strip the path from a file name.""" if not fpath: 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.