def GET(self,uid): myuid=Auth.uid() page=int(web.input().get("page","1")) thisguy=User.objects(ID=int(uid)).first() if not thisguy: return render.notfound() thisguy.tweet_count=Tweet.objects(AutherID=thisguy.ID).count() counts = thisguy.followings_count,thisguy.followed_count,thisguy.tweet_count #update count if page*20<counts[2]: next=page+1 elif page*20-counts[2]>20 : return web.notfound() else: next=None if Auth.is_login(): me=User.objects(id=Auth.uid()).first() else: me=None if not me: relation=None elif me==thisguy: relation="self" elif thisguy.ID in me.followings: relation="ifollowhim" else: relation=None # do i follow that people? datalist=[] posts=Tweet.objects(AutherID=thisguy.ID).order_by("-ID")[(page-1)*20:page*20] for p in posts: if p.SubjectID>0: if p.flag==1: datalist.append(("share" ,Node.objects(ID=p.SubjectID).first(),p, friendly_time(p.created).decode("utf-8"))) elif p.flag==-1: pass else: datalist.append(("comment" ,Node.objects(ID=p.SubjectID).first(),p, friendly_time(p.created).decode("utf-8"))) elif p.flag==-1: pass else: datalist.append(("say",p,friendly_time(p.created).decode("utf-8"))) return render.user(user=me,thisguy=thisguy,counts=counts,next=next,datalist=datalist,relation=relation)
def GET(self,uid): if Auth.is_login(): user=User.objects(id=Auth.uid()).first() else: user=None thisguy=User.objects(ID=uid).first() datalist=[] shares=Share_items.objects(creatorID=int(uid)) counts=(0,0,0) for p in shares: datalist.append(("share" ,Node.objects(ID=p.itemID).first(),p, friendly_time(p.created).decode("utf-8"))) return render.share_items(user=user,thisguy=thisguy,datalist=datalist,counts=counts)
def GET(self): myuid=Auth.uid() page=int(web.input().get("page","1")) me=User.objects(id=myuid).first() counts = me.followings_count,me.followed_count,me.tweet_count if page*20<counts[2]: next=page+1 elif page*20-counts[2]>20 : return web.notfound() else: next=None datalist=[] posts=Tweet.objects(AutherID=me.ID).order_by("-ID")[(page-1)*20:page*20] for p in posts: if p.SubjectID>0: if p.flag==1: datalist.append(("share" ,Node.objects(ID=p.SubjectID).first(),p, friendly_time(p.created).decode("utf-8"))) else: datalist.append(("comment" ,Node.objects(ID=p.SubjectID).first(),p, friendly_time(p.created).decode("utf-8"))) else: datalist.append(("say",p,friendly_time(p.created).decode("utf-8"))) return render.home(is_login=True,datalist=datalist,user=me,counts=counts,next=next)
def GET(self): page=int(web.input().get("page","1")) me=User.objects(id=Auth.uid()).first() #todo .. me.tweet_count=Tweet.objects(AutherID=me.ID).count() counts = me.followings_count,me.followed_count,me.tweet_count c= me.nodes_follow if not c: collections=[] else: collections=[] #取最新的收藏 for _id in c: collections.append(Node.objects(ID=_id).first()) if len(collections)>6: collections=collections[0:6] print counts[2] if page*20<counts[2]: next=page+1 elif page*20-counts[2]>20 : return web.notfound() else: next=None datalist=[] posts=Tweet.objects(AutherID=me.ID).order_by("-ID")[(page-1)*20:page*20] for p in posts: if p.SubjectID>0: if p.flag==1: datalist.append(("share" ,Node.objects(ID=p.SubjectID).first(),p, friendly_time(p.created).decode("utf-8"))) else: datalist.append(("comment" ,Node.objects(ID=p.SubjectID).first(),p, friendly_time(p.created).decode("utf-8"))) else: datalist.append(("say",p,friendly_time(p.created).decode("utf-8"))) return render.home(datalist=datalist,user=me,counts=counts,next=next,collections=collections)