def process_wiki_comment(self, parent_author, child_author, comment_id, transaction=None, date=None): parent_wiki = self.create_get_wiki(parent_author) child_wiki = self.create_get_wiki(child_author) try: if transaction and 'type' in transaction: t_type = transaction['type'] t_grlc = format_number(transaction['grlc']) if t_type.lower() == 's': c_type = 'B' c_grlc = t_grlc p_grlc = "-" elif t_type.lower() == 'b': c_type = 'S' c_grlc = "-" p_grlc = t_grlc else: c_type = "N/A" t_type = "N/A" c_grlc = "N/A" p_grlc = "N/A" parent_comment = COMMENT_LINK_TEMPLATE.format(get_post().id, comment_id, c_type, child_author, p_grlc, date) child_comment = COMMENT_LINK_TEMPLATE.format(get_post().id, comment_id, t_type, parent_author, c_grlc, date) except: pass self.process_wiki(parent_wiki, 1, c_type, child_author, p_grlc, parent_comment, date) self.process_wiki(child_wiki, 1, t_type, parent_author, c_grlc, child_comment, date)
def decorated_function(self, post_id, *args, **kwargs): user_name = self.user.name post = get_post(post_id) if user_name != post.author.name: return f(self, post_id, *args, **kwargs) else: self.redirect('/blog')
def post(self, post_id): post = get_post(post_id) post.subject = self.request.get('subject') post.content = self.request.get('content') post.put() time.sleep(0.1) self.redirect('/blog')
def get_comments(): print('Fetching comments') post = get_post() post.comment_sort = 'new' post.comments.replace_more(limit=None) print('Finished fetching ' + post.id + ' comments') return post.comments
def get(self, board, num): post = util.get_post(board, num) if not post: raise NotFound post["html"] = markup(board=board, postid=num, data=post.get("text")) post["full_html"] = render_template("post.html", post=post, board=board) return json_response(post)
def get(self, post_id): post = get_post(post_id) if self.user.name not in post.likes: post.likes.append(self.user.name) post.put() time.sleep(0.1) else: post.likes.remove(self.user.name) post.put() time.sleep(0.1) self.redirect('/blog/?')
def post(self, post_id): content = self.request.get('content') post = get_post(post_id) if content: c = Comment(content=content, author=self.user, likes=[], post=post) c.put() time.sleep(0.1) self.redirect('/blog') else: error = "Please input Content!" self.render("new-comment.html", content=content, error=error)
def get(self, board, post): post_data = get_post(board, post) thq = models.Thread.all(keys_only=True) thq.ancestor( db.Key.from_path("Board", board)) thq.filter("post_numbers", post) thread = thq.get() if not thread: raise NotFound() return redirect("/%s/%d/#p%d"% (board, thread.id(), post) )
def get(self, board, post): post_data = get_post(board, post) thq = models.Thread.all(keys_only=True) thq.filter("board", board) thq.filter("post_numbers", post) thread = thq.get() if not thread: raise NotFound() return redirect("/%s/#p%d"% (thread.name(), post) )
def check_post(postid): errmsg = "" status, obj = get_post(postid) if status is False: errmsg = "%s\n%s" % (errmsg, "fail to get post, postid: %s, msg: %s" % (postid, msg)) status, obj = check_post_title(post['title']) if status is False: errmsg = "%s\n%s" % (errmsg, "check_post_title fail, msg: %s" % obj) status, obj = check_post_summary(post['summary']) if status is False: errmsg = "%s\n%s" % (errmsg, "check_post_summary fail, msg: %s" % obj) status, obj = check_post_content(post['content']) if status is False: errmsg = "%s\n%s" % (errmsg, "check_post_content fail, msg: %s" % obj) if errmsg == "": return (True, True) else: return (False, errmsg)
def decorated_function(self, post_id, *args, **kwargs): post = get_post(post_id) if not post: self.error(404) return return f(self, post_id, *args, **kwargs)
def get(self, post_id): post = get_post(post_id) self.render("permalink.html", post=post, user=self.user)
def get(self, post_id): post = get_post(post_id) self.render("new-comment.html", post=post)
def post(self, post_id): post = get_post(post_id) post.delete() time.sleep(0.1) self.redirect('/blog')
def get(self, post_id): post = get_post(post_id) self.render('delete.html', post=post)
def get(self, post_id): post = get_post(post_id) self.render('edit.html', post=post)