def post(self, url = "/"): if not self.check_login(): self.redirect('/') return title = self.request.get('title') url = str('/' + title.replace(' ', '_')) content = self.request.get('content') tags = self.request.get('tags') category = self.request.get('category') if title.strip() == "" or content.strip() == "" or tags.strip() == "" or category.strip() == "": self.write_template('make-post.html',{'title_input': title, 'content_input': content, 'tags_input': tags, 'category_input': category, 'error': "fill out all forms!"}) return posts = main.top_posts() for post in posts: if post.title == title: post.content = content post.tags = tags post.category = category post.put() main.top_posts(True) self.redirect("/blog" + url) return a = data.Post(url = url, title = title, content = content, tags = tags, category = category) a.put() main.top_posts(True) self.redirect("/blog" + url)
def get(self, url = "/"): if not self.check_login(): self.redirect('/') return posts = main.top_posts() for post in posts: if post.url == url: post.delete main.top_posts(True) self.response.write("Post successfully deleted") return
def get(self, url = "/"): if url == '/': self.redirect("/blog") return posts = main.top_posts() for post in posts: if post.url == url: t_values = {'title_input':post.title,'content_input':post.content, 'date_input': post.created.date()} self.write_template('blog-post.html',t_values,False) return self.response.write("404 ERROR: Page not found.")
def get(self, url = "/"): if not self.check_login(): self.redirect('/') return if url == '/': self.write_template('make-post.html') return else: posts = main.top_posts() for post in posts: if post.url == url: title = post.title content = post.content tags = post.tags category = post.category self.write_template('make-post.html', {'title_input': title, 'content_input': content, 'tags_input': tags, 'category_input': category}) return self.redirect('/blog/newpost')
def get(self): posts = main.top_posts() for post in posts: post.title = '<a href="/blog'+ post.url +'">'+post.title+'</a>' post.content = main.strip_tags(post.content) self.write_template('blog-home.html',{'posts':posts}, False)