예제 #1
0
파일: auth.py 프로젝트: sinreal/miihui
 def POST(self):
      email=web.input().get("email")
      passwd=web.input().get("password")
      key=passwd
      #key=hashlib.md5(passwd).hexdigest()
      user = User.objects(email=email).first()
      if not user :
          return render.login(is_login=Auth.is_login(),content=u"没有这个用户")
      if user.password==key:
          Auth.set_login(user.id,user.username)
          return web.seeother("/")
      return render.login(is_login=Auth.is_login(),content=u"密码错误")
예제 #2
0
파일: item.py 프로젝트: sinreal/miihui
 def GET(self,id):
    page=int(web.input().get('page','1'))
    item=Node.objects(ID=int(id)).first()
    #todo 分页 or ajax
    comments=Tweet.objects(Q(SubjectID=int(id))&Q(flag__ne=1)).order_by("-ID") 
    #flag=1 means share 
    next=None
    if Auth.is_login():
         user=User.objects(id=Auth.uid()).first()
         mycollect=user.nodes_follow
         if item.ID in mycollect:
            collected=True
         else:
           collected=False
    else:
         user=None
         collected=False
    if item and  item.creatorID:
        creator=User.objects(ID=item.creatorID).first()
    else:
        creator =None
    datalist=[]
    for comment in comments:
       datalist.append((User.objects(ID=comment.AutherID).first(),comment))
    if user==creator :
            editble=True
    else:
           editble=False
    if  user and ( user.email=="*****@*****.**" or user.email=="*****@*****.**"  ):
            editble=True
    return render.item(editble=editble,user=user,creator=creator,item=item,datalist=datalist,collected=collected)
예제 #3
0
파일: app.py 프로젝트: sinreal/miihui
 def GET(self):
   if Auth.is_login():
      user=User.objects(id=Auth.uid()).first()
   else:
      user=None
   nodes=Node.objects(score=20).order_by("-ID")
   if nodes.count()>20:
        nodes=nodes[0:20]
   return render.index(user=user,nodes=nodes)           
예제 #4
0
파일: app.py 프로젝트: sinreal/miihui
 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)
예제 #5
0
파일: user.py 프로젝트: sinreal/miihui
 def GET(self,uid):
     #关注我的人 should keep it in  a list ?
     if Auth.is_login():
             me=User.objects(id=Auth.uid()).first()
     else:
            me=None
     user=User.objects(ID=int(uid)).first()
     followeds=User.objects(followings=user.ID)
     page=int(web.input().get("page","1"))
     count=user.followed_count
     if page*10<count:
        next=page+1
     else:
        next=None      
     return render.followeds(user=me,thisguy=user,count=count,next=next,followeds=followeds)
예제 #6
0
파일: app.py 프로젝트: sinreal/miihui
 def GET(self,userID):
   thisguy=User.objects(ID=userID).first()
   c= thisguy.nodes_follow
   if not  c:
     collections=[]
   else:
      collections=[]
      #取最新的收藏
      for _id in c:
        collections.append(Node.objects(ID=_id).first())
   if Auth.is_login():
          me=User.objects(id=Auth.uid()).first()
   else:
         me=None
   counts = thisguy.followings_count,thisguy.followed_count,thisguy.tweet_count      
   return render.usercollections(user=me,thisguy=thisguy, collections=collections, counts =counts)
예제 #7
0
파일: user.py 프로젝트: sinreal/miihui
 def GET(self,uid):
     #关注的人
     if Auth.is_login():
            me=User.objects(id=Auth.uid()).first()
     else:
            me=None
     user=User.objects(ID=int(uid)).first()
     followings_ids=user.followings
     followings=[User.objects(ID=idd).first() for idd in followings_ids] 
     page=int(web.input().get("page","1"))
     count=user.followings_count
     if page*10<count:
        next=page+1
     else:
        next=None      
     return  render.followings(user=me,thisguy=user,count=count,next=next,followings=followings)
예제 #8
0
파일: user.py 프로젝트: sinreal/miihui
  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)
예제 #9
0
 def _check_auth(*args,**kwargs):
     if Auth.is_login():
       return handler(*args,**kwargs)
     else:
       web.seeother("/login")
예제 #10
0
파일: auth.py 프로젝트: sinreal/miihui
 def GET(self):
     return render.login(is_login=Auth.is_login())
예제 #11
0
파일: auth.py 프로젝트: sinreal/miihui
 def GET(self):
     return render.signup(is_login=Auth.is_login(),content=None) 
예제 #12
0
파일: app.py 프로젝트: sinreal/miihui
 def GET(self):
   return render.about(is_login=Auth.is_login(),user=None)
예제 #13
0
파일: app.py 프로젝트: sinreal/miihui
 def GET(self):
   return render.tools(is_login=Auth.is_login(),user=None)