1. Dan Jacob
  2. newsmeme

Commits

danjac  committed 8a9c601

change aggregates

  • Participants
  • Parent commits cd348a7
  • Branches default

Comments (0)

Files changed (3)

File newsmeme/forms.py

View file
  • Ignore whitespace
         super(PostForm, self).__init__(*args, **kwargs)
 
     def validate_link(self, field):
-        posts = Post.query.filter_by(link=field.data)
+        posts = Post.query.public().filter_by(link=field.data)
         if self.post:
             posts = posts.filter(db.not_(Post.id==self.post.id))
         if posts.count():

File newsmeme/views/frontend.py

View file
  • Ignore whitespace
         post = Post(author=g.user)
         form.populate_obj(post)
 
-        g.user.karma += 1
-
         db.session.add(post)
         db.session.commit()
 

File newsmeme/views/user.py

View file
  • Ignore whitespace
                                     username=username,
                                     page=page)
 
-    num_comments = Comment.query.filter_by(author_id=user.id).count()
+    num_comments = Comment.query.filter_by(author_id=user.id).\
+        restricted(g.user).count()
 
     return render_template("user/posts.html",
                            user=user,
                                     username=username,
                                     page=page)
 
-    num_posts = Post.query.filter_by(author_id=user.id).count()
-    num_comments = Comment.query.filter_by(author_id=user.id).count()
+    num_posts = Post.query.filter_by(author_id=user.id).\
+        restricted(g.user).count()
 
     return render_template("user/comments.html",
                            user=user,
                            num_posts=num_posts,
-                           num_comments=num_comments,
+                           num_comments=page_obj.total,
                            page_obj=page_obj,
                            page_url=page_url)
 
 
     user = User.query.filter_by(username=username).first_or_404()
 
-    num_posts = Post.query.filter_by(author_id=user.id).count()
-    num_comments = Comment.query.filter_by(author_id=user.id).count()
+    num_posts = Post.query.filter_by(author_id=user.id).\
+        restricted(g.user).count()
+
+    num_comments = Comment.query.filter_by(author_id=user.id).\
+        restricted(g.user).count()
 
     followers = user.get_followers().order_by(User.username.asc())
 
 
     user = User.query.filter_by(username=username).first_or_404()
 
-    num_posts = Post.query.filter_by(author_id=user.id).count()
-    num_comments = Comment.query.filter_by(author_id=user.id).count()
-    
+    num_posts = Post.query.filter_by(author_id=user.id).\
+        restricted(g.user).count()
+
+    num_comments = Comment.query.filter_by(author_id=user.id).\
+        restricted(g.user).count()
+   
     following = user.get_following().order_by(User.username.asc())
 
     return render_template("user/following.html",