def delete(self, article_sn): # This currently is a ajax call # Request URL:/article/ARTICLE # Request Method:DELETE current_user = self.get_current_user() article = Article(da.get_article_by_sn(int(article_sn))) # wrapped if current_user['uid'] != article.author: self.finish(json.dumps(False)) else: if article.status == cst.DELETED: # Remove related data, like comments # Remove article that already markded "deleted". article.remove() da.remove_comments_with_article(int(article_sn)) else: # Just mark the article "deleted", not remove it. article.set_status(cst.DELETED) article.put() self.finish(json.dumps(True))
def post(self): article = Article() # get post values post_values = ['title', 'brief', 'content'] args = {} for v in post_values: # Get nessary argument # Use None as default if argument is not supplied args[v] = self.get_argument(v, None) article.set_sn() article.set_title(args['title']) article.set_sub_title(args['brief']) article.set_markdown(args['content']) article.set_html(markdown(args['content'], ['fenced_code', 'codehilite'], safe_mode= "escape")) current_user = self.get_current_user() article.set_author(current_user['uid']) article.put() self.redirect('/')
def post(self, sn): # get post values post_values = ['title', 'brief', 'content'] args = {} for v in post_values: # Get nessary argument # Use None as default if argument is not supplied args[v] = self.get_argument(v, None) current_user = self.get_current_user() # wrapped article = Article(da.get_article_by_sn(int(sn))) article.set_title(args['title']) article.set_sub_title(args['brief']) article.set_markdown(args['content']) article.set_html(markdown(args['content'], ['fenced_code', 'codehilite'], safe_mode= "escape")) article.set_review() article.put() self.redirect("/article/%s" % sn)