Ejemplo n.º 1
0
    def get_e_appointment_evaluate(self, u_id):  #  获取我参加的的已评价了的约拍
        ret_e_appointment = []
        ap_e_info = []
        ap_e_entrys = self.db.query(AppointEntry).filter(
            AppointEntry.AEregisterID == u_id, AppointEntry.AEvalid == True,
            AppointEntry.AEchoosed == True).all()
        for ap_e_entry in ap_e_entrys:
            try:
                item = self.db.query(AppointmentInfo).filter(
                    AppointmentInfo.AIappoid == ap_e_entry.AEapid).one()
                if item.AIpid == int(u_id):
                    if AppointmentInfo.AIpcomment:
                        ap_e_info = self.db.query(Appointment).filter(
                            Appointment.APid == ap_e_entry.AEapid, ).all()
                        ret_e_appointment.append(
                            APmodelHandler.ap_Model_simply_one(
                                ap_e_info[0], u_id))
                if item.AImid == int(u_id):
                    if AppointmentInfo.AImcomment:
                        ap_e_info = self.db.query(Appointment).filter(
                            Appointment.APid == ap_e_entry.AEapid, ).all()
                        ret_e_appointment.append(
                            APmodelHandler.ap_Model_simply_one(
                                ap_e_info[0], u_id))

            except Exception, e:
                print e
Ejemplo n.º 2
0
    def get_e_appointment(self, u_id, number):
        ret_e_appointment = []
        ap_e_info = []
        if number == 0:
            ap_e_entrys = self.db.query(AppointEntry).filter(
                AppointEntry.AEregisterID == u_id,
                AppointEntry.AEvalid == True).all()
        else:

            ap_e_entrys = self.db.query(AppointEntry).filter(
                AppointEntry.AEregisterID == u_id,
                AppointEntry.AEvalid == True,
                AppointEntry.AEchoosed == True).all()
        if number == 2:
            for ap_e_entry in ap_e_entrys:
                ap_id = ap_e_entry.AEapid
                try:
                    ap_e_info = self.db.query(Appointment).filter(
                        Appointment.APid == ap_id,
                        Appointment.APstatus >= number,
                        Appointment.APstatus <= number + 1).all()
                except Exception, e:
                    print e
                if ap_e_info:
                    ret_e_appointment.append(
                        APmodelHandler.ap_Model_simply_one(ap_e_info[0], u_id))
Ejemplo n.º 3
0
    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"摄影师约拍列表导入失败!"
Ejemplo n.º 4
0
 def get_my_appointment(self, u_id, number):
     ap_my_entrys = []
     ret_my_appointment = []
     if number == 2:
         try:
             ap_my_entrys = self.db.query(Appointment).filter(
                 Appointment.APsponsorid == u_id,
                 Appointment.APstatus >= number,
                 Appointment.APstatus <= number + 1).all()
         except Exception, e:
             print e
         ret_my_appointment = APmodelHandler.ap_Model_simply(
             ap_my_entrys, ret_my_appointment, u_id)
