def post(self): retdata = [] type = self.get_argument('type',default='unsolved') if type == '12001':#请求刷新所有动态 u_id = self.get_argument('uid',default='null') u_auth_key = self.get_argument('authkey',default='null') ufuncs = Ufuncs() #判断用户权限 if ufuncs.judge_user_valid(u_id , u_auth_key):#认证成功 data=self.db.query(Trend).all() favorites = self.db.query(Favorite).filter(Favorite.Fuid == u_id,Favorite.Ftype==3, Favorite.Fvalid == 1).all() list=[] exsit=0 for items in favorites: list.append(items.Ftypeid) print '哈哈哈',items.Ftypeid for i in range(len(data)): print '哈哈哈哈',len(data) try: url=self.db.query(TrendImage).filter(TrendImage.TItid==data[i].Tid).one() for item in list: if data[i].Tid == item: exsit =1 break else: exsit = 0 TRfunction.TRresponse(data[i],url.TIimgurl,retdata,exsit) except Exception,e: print e self.retjson['code']='12013' self.retjson['contents'] =retdata else: self.retjson['code']='12012' self.retjson['contents']='用户认证失败'
def post(self): type = self.get_argument('type') type_id = self.get_argument('typeid') uid = self.get_argument('uid') u_authkey = self.get_argument('authkey') ufunc = Ufuncs() if ufunc.judge_user_valid(uid, u_authkey): try: appointment = self.db.query(Appointment).filter(Appointment.APid == type_id).one() if appointment.APvalid == 0: self.retjson['content'] = r"该约拍已失效" else: # 查找是否已经点过赞 try: once_liked = self.db.query(AppointLike).filter(AppointLike.ALapid == type_id, AppointLike.ALuid == uid).one() if once_liked: if once_liked.ALvalid == 1: # 已经赞过 if type == '10601': # 对约拍进行点赞 self.retjson['code'] = '10605' self.retjson['content'] = r'已点过赞' elif type == '10611': # 取消赞 once_liked.ALvalid = 0 try: appointment.APlikeN -= 1 self.db.commit() self.retjson['code'] = '10615' self.retjson['content'] = r'取消赞成功' except Exception, e: self.db_commit_fail(e) else: # 曾经点过赞,但是已经取消 if type == '10601': once_liked.ALvalid = 1 appointment.APlikeN += 1 self.db_commit(r'点赞成功') elif type == '10611': self.retjson['code'] = '10613' self.retjson['content'] = r'用户已取消赞!' except Exception, e: # 未对这个操作过 print e if type == '10611': self.retjson['code'] = '10614' self.retjson['content'] = r'用户未赞过此约拍!' elif type == '10601': new_Aplike = AppointLike( ALapid=type_id, ALuid=uid, ALvalid=1 ) appointment.APlikeN += 1 self.db.merge(new_Aplike) self.db_commit(r'点赞成功') except Exception, e: print e self.retjson['code'] = '10607' self.retjson['content'] = '该约拍不存在'
def post(self): ac_type = self.get_argument('type') if ac_type == '10305': #报名活动 ac_id = self.get_argument('acid') ac_registerid = self.get_argument('registerid') u_auth_key = self.get_argument('authkey') ufuncs = Ufuncs() if ufuncs.judge_user_valid(ac_registerid, u_auth_key): # 用户认证成功 ac_activity = self.db.query(Activity).filter( Activity.ACid == ac_id).one() if ac_activity.ACmaxp == ac_activity.ACregistN: #报名人数是否已满 self.retjson['contents'] = '报名人数已满,无法报名' self.retjson['code'] = '10353' elif ac_activity.ACstatus != 0: self.retjson['contents'] = '该活动已经停止报名' self.retjson['code'] = '10354' else: try: exist = self.db.query(ActivityEntry).filter( ActivityEntry.ACEacid == ac_id, ActivityEntry.ACEregisterid == ac_registerid).one() if exist.ACEregisttvilid: self.retjson['contents'] = r'您已经报名该活动' self.retjson['code'] = '10351' else: #用户曾经报名过该活动 self.db.query(ActivityEntry).\ filter(ActivityEntry.ACEacid == ac_id , ActivityEntry.ACEregisterid == ac_registerid ).\ update({ActivityEntry.ACEregisttvilid : 1},synchronize_session = False) self.updata_activity_number(ac_id, 1) self.db.commit() self.retjson['contents'] = r'您已报名成功' self.retjson['code'] = '10352' except Exception, e: #用户从未报名过该活动 print e new_activityEntry = ActivityEntry( ACEacid=ac_id, ACEregisterid=ac_registerid, ACEregisttvilid=1, ACEscore=0, ACEcomment=0, ) self.db.merge(new_activityEntry) try: self.db.commit() self.updata_activity_number(ac_id, 1) self.retjson['contents'] = r'您已报名成功' self.retjson['code'] = '10352' except Exception, e: print e self.db.rollback() self.retjson['contents'] = r'服务器出错' self.retjson['code'] = '10359'
def post(self): u_id = self.get_argument('uid') ap_type = self.get_argument('type') ap_id = self.get_argument('apid') u_auth_key = self.get_argument('authkey') ufunc = Ufuncs() if ufunc.judge_user_valid(u_id, u_auth_key): # 用户认证成功 if ap_type == '10271': # 报名约拍 ap_message = self.get_argument('message') try: ap_user = self.db.query(User).filter( User.Uauthkey == u_auth_key).one() ap_user_id = ap_user.Uid appointment = self.db.query(Appointment).filter( Appointment.APid == ap_id, Appointment.APstatus == 0).one() try: exist = self.db.query(AppointEntry). \ filter(AppointEntry.AEregisterID == u_id, AppointEntry.AEapid == ap_id, ).one() # 应该再加上和ap_id的验证 if exist.AEvalid == 1: self.retjson['contents'] = '已报名过该约拍' self.retjson['code'] = '10273' else: exist.AEvalid = 1 appointment.APregistN += 1 self.db.commit() self.retjson['contents'] = '报名成功' self.retjson['code'] = '10270' except Exception, e: print e print "插入之前" new_appointmententry = AppointEntry( AEapid=ap_id, AEregisterID=ap_user_id, AEvalid=1, AEchoosed=0, AEmessage=ap_message, ) try: appointment.APregistN += 1 except Exception, e: self.retjson['contents'] = '报名人数增加错误' self.db.merge(new_appointmententry) try: self.db.commit() self.retjson['contents'] = '用户报名成功' self.retjson['code'] = '10270' except Exception, e: print e self.db_error()
def post(self): type = self.get_argument('type') u_auth_key = self.get_argument('authkey') uid = self.get_argument('uid') rank_list_handler = RanklistHandler() ufunc = Ufuncs() if ufunc.judge_user_valid(uid, u_auth_key): # 用户验证成功 if type == '10281': # 请求摄影师排行get_rank_photoers self.retjson['content'] = rank_list_handler.get_rank_photoers() self.retjson['code'] = '10285' elif type == '10282': # 请求模特排行 self.retjson['code'] = '10285' self.retjson['content'] = rank_list_handler.get_rank_models() else: self.retjson['code'] = '10286' self.retjson['content'] = u'用户认证失败!' self.write(json.dumps(self.retjson, ensure_ascii=False, indent=2))
def post(self): # u_auth_key = self.get_argument('authkey') # request_type = self.get_argument('type') # u_id = self.get_argument('uid') retdata = [] # list array type = self.get_argument('type', default='unsolved') if type == '10303': # 1.查看所有活动 u_id = self.get_argument('uid') u_auth_key = self.get_argument('authkey') ufuncs = Ufuncs() # 判断用户权限 if ufuncs.judge_user_valid(u_id, u_auth_key): # 用户认证成功 try: data = self.db.query(Activity).filter( Activity.ACvalid == 1, Activity.ACstatus != 2).order_by( desc(Activity.ACcreateT)).all() length = len(data) print length if length < 10: for i in range(length): #dataimage = self.db.query(ActivityImage).filter(data[i].ACid == ActivityImage.ACLacid).one() datauser = self.db.query(User).filter( data[i].ACsponsorid == User.Uid).one() aclurl = self.db.query(ActivityImage).filter( ActivityImage.ACIacid == data[i].ACid).limit( 1).all() #userurl = self.db.query(UserImage).filter(UserImage.UIuid == datauser.Uid).one() user_headimages = self.db.query(UserImage).filter( UserImage.UIuid == datauser.Uid).all() userimg = [] for user_headimage in user_headimages: exist = self.db.query(Image).filter( Image.IMid == user_headimage.UIimid, Image.IMvalid == 1).all() if exist: userimg = user_headimage break ACFunction.Acresponse(data[i], datauser, aclurl[0].ACIurl, userimg.UIurl, retdata, u_id) self.retjson['code'] = '10303' self.retjson['contents'] = retdata else: for item in range(0, 10): #dataimage = self.db.query(ActivityImage).filter(data[item].ACid == ActivityImage.ACLacid).one() datauser = self.db.query(User).filter( User.Uid == data[item].ACsponsorid).one() aclurl = self.db.query(ActivityImage).filter( ActivityImage.ACIacid == data[item].ACid).limit(1).all() print datauser.Uid print data[item].ACid # userurl = self.db.query(UserImage).filter(UserImage.UIuid == datauser.Uid).one() user_headimages = self.db.query(UserImage).filter( UserImage.UIuid == datauser.Uid).all() userimg = [] for user_headimage in user_headimages: exist = self.db.query(Image).filter( Image.IMid == user_headimage.UIimid, Image.IMvalid == 1).all() if exist: userimg = user_headimage break ACFunction.Acresponse(data[item], datauser, aclurl[0].ACIurl, userimg.UIurl, retdata, u_id) self.retjson['code'] = '10303' self.retjson['contents'] = retdata except Exception, e: print e self.retjson['code'] = '200' self.retjson['contents'] = 'there is no activity' else: self.retjson['code'] = '10373' self.retjson['contents'] = '认证未通过'
m_ACid = self.get_argument("acid", default="unknown") Usermodel = [] try: data = self.db.query(Activity).filter( Activity.ACid == m_ACid).one() print '你好' print data.ACsponsorid acint = data.ACsponsorid except Exception, e: print e if (data.ACsponsorid == int(m_uid)): issponsor = 1 else: issponsor = 0 if ufuncs.judge_user_valid(m_uid, auth_key): # 用户认证成功 try: print '认证成功' data = self.db.query(Activity).filter( m_ACid == Activity.ACid).one() #活动的基本详情 #下面是返回用户的信息 entryid = self.db.query(ActivityEntry).filter( ActivityEntry.ACEacid == m_ACid, ActivityEntry.ACEregisttvilid == 1).all() for item in entryid: Userjson = {'id': '', 'headImage': ''} Userurls = self.db.query(UserImage).filter( UserImage.UIuid == item.ACEregisterid).all() userimg = [] for Userurl in Userurls: exist = self.db.query(Image).filter(
print e self.retjson["code"] = '10382' self.retjson["contents"] = "你没有报名此活动!" else: self.retjson['code'] = '10384' self.retjson['contents'] = '活动尚未结束不能评论!' except Exception, e: print e elif type == '10361' or type == '10362': # elif type=='10311':#活动点赞 uid = self.get_argument('uid') u_authkey = self.get_argument('authkey') m_ACLacid = self.get_argument("aclacid", default="null") #活动的id ufunc = Ufuncs() if ufunc.judge_user_valid(uid, u_authkey): try: print m_ACLacid data = self.db.query(Activity).filter( Activity.ACid == m_ACLacid).one() if data.ACvalid == 0: self.retjson['contents'] = '活动已经失效' else: try: #是否已经点过赞 once_liked = self.db.query(ActivityLike).filter( ActivityLike.ACLacid == m_ACLacid, ActivityLike.ACLuid == uid).one() if once_liked: if once_liked.ACLvalid == 1: # 已经赞过 if type == '10361': # 对活动进行点赞 self.retjson['code'] = '10385'
except Exception,e: print e self.retjson['code'] = '10321' self.retjson['contents'] = '该活动未授权' except Exception,e: print e self.retjson['code'] = '10320' self.retjson['contents'] = '用户授权码错误' elif ac_type == '10307': #取消活动 ac_id = self.get_argument('acid') u_id = self.get_argument('uid') u_auth_key = self.get_argument('authkey') ufuncs = Ufuncs() if ufuncs.judge_user_valid(u_id, u_auth_key): # 用户认证成功 try: sp_id = self.db.query(Activity).filter(Activity.ACid == ac_id,Activity.ACstatus == 0).one() if int(u_id) == sp_id.ACsponsorid : if sp_id.ACvalid == 1: sp_id.ACvalid = 0 self.db.commit() self.retjson['contents'] = '取消活动成功' self.retjson['code'] = '10325' else : self.retjson['contents'] = '你已经取消了该活动' self.retjson['code'] = '10326' else: self.retjson['contents'] = '你不是发起者' self.retjson['code'] = '10327'
ap_id = ap[0].APid imghandler.insert_appointment_image(ap_imgs_json, ap_id) self.retjson['code'] = '10214' self.retjson['contents'] = '发布约拍成功' except Exception, e: print e, '网络故障' self.retjson['contents'] = '数据库错误' self.retjson['code'] = '10215' # 取消约拍 elif ap_type == '10207': auth_key = self.get_argument('authkey') apid = self.get_argument('apid') uid = self.get_argument('userid') ufunc = Ufuncs() if ufunc.judge_user_valid(uid, auth_key): try: appointment = self.db.query(Appointment).filter( Appointment.APid == apid).one() if appointment.APvalid == 1: # 约拍还有效 if appointment.APsponsorid == int(uid): # 报名中,可以取消 if appointment.APstatus == 0: appointment.APvalid = 0 self.db.commit() self.retjson['code'] = '10200' self.retjson['contents'] = '成功取消约拍!' else: self.retjson['code'] = '10215' self.retjson['contents'] = '该约拍正在进行中或已完成,不能取消!'