def test_get_comments_by_card_id(self): uid0 = User.add("test1", "password", "*****@*****.**") bid0 = Board.add("board1", "A") lid0 = List.add("To Do", bid0) caid0 = Card.add("card1", lid0, uid0) caid1 = Card.add("card2", lid0, uid0) coid0 = Comment.add(caid0, uid0, "comment1") coid1 = Comment.add(caid1, uid0, "comment2") comment0 = Comment.get(coid0) comment1 = Comment.get(coid1) assert coid0 in [comment.id for comment in Comment.get_comments_by_card_id(caid0)] assert coid1 not in [comment.id for comment in Comment.get_comments_by_card_id(caid0)]
def post(self, slug=None): try: linkcheck = self.request.get_all('checks') for key in linkcheck: comment = Comment.get(key) comment.delit() finally: self.redirect('/admin/comments')
def test_add_and_get(self): uid0 = User.add("test1", "password", "*****@*****.**") bid0 = Board.add("board1", "A") lid0 = List.add("To Do", bid0) caid0 = Card.add("card1", lid0, uid0) coid0 = Comment.add(caid0, uid0, "comment1") comment0 = Comment.get(coid0) assert caid0 == comment0.card_id assert uid0 == comment0.user_id assert "comment1" == comment0.content
def is_valid(self, post_key, comment_key): self.user_comment = Comment.get(comment_key) # Check Comment if (not self.user_comment or self.user_comment.is_deleted): self.abort(404, "Unknown comment") # Check Author if self.user_comment.user.key() != self.user.key(): self.abort(404, "You are not allowed to update this comment") return func(self, post_key, comment_key)
def delete(self, content_id, comment_id): comment = Comment.get(int(comment_id)) comment.delete() self.redirect('/content/' + content_id + "?action=comment.delete")
def comment_delete(blog_id, comment_id): comment = Comment.get(comment_id) comment.delete() return redirect(url_for('blog_show',blog_id = blog_id))