Ejemplo n.º 5
0
class ApCompanionHandler(BaseHandler):
    retjson = {'code': '', 'contents': ''}

    def post(self):
        type = self.get_argument('type')
        if type == '10900':  # 发布约拍伴侣
            ApcTitle = self.get_argument('title')
            ApOrc = self.get_argument('orgnazation')
            ApcContent = self.get_argument('content')
            ApcUrl = self.get_argument('companionUrl')
            Apcimg = self.get_arguments('companionImgs[]')

            new_ApCompanion = WApCompanions(
                WAPCname=ApcTitle,
                WAPCServeintro=ApcContent,  # 服务内容介绍
                WAPCOrganintro=ApOrc,
                WAPCvalid=1,
                WAPCContact=ApcUrl,
            )

            self.db.merge(new_ApCompanion)
            self.db.commit()
            try:
                OneCompanion = self.db.query(WApCompanions).filter(
                    WApCompanions.WAPCname == ApcTitle,
                    WApCompanions.WAPCServeintro == ApcContent,
                    WApCompanions.WAPCContact == ApcUrl,
                    WApCompanions.WAPCvalid == 1).one()
                image = ImageHandler()
                image.insert_companion_image(Apcimg, OneCompanion.WAPCid)
                self.db.commit()
                self.retjson['code'] = '10900'
                self.retjson['contents'] = '约拍伴侣创建成功'
            except Exception, e:
                print e
                self.retjson['code'] = '10901'
                self.retjson['contents'] = '创建失败'

        elif type == '10904':
            # 返回约拍伴侣
            retdata = []
            Companion_all = self.db.query(WApCompanions).filter(
                WApCompanions.WAPCvalid == 1).all()
            modelhandler = APmodelHandler()
            for item in Companion_all:
                modelhandler.ApCompanion(item, retdata)

            self.retjson['code'] = '10904'
            self.retjson['contents'] = retdata
                    except Exception,e:
                        self.not_in_fav_list()
                except Exception,e:
                    self.not_in_fav_list()


            if type == '10541': # 查看所有收藏的约拍
                retdata = []
                try:
                    favorites = self.db.query(Favorite).filter(Favorite.Fuid == user_id, Favorite.Fvalid == 1,Favorite.Ftype == 1).all()  # 返回收藏列表
                    ap_favorates = []
                    for each_favorite in favorites:
                        ap_favorite_id = each_favorite.Ftypeid  # 即约拍Id
                        ap_favorite = self.db.query(Appointment).filter(Appointment.APid == ap_favorite_id).one()
                        ap_favorates.append(ap_favorite)
                    APmodelHandler.ap_Model_simply(ap_favorates, retdata, user_id)
                    self.retjson['code'] = '10550'
                    self.retjson['contents'] = retdata
                except Exception, e:
                    print e
                    self.retjson['code'] = '10526'
                    self.retjson['contents'] = r'用户未收藏任何约拍'

            if type == '10502':#收藏活动
                    typeid = self.get_argument('typeid')#活动id
                    try:
                        exist = self.db.query(Activity).filter(Activity.ACid == typeid).one()  #活动是否存在
                        if exist:  # 该约拍存在
                            if exist.ACvalid == 1:  # 该活动还有效
                                try:  # 判断用户曾经是否对活动拍进行过收藏动作,
                                    once_favorite = self.db.query(Favorite).filter(Favorite.Fuid == user_id,
Ejemplo n.º 7
0
    def post(self):
        askcode = self.get_argument('askCode')  # 请求码
        m_phone = self.get_argument('phone')
        if askcode == '10106':  # 手动登录
            m_password = self.get_argument('password')
            if not m_phone or not m_password:
                self.retjson['code'] = 400
                self.retjson['contents'] = 10105  # '用户名密码不能为空'
                # todo:登录返回json的retdata多一层[],客户端多0.5秒处理时间
                # 防止重复注册
            else:
                try:
                    user = self.db.query(User).filter(
                        User.Utel == m_phone).one()
                    if user:  # 用户存在
                        password = user.Upassword
                        if m_password == password:  # 密码正确
                            print u'密码正确'
                            self.retjson['code'] = 200
                            if user.Ubirthday:
                                Ubirthday = user.Ubirthday.strftime(
                                    '%Y-%m-%d %H:%M:%S'),
                            else:
                                Ubirthday = ''
                            retdata = []
                            u_auth_key = user.Uauthkey
                            user_model = dict(
                                id=user.Uid,
                                phone=user.Utel,
                                nickName=user.Ualais,
                                realName=user.Uname,
                                sign=user.Usign,
                                sex=user.Usex,
                                score=user.Uscore,
                                location=user.Ulocation,
                                birthday=Ubirthday,
                                registTime=user.UregistT.strftime(
                                    '%Y-%m-%d %H:%M:%S'),
                                mailBox=user.Umailbox,
                                headImage=
                                r"http://img5.imgtn.bdimg.com/it/u=1268523085,477716560&fm=21&gp=0.jpg",
                                auth_key=u_auth_key)
                            photo_list = []  # 摄影师发布的约拍
                            model_list = []
                            daohangl_list = []
                            daohangl_list.append(
                                Model_daohanglan(
                                    'http://img3.imgtn.bdimg.com/it/u=4271053251,2424464488&fm=21&gp=0.jpg',
                                    'www.baidu.com'))
                            daohangl_list.append(
                                Model_daohanglan(
                                    'http://image8.360doc.com/DownloadImg/2010/04/0412/2762690_45.jpg',
                                    'http://image.baidu.com/search/detail?ct=503316480&z=0&ipn=d&word=%E7%BE%8E%E5%9B%BE&step_word=&hs=0&pn=24&spn=0&di=14293150190&pi=0&rn=1&tn=baiduimagedetail&is=&istype=0&ie=utf-8&oe=utf-8&in=&cl=2&lm=-1&st=undefined&cs=2860350365%2C3214019191&os=289517539%2C4157278886&simid=0%2C0&adpicid=0&ln=1992&fr=&fmq=1472885603080_R&fm=&ic=undefined&s=undefined&se=&sme=&tab=0&width=&height=&face=undefined&ist=&jit=&cg=&bdtype=0&oriquery=&objurl=http%3A%2F%2Fimage8.360doc.com%2FDownloadImg%2F2010%2F04%2F0412%2F2762690_45.jpg&fromurl=ippr_z2C%24qAzdH3FAzdH3Fooo_z%26e3Bnma15v_z%26e3Bv54AzdH3Fv5gpjgpAzdH3F8aAzdH3FabdaAzdH3F88AzdH3F8nad0dl_9098dc0d_z%26e3Bfip4s&gsm=0&rpstart=0&rpnum=0'
                                ))
                            try:
                                print 'shaixuanqian'

                                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()  # 创建对象
                                print 'chuangjianchengg'

                                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)
                                print 'shaixuanchengg'
                                data = dict(
                                    userModel=user_model,
                                    daohanglan=daohangl_list,
                                    photoList=photo_list,
                                    modelList=model_list,
                                )
                                # todo 待生成真的导航栏

                                retdata.append(data)
                                self.retjson['code'] = '10101'
                                self.retjson['contents'] = retdata
                            except Exception, e:
                                print e
                                self.retjson['contents'] = r"摄影师约拍列表导入失败!"

                        else:
                            self.retjson['contents'] = u'密码错误'
                            self.retjson['code'] = '10104'  # 密码错误
                    else:  # 用户不存在
                        self.retjson['contents'] = u'该用户不存在或服务器错误'
                        self.retjson['code'] = '10103'
