Beispiel #1
0
    def get(self, post_id):
        """
        get:   Get
        Args:
                self:   This object
                post_id:    Post ID
        """
        if not self.user:
            return self.redirect('/login')

        key = db.Key.from_path('Post', int(post_id), parent=blog_key())
        b = db.get(key)

        if not b:
            self.render('notfound.html')
            return
#
#       Check that user IDs do not match
#
        user_id = self.user.key().id()
        if b.user_id == user_id:
            return self.redirect('/blog/%s' % str(b.key().id()))

        if b.is_liked_by_user(user_id) == 'Liked':
            return self.redirect('/blog/%s' % str(b.key().id()))

        l = Likes(parent=blog_key(),
                  post_id=int(post_id),
                  user_id=int(user_id))
        l.put()
        self.redirect('/blog/%s' % str(b.key().id()))
    def get(self, post_id):
        """
        get:   Get
        Args:
                self:   This object
                post_id:    Post ID
        """
        b = Post.get_by_id(int(post_id), parent=blog_key())

        if not b:
            self.render('notfound.html')
            return
#
#       Check that user IDs match
#
        user_id = self.user.key().id()
        if b.user_id != user_id:
            self.redirect('/blog/%s' % str(b.key().id()))

        subject = b.subject
        content = b.content
        self.render('deletepost.html',
                    subject=subject,
                    content=content,
                    post_id=post_id)
Beispiel #3
0
    def post(self):
        """
        post:   Post
        Args:
                self:   This object
        """
        if not self.user:
            return self.redirect('/login')

        subject = self.request.get("subject")
        content = self.request.get("content")
        user_id = self.user.key().id()

        if subject and content:
            b = Post(parent=blog_key(),
                     subject=subject,
                     content=content,
                     user_id=user_id)
            b.put()
            self.redirect('/blog/%s' % str(b.key().id()))
        else:
            error = "subject and content, please!"
            self.render("newpost.html",
                        subject=subject,
                        content=content,
                        error=error)
Beispiel #4
0
    def post(self, post_id):
        """
        post:   Post
        Args:
                self:   This object
                post_id:    Post ID
        """
        if not self.user:
            return self.redirect('/login')

        b = Post.get_by_id(int(post_id), parent=blog_key())
#
#       Check that user IDs match
#
        user_id = self.user.key().id()
        if b.user_id != user_id:
            return self.redirect('/blog/%s' % str(b.key().id()))

        subject = self.request.get("subject")
        content = self.request.get("content")

        if subject and content:
            b.subject = subject
            b.content = content
            b.put()
            self.redirect('/blog/%s' % str(b.key().id()))
        else:
            error = "subject and content, please!"
            self.render("editpost.html", subject=subject, content=content,
                        error=error)
 def wrapper(self, comment_id):
     key = db.Key.from_path('Comment', int(comment_id), parent=blog_key())
     comment = db.get(key)
     if self.user.key().id() == comment.user_id:
         return function(self, comment_id)
     else:
         self.redirect('/')
         return
 def wrapper(self, post_id):
     key = db.Key.from_path('Post', int(post_id), parent=blog_key())
     post = db.get(key)
     if self.user.key().id() == post.user_id:
         return function(self, post_id)
     else:
         self.redirect('/')
         return
 def wrapper(self, comment_id):
     key = db.Key.from_path('Comment', int(comment_id), parent=blog_key())
     comment = db.get(key)
     if comment:
         return function(self, comment_id)
     else:
         self.render('notfound.html')
         return
 def wrapper(self, post_id):
     key = db.Key.from_path('Post', int(post_id), parent=blog_key())
     post = db.get(key)
     if post:
         return function(self, post_id)
     else:
         self.render('notfound.html')
         return
    def get(self, comment_id):
        """
        get:   Get
        Args:
                self:   This object
        """
        key = db.Key.from_path('Comment', int(comment_id), parent=blog_key())
        comment = db.get(key)

        if not comment:
            self.render('notfound.html')
            return

        self.render('showcomment.html', comment=comment)
    def get(self, post_id):
        """
        get:   Get
        Args:
                self:   This object
        """
        key = db.Key.from_path('Post', int(post_id), parent=blog_key())
        post = db.get(key)

        if not post:
            self.render('notfound.html')
            return
#
#       Get comments
#
        comments = Comment.all().filter('post_id =', int(post_id))
        self.render('permalink.html', post=post, comments=comments)
    def post(self, comment_id):
        """
        post:   Post
        Args:
                self:   This object
                comment_id:    Comment ID
        """
        if not self.user:
            return self.redirect('/login')

        c = Comment.get_by_id(int(comment_id), parent=blog_key())
        content = self.request.get("content")

        if content:
            c.content = content
            c.put()
            self.redirect('/blog/comment/%s' % str(c.key().id()))
        else:
            error = "content, please!"
            self.render("editcomment.html", content=content, error=error)
    def get(self, comment_id):
        """
        get:   Get
        Args:
                self:   This object
                comment_id:    Comment ID
        """
        c = Comment.get_by_id(int(comment_id), parent=blog_key())

        if not c:
            self.render('notfound.html')
            return
#
#       Check that user IDs match
#
        user_id = self.user.key().id()
        if c.user_id != user_id:
            self.redirect('/blog/%s' % str(c.key().id()))

        content = c.content
        self.render('editcomment.html', content=content, comment_id=comment_id)
Beispiel #13
0
    def post(self, post_id):
        """
        post:   Post
        Args:
                self:   This object
                post_id:    Post ID
        """
        if not self.user:
            return self.redirect('/login')

        content = self.request.get("content")
        user_id = self.user.key().id()

        if content:
            c = Comment(parent=blog_key(), content=content,
                        post_id=int(post_id), user_id=user_id)
            c.put()
            self.redirect('/blog/%s' % str(post_id))
        else:
            error = "content, please!"
            self.render("newcomment.html", content=content, error=error)
    def post(self, comment_id):
        """
        post:   Post
        Args:
                self:   This object
                comment_id:    Comment ID
        """
        if not self.user:
            return self.redirect('/login')

        c = Comment.get_by_id(int(comment_id), parent=blog_key())
        #
        #       Check that user IDs match
        #
        user_id = self.user.key().id()
        if c.user_id != user_id:
            return self.redirect('/blog/comment/%s' % str(c.key().id()))
        c.delete()
        comments = Comment.all().filter('comment_id =', comment_id)
        for comment in comments:
            comment.delete()

        self.redirect('/blog/commentdeleted')
    def post(self, post_id):
        """
        post:   Post
        Args:
                self:   This object
                post_id:    Post ID
        """
        if not self.user:
            return self.redirect('/login')

        b = Post.get_by_id(int(post_id), parent=blog_key())
        #
        #       Check that user IDs match
        #
        user_id = self.user.key().id()
        if b.user_id != user_id:
            return self.redirect('/blog/%s' % str(b.key().id()))
        b.delete()
        comments = Comment.all().filter('post_id =', post_id)
        for comment in comments:
            comment.delete()

        self.redirect('/blog/postdeleted')