def get(self, topic_id, *args, **kwargs): try: topic = PostTopic.get(PostTopic.str == topic_id) except PostTopic.DoesNotExist: self.redirect("/static/404.html") return current_page = get_cleaned_query_data(self, [ 'page', ], blank=True)['page'] if current_page: current_page = int(current_page) if current_page < 1: self.redirect("/static/404.html") return posts, page_number_limit = Post.list_by_topic( topic, page_number=current_page) else: current_page = 1 posts, page_number_limit = Post.list_by_topic(topic) top_posts, _ = Post.list_top() pages = get_page_nav(current_page, page_number_limit, config.default_page_limit) self.render('index/index.html', posts=posts, top_posts=top_posts, topic_category_cache=topic_category_cache, hot_post_cache=hot_post_cache, systatus=system_status_cache, current_topic=topic, pages=pages, pages_prefix_url='/topic/' + topic.str + '?page=')
def get_topic_index_info(topic_id, current_page, page_limit=config.default_page_limit): try: topic = PostTopic.get(PostTopic.str == topic_id) except PostTopic.DoesNotExist: return None current_page = get_page_number(current_page) posts, page_number_limit = Post.list_by_topic(topic, page_number=current_page) top_posts, _ = Post.list_top() pages = get_page_nav(current_page, page_number_limit, page_limit) return topic, posts, top_posts, pages
def get_topic_index_info(topic_id, current_page, page_limit=config.default_page_limit): try: topic = PostTopic.get(PostTopic.str == topic_id) except PostTopic.DoesNotExist: return None current_page = get_page_number(current_page) posts, page_number_limit = Post.list_by_topic(topic, page_number=current_page) top_posts, _ = Post.list_top() pages = get_page_nav(current_page, page_number_limit, page_limit) return topic, posts, top_posts, pages