Beispiel #1
0
 def get(self, username):
     user = User.get_by_username(username)
     if user:
         page = self.get_argument('p', '1')
         count, query = Topic.get_list_by_user(user)
         pagination_ret = pagination(count, query, config.TOPIC_PAGE_SIZE, page)
         self.render('user/user_page.html', user=user, tab={'user_topic_page': 'active'}, count=count,
                     avatar_html=avatar_generate(username, user.avatar_color, 167),
                     pagination=pagination_ret, page_url=self.request.path)
     else:
         self.write_error(404)
Beispiel #2
0
 def get(self, topic_id):
     topic = Topic.get_by_pk(topic_id)
     if topic:
         topic.view_count_inc()
         count, user_topics = Topic.get_list_by_user(topic.user)
         user_topics = user_topics.limit(10)
         follow = JsDict()
         if self.current_user():
             follow.topic = Follow.exists(OBJECT_TYPES.TOPIC, topic_id, self.current_user())
             follow.author = Follow.exists(OBJECT_TYPES.USER, topic.user.id, self.current_user())
         self.render(
             "forum/topic.html",
             nav="index",
             page_title=page_title(topic.title, topic.board.title, "社区"),
             topic=topic,
             user_topics=user_topics,
             follow=follow,
         )
     else:
         self.write_error(404)