# HG changeset patch # User Lennard de Rijk # Date 1236517909 0 # Node ID fbc2ad561c4b2ef7bff7e6b3b62dfcd4353358dc # Parent 19f1bb7ae61587d281cb5ed857b1e43f07c2ca7b Added a new method in the review logic to return all reviews for the given entity as scope. Patch by: Lennard de Rijk Reviewed by: to-be-reviewed diff -r 19f1bb7ae615 -r fbc2ad561c4b app/soc/logic/models/review.py --- a/app/soc/logic/models/review.py Sun Mar 08 13:10:38 2009 +0000 +++ b/app/soc/logic/models/review.py Sun Mar 08 13:11:49 2009 +0000 @@ -42,4 +42,20 @@ super(Logic, self).__init__(model=model, base_model=base_model, scope_logic=scope_logic) + def getReviewsForEntity(self, entity, is_public, order=None): + """Returns the reviews that have the given entity as scope. + + Args: + entity: the entity which is the scope of the review + is_public: determines if the public or non-public reviews are returned + order: the optional ordering in which the reviews are returned + """ + + fields = {'scope': entity, + 'is_public': is_public} + + query = self.getQueryForFields(fields, order) + + return self.getAll(query) + logic = Logic()