Ejemplo n.º 1
0
 def get(self, post_id, comment_id):
     if self.user:
         # get current comment!
         article = Article.get_by_id(int(post_id))
         comment = Comment.get_by_id(int(comment_id))
         if comment.made_by == self.user.name:
             self.render("edit_comment.html",
                         title=article.title,
                         comment=comment.comment,
                         user=self.user)
         else:
             self.redirect('/blog/broken')
     else:
         self.redirect('/blog/login')
Ejemplo n.º 2
0
    def post(self, post_id, comment_id):
        if self.user:
            article = Article.get_by_id(int(post_id))
            comment_elem = Comment.get_by_id(int(comment_id))

            if comment_elem.made_by == self.user.name:
                if 'back' in self.request.POST:
                    self.redirect('/blog/%s' % str(post_id))
                elif 'delete' in self.request.POST:
                    comment_elem.delete()
                    self.redirect('/blog/%s' % str(post_id))
            else:
                self.redirect('/blog/broken')
        else:
            self.redirect('/blog/login')