Commits

Anonymous committed 34f5eb4

add restrict to views

  • Participants
  • Parent commits 58558fb

Comments (0)

Files changed (1)

newsmeme/models.py

         if user.is_moderator:
             return self
 
-        return self.filter(db.or_(Post.access==Post.PUBLIC,
-                                  Post.author_id==user.id,
-                                  db.and_(Post.access==Post.FRIENDS, 
-                                          Post.author_id.in_(user.friends))))
+        return self.filter(
+            db.or_(Post.access==Post.PUBLIC,
+                   Post.author_id==user.id,
+                   db.and_(Post.access==Post.FRIENDS, 
+                           Post.author_id.in_(user.friends)))).distinct()
 
 
 class Comment(db.Model):