Ejemplo n.º 8
0
    def post(self):

        # todo 还未增加图片地址,活动按时间排序
        retjson = {'code': '', 'contents': ''}
        retdata_ap = []
        ret_json_contents = {}
        retdata_ac = []
        ac = ACmodelHandler()
        ap = APmodelHandler()

        type = self.get_argument('type')
        u_id = self.get_argument('uid')
        auth_key = self.get_argument('authkey')
        u_other_id = self.get_argument('seeid')
        if type == '10801':  # 查看个人主页
            ufuncs = Userinfo.Ufuncs.Ufuncs()
            retdata_ap = []
            if ufuncs.judge_user_valid(u_id,
                                       auth_key):  # 判断userID与auth_key是否匹配
                u_info = self.db.query(User).filter(
                    User.Uid == u_other_id).one()
                u_change_info = self.db.query(UCinfo).filter(
                    UCinfo.UCuid == u_other_id).one()
                ret_user_info = userinfo_smply(u_info, u_change_info)
                ret_json_contents['user_info'] = ret_user_info

                exist = self.db.query(UserLike).filter(
                    UserLike.ULlikeid == u_id,
                    UserLike.ULlikedid == u_other_id,
                    UserLike.ULvalid == 1).all()
                if exist:
                    ret_json_contents['follow'] = True
                else:
                    ret_json_contents['follow'] = False
                # # 筛选有效的约拍信息
                # u_appointment_infos = self.db.query(AppointEntry).filter(AppointEntry.AEregisterID == u_other_id,
                #                                                          AppointEntry.AEvalid ==1).all()
                # for u_appointment_info in u_appointment_infos:
                #     ap_id = u_appointment_info.AEapid
                #     try:
                #         ap_info = self.db.query(Appointment).filter(Appointment.APid == ap_id,
                #                                                     Appointment.APvalid == True).one()
                #         retdata_ap.append(ap.ap_Model_simply_one(ap_info,u_id))
                #     except Exception,e:
                #         print e
                #         retjson['code'] = '10602'
                #         retjson['contents']='该约拍不存在'
                # try:
                #     u_spap_infos = self.db.query(Appointment).filter(Appointment.APsponsorid == u_other_id,
                #                                                  Appointment.APvalid == True).all()
                #
                #     for u_spap_info in u_spap_infos:
                #        retdata_ap.append(ap.ap_Model_simply_one(u_spap_info,u_id))
                # except Exception, e:
                #     print e
                #
                # ret_json_contents['ap_info'] =retdata_ap
                #
                # #筛选有效的活动信息
                # u_ac_infos = self.db.query(ActivityEntry).filter(ActivityEntry.ACEregisterid == u_other_id,
                #                                                  ActivityEntry.ACEregisttvilid ==1).all()
                # for u_ac_info in u_ac_infos:
                #     ac_id = u_ac_info.ACEacid
                #     ac_info = self.db.query(Activity).filter(Activity.ACid ==ac_id, Activity.ACvalid == 1).all()
                #     if ac_info:
                #         ret_ac  = ac.ac_Model_simply(ac_info[0],'default')
                #         retdata_ac.append(ret_ac)
                # ret_json_contents['ac_info'] =retdata_ac
                retjson['code'] = '10601'
                retjson['contents'] = ret_json_contents

            else:
                retjson['code'] = '10600'
                retjson['contents'] = '授权码不正确'
            self.write(json.dumps(retjson, ensure_ascii=False, indent=2))
