Added a new method in the review logic to return all reviews for the given entity as scope.
authorLennard de Rijk <ljvderijk@gmail.com>
Sun, 08 Mar 2009 13:11:49 +0000
changeset 1740 fbc2ad561c4b
parent 1739 19f1bb7ae615
child 1741 0da1285f5bc0
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
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()