def post(self,entrytype,blogId): blog= Weblog.get_by_id(int(blogId)) if(blog is not None): blogReactions = blog.weblogreactions_set for reaction in blogReactions: reaction.delete() blog.delete() util.flushBlogMonthCache(blog) util.flushBlogPagesCache() util.flushRecentFeatured() self.redirect('/') return
def post(self,entrytype): preview = self.request.get('preview') submitted = self.request.get('submitted') user = users.get_current_user() blog = Weblog() blog.title = self.request.get('title_input') blog.content = self.request.get('text_input') blog.author = user blog.authorEmail = user.email() blog.tags_commas = self.request.get('tags') if entrytype == 'page': blog.entrytype = entrytype template_values = { 'entrytype': entrytype, 'blog': blog, 'preview': preview, 'submitted': submitted, 'action': "addBlog", 'tags': self.request.get('tags'), } if preview == '1' and submitted !='1': self.generate('blog_add.html',template_values) else: if submitted =='1': try: permalink = util.get_permalink(blog.date,translate.translate(util.u(blog.title,'utf-8'))) if not permalink: raise Exception except Exception: template_values.update({'error':'Generate permanent link for blog error, please retry it.'}) self.generate('blog_add.html',template_values) return #check the permalink duplication problem. maxpermalinkBlog = db.GqlQuery("select * from Weblog where permalink >= :1 and permalink < :2 order by permalink desc",permalink, permalink+u"\xEF\xBF\xBD").get() if maxpermalinkBlog is not None: permalink = maxpermalinkBlog.permalink+"1" blog.permalink = permalink blog.save() util.flushBlogMonthCache(blog) util.flushBlogPagesCache() util.flushTagList() util.flushRecentFeatured() self.redirect('/'+blog.relative_permalink()) return
def post(self,entrytype,blogId): blog= Weblog.get_by_id(int(blogId)) if(blog is None): self.redirect('/') return if blog.entrytype == 'page': blog.permalink = self.request.get('permalink') blog.title = self.request.get('title_input') blog.content = self.request.get('text_input') blog.tags_commas = self.request.get('tags') user = users.get_current_user() blog.lastModifiedDate = datetime.datetime.now() blog.lastModifiedBy = user blog.update() util.flushBlogMonthCache(blog) util.flushBlogPagesCache() util.flushRecentFeatured() self.redirect('/'+blog.relative_permalink()) return