Ejemplo n.º 1
0
 def GET(self, node_name):
     limit = 10
     node = node_model().get_one({'name': node_name})
     if node is None:
         self.crumb.append('节点未找到')
         return render.node_nf('节点未找到', self.crumb.output())
     else:
         self.crumb.append(node.display_name)
         node_fav = False
         if session.user_id:
             if user_meta_model().get_one({'user_id':session.user_id, 'meta_key':'node_fav', 'meta_value':node.id}):
                 node_fav = True
         total_rows = post_model().count_table({'node_id':node.id})
         pagination = Pagination('/node/'+node_name, total_rows, limit = limit)
         page = pagination.true_page(web.input(p=1)['p'])
         posts_result = post_model().get_all({'node_id' : node.id}, limit = limit, offset = (page-1)*limit , order = 'time DESC')
         posts = []
         for post_result in posts_result:
             post = {'post':post_result}
             user = user_model().get_one({'id':post_result.user_id})
             post['user'] = user
             comment = comment_model().get_one({'post_id':post_result.id}, order='time DESC')
             if comment:
                 comment_user = user_model().get_one({'id':comment.user_id})
                 post['comment_user'] = comment_user
             else:
                 post['comment_user'] = None
             posts.append(post)
         return render.node_posts(posts, node, total_rows, node_fav, self.crumb.output(), pagination.output())
Ejemplo n.º 2
0
 def GET(self, node_name):
     limit = 10
     node = node_model().get_one({'name': node_name})
     if node is None:
         self.crumb.append('节点未找到')
         return render.node_nf('节点未找到', self.crumb.output())
     else:
         self.crumb.append(node.display_name)
         node_fav = False
         if session.user_id:
             if user_meta_model().get_one({'user_id':session.user_id, 'meta_key':'node_fav', 'meta_value':node.id}):
                 node_fav = True
         total_rows = post_model().count_table({'node_id':node.id})
         pagination = Pagination('/node/'+node_name, total_rows, limit = limit)
         page = pagination.true_page(web.input(p=1)['p'])
         posts = post_model().trends(limit, (page-1) * limit, node.id)
         return render.node_posts(posts, node, total_rows, node_fav, self.crumb.output(), pagination.output())
Ejemplo n.º 3
0
 def GET(self, node_name):
     limit = 10
     node = node_model().get_one({'name': node_name})
     if node is None:
         self.crumb.append('节点未找到')
         return render.node_nf('节点未找到', self.crumb.output())
     else:
         self.crumb.append(node.display_name)
         node_fav = False
         if session.user_id:
             if user_meta_model().get_one({
                     'user_id': session.user_id,
                     'meta_key': 'node_fav',
                     'meta_value': node.id
             }):
                 node_fav = True
         total_rows = post_model().count_table({'node_id': node.id})
         pagination = Pagination('/node/' + node_name,
                                 total_rows,
                                 limit=limit)
         page = pagination.true_page(web.input(p=1)['p'])
         posts_result = post_model().get_all({'node_id': node.id},
                                             limit=limit,
                                             offset=(page - 1) * limit,
                                             order='time DESC')
         posts = []
         for post_result in posts_result:
             post = {'post': post_result}
             user = user_model().get_one({'id': post_result.user_id})
             post['user'] = user
             comment = comment_model().get_one({'post_id': post_result.id},
                                               order='time DESC')
             if comment:
                 comment_user = user_model().get_one(
                     {'id': comment.user_id})
                 post['comment_user'] = comment_user
             else:
                 post['comment_user'] = None
             posts.append(post)
         return render.node_posts(posts, node, total_rows, node_fav,
                                  self.crumb.output(), pagination.output())