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)
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)
def post(self): title = self.request.get('title').strip() content = self.request.get('content').strip() template_vars = {} template_vars['errors'] = {} template_vars['values'] = {} if not title: template_vars['errors']['title'] = 'Title is Required' if not content: template_vars['errors']['content'] = 'Content is Required' if len(template_vars['errors']) == 0: print 'no errors should create' # make post post = Post( title=title, content=content ) # save post inserted = post.put() # TODO - see if need to handle case where insert fails self.redirect('/post/%s' % inserted.id()) self.render('post_add', template_vars)
def post(self): if self.user: subject = self.request.get("subject") content = self.request.get("content") if subject and content: new_post = Post(subject=subject, content=content, author=self.user.name) new_post.put() self.redirect("/post/%s" % str(new_post.key.id())) else: error = "Both fields are required" self.render_page("newpost.html", subject, content, error=error) else: self.redirect("/login")
def post(self): """ Attempt to create a new blog post """ current_user = self.authenticate_user() if not current_user: self.redirect("/login") else: content = self.request.get("content") title = self.request.get("subject") if not content or not title: self.render_front(title, content, "We need both a title and content") else: post = Post(title=title, content=content, user=current_user.key) post.put() current_user.posts.append(post.key) current_user.put() self.redirect("/post/" + str(post.key.id()))
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)