1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/bb3a803c207d/ changeset: bb3a803c207d user: greg date: 2013-01-21 14:59:31 summary: Eliminate the tool shed's common controller. affected #: 4 files diff -r 34404f8489792a97096b36f012fbf775cc3b382b -r bb3a803c207d4e1f305982bf97bcb9019810bd83 lib/galaxy/webapps/community/controllers/common.py --- a/lib/galaxy/webapps/community/controllers/common.py +++ /dev/null @@ -1,27 +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 diff -r 34404f8489792a97096b36f012fbf775cc3b382b -r bb3a803c207d4e1f305982bf97bcb9019810bd83 lib/galaxy/webapps/community/controllers/repository.py --- a/lib/galaxy/webapps/community/controllers/repository.py +++ b/lib/galaxy/webapps/community/controllers/repository.py @@ -13,7 +13,7 @@ import galaxy.util.shed_util_common as suc from galaxy.tool_shed import encoding_util from galaxy.webapps.community.util import workflow_util -import common +from galaxy.webapps.community.util import common_util import galaxy.tools from galaxy import eggs @@ -518,7 +518,7 @@ link=( lambda item: dict( operation="view_or_manage_repository", id=item.id ) ), attach_popup=False ) -class RepositoryController( BaseUIController, common.ItemRatings ): +class RepositoryController( BaseUIController, common_util.ItemRatings ): install_matched_repository_grid = InstallMatchedRepositoryGrid() matched_repository_grid = MatchedRepositoryGrid() diff -r 34404f8489792a97096b36f012fbf775cc3b382b -r bb3a803c207d4e1f305982bf97bcb9019810bd83 lib/galaxy/webapps/community/controllers/repository_review.py --- a/lib/galaxy/webapps/community/controllers/repository_review.py +++ b/lib/galaxy/webapps/community/controllers/repository_review.py @@ -6,7 +6,7 @@ from galaxy.web.framework.helpers import grids from galaxy.model.orm import and_ from sqlalchemy.sql.expression import func -import common +from galaxy.webapps.community.util import common_util from galaxy.webapps.community.util.container_util import STRSEP from repository import RepositoryGrid import galaxy.util.shed_util_common as suc @@ -260,7 +260,7 @@ .outerjoin( ( model.ComponentReview.table, model.ComponentReview.table.c.repository_review_id == model.RepositoryReview.table.c.id ) ) \ .outerjoin( ( model.Component.table, model.Component.table.c.id == model.ComponentReview.table.c.component_id ) ) -class RepositoryReviewController( BaseUIController, common.ItemRatings ): +class RepositoryReviewController( BaseUIController, common_util.ItemRatings ): component_grid = ComponentGrid() repositories_reviewed_by_me_grid = RepositoriesReviewedByMeGrid() diff -r 34404f8489792a97096b36f012fbf775cc3b382b -r bb3a803c207d4e1f305982bf97bcb9019810bd83 lib/galaxy/webapps/community/util/common_util.py --- /dev/null +++ b/lib/galaxy/webapps/community/util/common_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 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.