def get_login_model(self, user): retdata = [] user_model = Usermodel.get_user_detail_from_user(user) # 用户模型 photo_list = [] # 摄影师发布的约拍 model_list = [] try: photo_list_all = self.db.query(Appointment).filter(Appointment.APtype == 1, Appointment.APvalid == 1). \ order_by(desc(Appointment.APcreateT)).limit(6).all() model_list_all = self.db.query(Appointment).filter(Appointment.APtype == 0, Appointment.APvalid == 1). \ order_by(desc(Appointment.APcreateT)).limit(6).all() from Appointment.APmodel import APmodelHandler ap_model_handler = APmodelHandler() # 创建对象 ap_model_handler.ap_Model_simply(photo_list_all, photo_list, user.Uid) ap_model_handler.ap_Model_simply(model_list_all, model_list, user.Uid) data = dict( userModel=user_model, daohanglan=self.bannerinit(), photoList=photo_list, modelList=model_list, ) # todo 待生成真的导航栏 retdata.append(data) self.retjson['code'] = '10111' self.retjson['contents'] = retdata except Exception, e: print e self.retjson['contents'] = r"摄影师约拍列表导入失败!"
def get_new_login_model(self, user): models = [] retdata = [] imghandler = UserImgHandler() user_model = Usermodel.get_user_detail_from_user(user) # 用户模型 try: my_likes = self.db.query(UserLike).filter( UserLike.ULlikeid == user.Uid, UserLike.ULvalid == 1).all() for like in my_likes: pic = self.db.query(UserCollection).filter( UserCollection.UCuser == like.ULlikedid, UserCollection.UCvalid == 1).all() for item in pic: retdata.append( imghandler.UC_login_model(item, item.UCuser, user.Uid)) # 推荐作品集 # 约拍类型和id data = dict( userModel=user_model, daohanglan=self.bannerinit(), CollectionList=retdata, # 好友作品集 RecList=[], # 推荐作品集 groupList=APgroupHandler.Group(), ) models.append(data) self.retjson['code'] = '10111' self.retjson['contents'] = models except Exception, e: print e self.retjson['contents'] = r"摄影师约拍列表导入失败!"
def get_rank_list_usermodel(self, rs_models, type): ''' Args: type: 1为摄影师,2为模特 rs_models: 排行榜摄影师或模特的RankScore模型 Returns:排行榜摄影师的用户模型 ''' user_models = [] auth = AuthKeyHandler() for rs_umodel in rs_models: rs_u_id = rs_umodel.RSuid # 摄影师的用户id try: user = db.query(User).filter(User.Uid == rs_u_id).one() user_model = Usermodel.get_user_detail_from_user(user) # 摄影师 if type == 1: user_model['rank'] = rs_umodel.RSPrank user_model['image'] = auth.download_url('0' + str(user.Uid) + '.png') #print user_model.id # 模特 elif type == 2: user_model['rank'] = rs_umodel.RSMrank user_model['image'] = auth.download_url( str(user.Uid) + '.png') user_models.append(user_model) except Exception, e: print e, u"未查找找到该用户"
def post(self): type = self.get_argument('type') # 请求摄影师模特列表 if type == '10850': authkey = self.get_argument('authkey') # 用户认证 retdata = [] try: userid = self.db.query(User).filter( User.Uauthkey == authkey).one() # 用户本身 if userid.Ucategory == 0: self.retjson['code'] = '10851' self.retjson['contents'] = '请设置您的用户类型:摄影师or模特' else: imghandler = UserImgHandler() #reclist = imghandler.reclist(userid.Uid) # 朋友的朋友列表(不包括自己) reclist = [ 14, 15, 19, 20, 31, 38, 50, 54, 55, 93, 94, 98, 100, 103, 106 ] # 用于测试的朋友的朋友列表 if reclist: try: UserRec = self.db.query(User).filter( User.Uid.in_(reclist)).all() for item in UserRec: uc = self.db.query(UserCollection).filter( UserCollection.UCuser == item.Uid).all() if uc: # 如果有作品集 retdata.append( Usermodel.rec_user_list(item)) else: continue if retdata == []: NewUserRec = self.db.query(UserCollection).filter(UserCollection.UCvalid == 1). \ order_by(desc(UserCollection.UCcreateT)).limit(5).all() for item in NewUserRec: Users = self.db.query(User).filter( User.Uid == item.UCuser).all() retdata.append( Usermodel.rec_user_list(Users[0])) # 重复返回作品集(方便客户端测试) retdata += retdata retdata += retdata self.retjson['code'] = '10850' self.retjson['contents'] = retdata except Exception, e: print e self.retjson['contents'] = '获取推荐列表失败' else: # 如果用户没有关注(也就是没有朋友),那么推荐最近的作品集 UserRec = self.db.query(UserCollection).filter(UserCollection.UCvalid == 1).\ order_by(desc(UserCollection.UCcreateT)).limit(5).all() for item in UserRec: Users = self.db.query(User).filter( User.Uid == item.UCuser).all() retdata.append(Usermodel.rec_user_list(Users[0])) # 重复返回作品集(方便客户端测试) # retdata += retdata # retdata += retdata self.retjson['code'] = '10850' self.retjson['contents'] = retdata