def get(self): tid = self.get_argument('topic_id', None) if not tid: return self.write('') topic = fetch_cached_board_topic(tid) page = self.get_argument('page', 0) limit = PageMaxLimit start = string2int(page) * limit if topic: comment_list = topic.get_comments(limit=limit, offset=start) return self.render('board/comments.html', topic=topic, comment_list=comment_list, timeover=timeover) else: return self.write('')
def get(self, topic_id=None, comment_content_error=None, comment_content=''): if not topic_id: self.about(404) topic = fetch_cached_board_topic(topic_id) topic_more_content = fetch_cached_board_topic_morecontent(topic_id) if not topic: self.about(404) node = topic.node topic_has_voted = False people_id = None people = None page = self.get_argument("page", "1") page = string2int(page) if page < 1: page = 1 if people_id: topic_has_voted = topic.has_voted(people_id) limit = PageMaxLimit offset = (page-1) * PageMaxLimit comments = topic.get_comments(limit=limit, offset=offset) total_pages = topic.comment_count/limit last_page = topic.comment_count % limit if last_page > 0: total_pages += 1 node_list = fetch_cached_board_nodelist() to = timeout(topic.create_time) topic_can_edit = False #if people and to < 600 and topic.is_author(people): # topic_can_edit = True pagination = Pagination(page, total_pages) #return self.write(topic_more_content) self.render("board/topic.html", timeover=timeover, topic=topic, topic_more_content=topic_more_content, node=node, node_list=node_list, xsrf_token=self.xsrf_token, pagination=pagination, comment_list=comments, topic_has_voted=topic_has_voted, topic_can_edit=topic_can_edit, comment_content_error=comment_content_error, comment_content=comment_content)
def get(self): page = self.get_argument('page', '1') page_no = string2int(page, -1) if page_no == -1: self.about(404) if page_no < 1: page_no = 1 offset = (page_no-1) * PageMaxLimit*2 node_list = fetch_cached_board_nodelist() topics = BoardTopic.get_last_topics(limit=PageMaxLimit, offset=offset) topic_list = [] for t in topics: topic = fetch_cached_board_topic(t.id) topic_list.append(topic) now = time.time() self.render("board/index.html", timeover=timeover, topic_list=topic_list, topic_count=len(topic_list), node_list=node_list, now_time=now, page=page_no, offset=offset)
def get(self, node_name=None): if not node_name: self.about(404) node = BoardNode.get_by_name(node_name) if not node: self.about(404) page = self.get_argument('page', '1') page_no = string2int(page, -1) if page_no == -1: self.about(404) if page_no < 1: page_no = 1 offset = (page_no-1) * PageMaxLimit node_list = fetch_cached_board_nodelist() topics = BoardTopic.get_last_node_topics(node, limit=PageMaxLimit, offset=offset) topic_list = [] for t in topics: topic = fetch_cached_board_topic(t.id) topic_list.append(topic) now = time.time() total_count = BoardTopic.get_node_topics_count(node) total_pages = total_count / PageMaxLimit last_page = total_count % PageMaxLimit if last_page > 0: total_pages += 1 pagination = Pagination(page_no, total_pages) self.render("board/node.html", timeover=timeover, topic_list=topic_list, topic_count=len(topic_list), node_list=node_list, node = node, now_time=now, pagination=pagination, offset=offset)