示例#1
0
 def GET(self, name):
     limit = 10
     user = user_model().get_one({'name':name})
     crumb = Crumb()
     if user:
         crumb.append(name, '/profile/'+name)
         crumb.append('全部主题')
         total_rows = post_model().count_table({'user_id':user.id})
         pagination = Pagination('/profile/'+name+'/posts', total_rows, limit = limit)
         page = pagination.true_page(web.input(p=1)['p'])
         posts_result = post_model().get_all({'user_id':user.id}, limit = limit, offset = (page-1) * limit, order = 'time DESC')
         posts = []
         for post_result in posts_result:
             post = {'post':post_result}
             node = node_model().get_one({'id':post_result.node_id})
             post['node'] = node
             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.user_posts('全部主题', user,  posts, total_rows, crumb.output(), pagination.output())
     else:
         crumb.append('会员未找到')
         return render.user_nf('会员未找到', crumb.output())
示例#2
0
文件: user.py 项目: zhjchina/post_bar
 def GET(self, name):
     limit = 10
     user = user_model().get_one({'name': name})
     crumb = Crumb()
     if user:
         crumb.append(name, '/profile/' + name)
         crumb.append('全部回复')
         total = comment_model().count_table({'user_id': user.id})
         pagination = Pagination('/profile/' + name + '/comments',
                                 total,
                                 limit=limit)
         page = pagination.true_page(web.input(p=1)['p'])
         comments_result = comment_model().get_all({'user_id': user.id},
                                                   limit=limit,
                                                   offset=(page - 1) *
                                                   limit,
                                                   order='time DESC')
         if len(comments_result) > 0:
             comments = []
             for comment_result in comments_result:
                 post = post_model().get_one({'id': comment_result.post_id})
                 post_user = user_model().get_one({'id': post.user_id})
                 comment = {
                     'post': post,
                     'comment': comment_result,
                     'post_user': post_user
                 }
                 comments.append(comment)
         else:
             comments = None
         return render.user_comments('全部回复', comments, total,
                                     crumb.output(), pagination.output())
     else:
         crumb.append('会员未找到')
         return render.user_nf('会员未找到', crumb.output())
示例#3
0
文件: user.py 项目: zhjchina/post_bar
 def GET(self, name):
     limit = 10
     user = user_model().get_one({'name': name})
     if user is None:
         crumb = Crumb()
         crumb.append('会员未找到')
         return render.user_nf('会员未找到', crumb.output())
     else:
         posts_result = post_model().get_all({'user_id': user.id},
                                             limit=limit,
                                             order='time DESC')
         if len(posts_result) > 0:
             posts = []
             for post_result in posts_result:
                 post = {'post': post_result}
                 node = node_model().get_one({'id': post_result.node_id})
                 post['node'] = node
                 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)
         else:
             posts = None
         comments_result = comment_model().get_all({'user_id': user.id},
                                                   limit=limit,
                                                   order='time DESC')
         if len(comments_result) > 0:
             comments = []
             for comment_result in comments_result:
                 post = post_model().get_one({'id': comment_result.post_id})
                 post_user = user_model().get_one({'id': post.user_id})
                 comment = {
                     'post': post,
                     'comment': comment_result,
                     'post_user': post_user
                 }
                 comments.append(comment)
         else:
             comments = None
         following = False
         if session.user_id:
             if user_meta_model().get_one({
                     'user_id': session.user_id,
                     'meta_key': 'follow',
                     'meta_value': user.id
             }):
                 following = True
         return render.profile(user.name, user, posts, comments, following)
示例#4
0
 def GET(self, name):
     user = user_model().get_one({'name':name})
     if user is None:
         crumb = Crumb()
         crumb.append('会员未找到')
         return render.user_nf('会员未找到', crumb.output())
     else:
         if session.user_id is None:
             raise web.SeeOther('/login?next=/profile/'+name)
         user_meta_model().delete({'user_id':session.user_id, 'meta_key':'follow', 'meta_value':user.id})
         user_model().update({'id':session.user_id}, {'user_favs':user_meta_model().count_meta({'user_id':session.user_id, 'meta_key':'follow'})})
         user_model().update_session(session.user_id)
         raise web.SeeOther('/profile/'+name)
示例#5
0
 def GET(self, name):
     limit = 10
     user = user_model().get_one({'name':name})
     if user is None:
         crumb = Crumb()
         crumb.append('会员未找到')
         return render.user_nf('会员未找到', crumb.output())
     else:
         posts_result = post_model().get_all({'user_id':user.id}, limit = limit, order = 'time DESC')
         if len(posts_result) > 0:
             posts = []
             for post_result in posts_result:
                 post = {'post':post_result}
                 node = node_model().get_one({'id':post_result.node_id})
                 post['node'] = node
                 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)
         else:
             posts = None
         comments_result = comment_model().get_all({'user_id':user.id}, limit = limit, order = 'time DESC')
         if len(comments_result) > 0:
             comments = []
             for comment_result in comments_result:
                 post = post_model().get_one({'id':comment_result.post_id})
                 post_user = user_model().get_one({'id':post.user_id})
                 comment = {'post':post, 'comment':comment_result, 'post_user':post_user}
                 comments.append(comment)
         else:
             comments = None
         following = False
         if session.user_id:
             if user_meta_model().get_one({'user_id':session.user_id, 'meta_key':'follow', 'meta_value':user.id}):
                 following = True
         return render.profile(user.name, user, posts, comments, following)
示例#6
0
 def GET(self, name):
     limit = 10
     user = user_model().get_one({'name':name})
     crumb = Crumb()
     if user:
         crumb.append(name, '/profile/'+name)
         crumb.append('全部回复')
         total = comment_model().count_table({'user_id':user.id})
         pagination = Pagination('/profile/'+name+'/comments', total, limit = limit)
         page = pagination.true_page(web.input(p=1)['p'])
         comments_result = comment_model().get_all({'user_id':user.id}, limit = limit, offset = (page-1)*limit, order = 'time DESC')
         if len(comments_result) > 0:
             comments = []
             for comment_result in comments_result:
                 post = post_model().get_one({'id':comment_result.post_id})
                 post_user = user_model().get_one({'id':post.user_id})
                 comment = {'post':post, 'comment':comment_result, 'post_user':post_user}
                 comments.append(comment)
         else:
             comments = None
         return render.user_comments('全部回复', comments, total, crumb.output(), pagination.output())
     else:
         crumb.append('会员未找到')
         return render.user_nf('会员未找到', crumb.output())