예제 #1
0
    def post(self):

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

        if subject and content:
            post = Post(subject = subject, content = content)
            post.put()
            self.top_posts(update=True)
            self.redirect("/blog/"+str(post.key().id()))
        else:
            error = "we need both a subject and content!"
            self.render_new_post(subject,content,error)
예제 #2
0
    def post(self):
        subject = self.request.get('subject')
        content = self.request.get('content')

        if subject and content:
            p = Post(parent=Utils().blog_key(), author=self.user,
                     subject=subject, content=content)
            p.put()
            return self.redirect('/blog/%s' % str(p.key().id()))
        else:
            error = "subject and content are both needed!"
            self.render("newpost.html", subject=subject,
                        content=content, error=error)
예제 #3
0
파일: NewPost.py 프로젝트: J-Yash/user-blog
    def post(self):
        if not self.user:
            return self.redirect("/login")

        subject = self.request.get('subject')
        content = self.request.get('content')
        user_id = self.request.cookies.get('user_id').split('|')[0]

        if subject and content:
            p = Post(subject=subject, content=content, user_id=user_id)
            p.put()

            l = LikeCount(blog_id=str(p.key().id()), count=0)
            l.put()

            self.redirect('/blog/%s' % str(p.key().id()))

        else:
            error = "Both subject and content are required!"
            self.render("newpost.html",
                        subject=subject,
                        content=content,
                        error=error)