Ejemplo n.º 9
0
    def post(self):
        ret_contents = {}
        ret_activity = []
        ret_e_appointment = []
        ret_my_appointment = []
        ac = ACmodelHandler()
        ap = APmodelHandler()
        type = self.get_argument('type')
        u_id = self.get_argument('uid')
        auth_key = self.get_argument('authkey')
        ufuncs = Ufuncs.Ufuncs()
        if ufuncs.judge_user_valid(u_id, auth_key):
            if type == '10901':  # 查看我的已报名的约拍活动
                ret_activity = self.get_activity(u_id, 0)
                ret_contents['activity'] = ret_activity
                ret_e_appointment = self.get_e_appointment(u_id, 0)
                ret_contents['entryappointment'] = ret_e_appointment
                ret_my_appointment = self.get_my_appointment(u_id, 0)
                ret_contents['myappointment'] = ret_my_appointment
                self.retjson['code'] = '10392'
                self.retjson['contents'] = ret_contents

            elif type == '10902':  # 查看我的正在进行的约拍活动
                ret_activity = self.get_activity(u_id, 1)
                ret_contents['activity'] = ret_activity
                ret_e_appointment = self.get_e_appointment(u_id, 1)
                ret_contents['entryappointment'] = ret_e_appointment
                ret_my_appointment = self.get_my_appointment(u_id, 1)
                ret_contents['myappointment'] = ret_my_appointment
                self.retjson['code'] = '10393'
                self.retjson['contents'] = ret_contents

            elif type == '10903':  # 查看我的已经完成的但是没有评价约拍活动
                ret_activity = self.get_activity(u_id, 2)
                ret_contents['activity'] = ret_activity
                ret_e_appointment = self.get_e_appointment_not_evaluate(u_id)
                ret_contents['entryappointment'] = ret_e_appointment
                ret_my_appointment = self.get_my_appointment_not_evaluate(u_id)
                ret_contents['myappointment'] = ret_my_appointment
                self.retjson['code'] = '10394'
                self.retjson['contents'] = ret_contents

            elif type == '10909':  # 查看我的已经完成评价的约拍 这里没有活动了,因为活动没有状态码4

                ret_e_appointment = self.get_e_appointment_evaluate(u_id)
                ret_contents['entryappointment'] = ret_e_appointment
                ret_my_appointment = self.get_my_appointment_evaluate(u_id)
                ret_contents['myappointment'] = ret_my_appointment
                self.retjson['code'] = '10395'
                self.retjson['contents'] = ret_contents

            elif type == '10904':  # 选择约拍对象
                apid = self.get_argument('apid')
                chooseuid = self.get_argument('chooseduid')
                try:
                    registEntry = self.db.query(AppointEntry).\
                        filter(AppointEntry.AEregisterID == chooseuid, AppointEntry.AEapid == apid).one()  # 查找报名项
                    if registEntry:
                        if registEntry.AEvalid == 1:  # 用户未取消报名
                            if registEntry.AEchoosed:
                                self.retjson['contents'] = u'之前已选择过该用户!'
                            else:  # 用户报名中且未被选择,添加新的约拍项
                                registEntry.AEchoosed = 1  # 该用户被选择
                                try:
                                    appointment = self.db.query(Appointment.APid, Appointment.APsponsorid, Appointment.APtype,
                                                                Appointment.APstatus).\
                                        filter(Appointment.APid == registEntry.AEapid).one()
                                    if appointment.APsponsorid == int(
                                            u_id):  # 该操作用户是发起者
                                        mid = pid = 0
                                        if appointment.APtype == 1:  # 发起者是摄影师:
                                            mid = chooseuid
                                            pid = u_id
                                        elif appointment.APtype == 0:  # 发起者是模特:
                                            mid = u_id
                                            pid = chooseuid
                                        print 'before change'
                                        self.db.query(Appointment).filter(Appointment.APid == appointment.APid).\
                                        update({"APstatus": 1}, synchronize_session='evaluate') # 将该约拍项移到进行中
                                        print 'after change'
                                        newappinfo = AppointmentInfo(
                                            AImid=mid,
                                            AIpid=pid,
                                            AIappoid=apid)
                                        try:
                                            self.db.merge(newappinfo)
                                            self.db.commit()
                                            self.retjson['code'] = '10920'
                                            self.retjson[
                                                'contents'] = u"选择约拍对象成功"
                                        except Exception, e:
                                            print e
                                            self.retjson['code'] = '10925'
                                            self.retjson[
                                                'contents'] = u"数据库插入错误"
                                    else:
                                        self.retjson['code'] = '10921'
                                        self.retjson[
                                            'contents'] = u"该用户没有选择权限!"
                                except Exception, e:
                                    print e
                                    self.retjson['code'] = '10924'
                                    self.retjson['contents'] = u'该约拍不存在或已过期'
Ejemplo n.º 10
0
                    print e
                if ap_e_info:
                    ret_e_appointment.append(
                        APmodelHandler.ap_Model_simply_one(ap_e_info[0], u_id))
        else:
            for ap_e_entry in ap_e_entrys:
                ap_id = ap_e_entry.AEapid
                try:
                    ap_e_info = self.db.query(Appointment).filter(
                        Appointment.APid == ap_id,
                        Appointment.APstatus == number).all()
                except Exception, e:
                    print e
                if ap_e_info:
                    ret_e_appointment.append(
                        APmodelHandler.ap_Model_simply_one(ap_e_info[0], u_id))

        return ret_e_appointment

    def get_my_appointment(self, u_id, number):
        ap_my_entrys = []
        ret_my_appointment = []
        if number == 2:
            try:
                ap_my_entrys = self.db.query(Appointment).filter(
                    Appointment.APsponsorid == u_id,
                    Appointment.APstatus >= number,
                    Appointment.APstatus <= number + 1).all()
            except Exception, e:
                print e
            ret_my_appointment = APmodelHandler.ap_Model_simply(