コード例 #1
0
 def post(self):
     msgid=''
     try:
         point=int(self.request.get('point','0'))
         username=get_current_user(self)
         user=getorAddUserPoint(username)
         msg=u'竞拍成功。'
         if point>user.point:
             msg=u'竞拍失败,积分不足。'
         else:
             pl=PaiMai.all().order('-__key__').fetch(1)
             pm=None
             if 1==len(pl):
                 pm=pl[0]
                 lasttimestr=jingpaiDate()
                 if lasttimestr!=pm.key().name()[1:]:
                     pm=PaiMai(key_name='p'+lasttimestr)
                     memcache.delete('adnote')
             elif 0==len(pl):
                 pm=PaiMai(key_name='p'+ setting.AdNoteTime)
                 memcache.delete('adnote')
             if pm.maxpoint<point:
                 pm.maxpoint=point
                 pm.user=username
                 pm.put()
             else:
                 msg=u'竞拍失败,使用积分少于 当前竞拍最高分 。'
         msgid=str(uuid.uuid4())
         memcache.set(msgid,msg,3600)
     except :
         pass
     self.redirect('/JingPai?msg='+msgid)
     return
コード例 #2
0
    def get(self):
        username=get_current_user(self)
        lasttimestr=jingpaiDate()
        starttime=datetime.datetime.strptime(lasttimestr,'%Y%m%d')
        endtime=starttime+datetime.timedelta(hours =24*7)-+datetime.timedelta(minutes =1)
        pl=PaiMai.all().order('-__key__').fetch(1)
        pm=None
        if 1==len(pl):
            pm=pl[0]
            if lasttimestr!=pm.key().name()[1:]:
                pm=None
        adnote=None
        if pm:
            adnote=AdNote.get_by_key_name('u'+pm.user)
        msgid=self.request.get('msg')
        msg=None
        if msgid:
            msg=memcache.get(msgid)

        self.render('templates/jingpai.html',{'username':username,'starttime':starttime,'endtime':endtime,'paimai':pm,'adnote':adnote,'userpoint':getorAddUserPoint(username),'msg':msg})
コード例 #3
0
 def get(self):
     username=get_current_user(self)
     self.render('templates/topnav.html',{'username':username,'user':getorAddUser(username),'userpoint':getorAddUserPoint(username)})