当前位置: 首页>>代码示例>>Python>>正文


Python QueryHelper.get_corp_by_cid方法代码示例

本文整理汇总了Python中helpers.queryhelper.QueryHelper.get_corp_by_cid方法的典型用法代码示例。如果您正苦于以下问题:Python QueryHelper.get_corp_by_cid方法的具体用法?Python QueryHelper.get_corp_by_cid怎么用?Python QueryHelper.get_corp_by_cid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在helpers.queryhelper.QueryHelper的用法示例。


在下文中一共展示了QueryHelper.get_corp_by_cid方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_corp_by_cid [as 别名]
    def post(self):
        cid = self.get_argument("cid", "")
        message = None
        url = None
        corp = QueryHelper.get_corp_by_cid(cid, self.db)
        if not corp:
            message = ErrorCode.USER_NOT_FOUND
            self.render("delegation/delegation_enterprise.html", message=message, url=url)
        else:
            uid = "dummy"
            tid = "dummy"
            tmobile = "dummy"
            cid = cid
            oid = UWEB.DUMMY_OID

            url = "/".join(
                [
                    ConfHelper.UWEB_CONF.url_out,
                    UWebHelper.URLS.DELEGATION[1:],
                    str(uid),
                    str(tid),
                    str(tmobile),
                    str(cid),
                    str(oid),
                ]
            )
            sign = UWebHelper.get_sign("".join([str(uid), str(tid), str(tmobile), str(cid), str(oid)]))
            url += "?s=" + sign
            self.log_delegation(self.current_user.id, cid, uid, tid)

            self.render("delegation/delegation_enterprise.html", message=message, url=url)
开发者ID:jcsy521,项目名称:ydws,代码行数:33,代码来源:delegate.py

示例2: get

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_corp_by_cid [as 别名]
    def get(self):
        """Display profile of current corp.
        """
        status = ErrorCode.SUCCESS
        try: 
            profile = DotDict()
            # 1: user
            corp = QueryHelper.get_corp_by_cid(self.current_user.cid, self.db)
            if not corp:
                status = ErrorCode.LOGIN_AGAIN
                logging.error("[UWEB] Corp does not exist, redirect to login.html. cid: %s.", 
                              self.current_user.cid)
                self.write_ret(status)
                return

            profile.update(corp)
            self.write_ret(status,
                           dict_=dict(profile=profile))
        except Exception as e:
            logging.exception("[UWEB] Get corp profile failed. cid:%s, tid:%s, Exception: %s", 
                              self.current_user.cid, self.current_user.tid, e.args) 
            status = ErrorCode.SERVER_BUSY
            self.write_ret(status)
开发者ID:jcsy521,项目名称:ydws,代码行数:25,代码来源:profile.py

示例3: post

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_corp_by_cid [as 别名]
    def post(self):
        """Add a terminal.
        """
        status = ErrorCode.SUCCESS
        try:
            data = DotDict(json_decode(self.request.body))
            logging.info("[UWEB] Corp add terminal request: %s, cid: %s",
                         data, self.current_user.cid)
        except Exception as e:
            status = ErrorCode.ILLEGAL_DATA_FORMAT
            self.write_ret(status)
            return

        try:
            if data.has_key('cnum') and not check_cnum(data.cnum):
                status = ErrorCode.ILLEGAL_CNUM
                self.write_ret(status)
                return

            # 1 year
            begintime = int(time.time())
            now_ = datetime.datetime.now()
            endtime = now_ + relativedelta(years=1)
            endtime = int(time.mktime(endtime.timetuple()))

            # 1: add terminal
            #umobile = data.umobile if data.umobile else self.current_user.cid
            if data.umobile:
                umobile = data.umobile
            else:
                corp = QueryHelper.get_corp_by_cid(self.current_user.cid, self.db)
                umobile = corp.get('c_mobile', '')

            terminal = QueryHelper.get_terminal_by_tmobile(data.tmobile, self.db)
            if terminal:
                if terminal.service_status == UWEB.SERVICE_STATUS.TO_BE_UNBIND:
                    delete_terminal(terminal.tid, self.db, self.redis)
                else:
                    logging.error(
                        "[UWEB] mobile: %s already existed.", data.tmobile)
                    status = ErrorCode.TERMINAL_ORDERED
                    self.write_ret(status)
                    return

            vibl = data.get("vibl")
            use_scene = get_use_scene_by_vibl(vibl)

            biz_type = data.get('biz_type', UWEB.BIZ_TYPE.YDWS)
            tid = data.tmobile

            terminal_info = dict(tid=tid,
                                 group_id=data.group_id,
                                 tmobile=data.tmobile,
                                 owner_mobile=umobile,
                                 mannual_status=UWEB.DEFEND_STATUS.YES,
                                 begintime=begintime,
                                 endtime=4733481600,
                                 offline_time=begintime,
                                 cnum=data.cnum,
                                 icon_type=data.icon_type,
                                 login_permit=data.login_permit,
                                 push_status=data.push_status,
                                 vibl=data.vibl,
                                 use_scene=use_scene,
                                 biz_type=biz_type,
                                 speed_limit=data.speed_limit,
                                 stop_interval=data.stop_interval,
                                 service_status=UWEB.SERVICE_STATUS.ON)

            if int(biz_type) == UWEB.BIZ_TYPE.YDWS:
                # 0. check tmobile is whitelist or not
                white_list = check_zs_phone(data.tmobile, self.db)
                if not white_list:
                    logging.error("[UWEB] mobile: %s is not whitelist.", data.tmobile)
                    status = ErrorCode.MOBILE_NOT_ORDERED
                    message = ErrorCode.ERROR_MESSAGE[status] % data.tmobile
                    self.write_ret(status, message=message)
                    return

                # 4: send message to terminal
                register_sms = SMSCode.SMS_REGISTER % (umobile, data.tmobile)
                ret = SMSHelper.send_to_terminal(data.tmobile, register_sms)
            else:
                tid = get_tid_from_mobile_ydwq(data.tmobile)
                activation_code = QueryHelper.get_activation_code(self.db)
                terminal_info['tid'] = tid
                terminal_info['activation_code'] = activation_code
                terminal_info['service_status'] = UWEB.SERVICE_STATUS.TO_BE_ACTIVATED
                register_sms = SMSCode.SMS_REGISTER_YDWQ % (ConfHelper.UWEB_CONF.url_out, activation_code)
                ret = SMSHelper.send(data.tmobile, register_sms)

            add_terminal(terminal_info, self.db, self.redis)
            # record the add action
            bind_info = dict(tid=data.tmobile,
                             tmobile=data.tmobile,
                             umobile=umobile,
                             group_id=data.group_id,
                             cid=self.current_user.cid,
                             add_time=int(time.time()))
            record_add_action(bind_info, self.db)
#.........这里部分代码省略.........
开发者ID:jcsy521,项目名称:ydws,代码行数:103,代码来源:terminal.py

示例4: get

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_corp_by_cid [as 别名]
    def get(self):
        """Get terminal info.
        """
        status = ErrorCode.SUCCESS
        try:
            tid = self.get_argument('tid', None)
            # check tid whether exist in request and update current_user
            self.check_tid(tid)

            # part 1: terminal
            tracker = DotDict()
            # 1: terminal
            # NOTE: static_val, move_val are deprecated
            terminal = QueryHelper.get_available_terminal(
                self.current_user.tid, self.db)

            if not terminal:
                status = ErrorCode.LOGIN_AGAIN
                logging.error("The terminal with tid: %s does not exist, redirect to login.html", 
                              self.current_user.tid)
                self.write_ret(status)
                return

            # 撤防,智能设防
            if terminal['mannual_status'] != UWEB.DEFEND_STATUS.YES:
                terminal['parking_defend'] = 1
            else:  # 强力设防
                terminal['parking_defend'] = 0

            # 2: sos is deprecatd
            user = QueryHelper.get_user_by_uid(self.current_user.uid, self.db)
            if not user:
                status = ErrorCode.LOGIN_AGAIN
                logging.error("The user with uid: %s does not exist, redirect to login.html", 
                              self.current_user.uid)
                self.write_ret(status)
                return

            sos = dict(mobile='')
            tracker.update(sos)

            tracker.update(dict(push_status=terminal.push_status))
            tracker.update(dict(sos_pop=terminal.white_pop))
            tracker.update(dict(vibl=terminal.vibl))
            tracker.update(dict(static_val=terminal.static_val))
            tracker.update(dict(parking_defend=terminal.parking_defend))
            tracker.update(dict(owner_mobile=terminal.owner_mobile))
            tracker.update(dict(speed_limit=terminal.speed_limit))

            # part 2: profile

            profile = DotDict()

            car = QueryHelper.get_car_by_tid(self.current_user.tid, self.db)

            profile.update(dict(name=user.name,
                                mobile=user.mobile,
                                email=user.email,
                                cnum=car.cnum))

            # part 3: sms option
            sms_options = QueryHelper.get_sms_option(user.mobile, self.db)

            # part 5: corp info
            corp = DotDict()
            corp = QueryHelper.get_corp_by_cid(self.current_user.cid, self.db)

            self.write_ret(status,
                           dict_=dict(tracker=tracker,
                                      sms_options=sms_options,
                                      profile=profile,
                                      corp=corp))
        except Exception as e:
            status = ErrorCode.SERVER_BUSY
            logging.exception("[UWEB] Get appsetting failed. uid: %s tid: %s, Exception: %s",
                              self.current_user.uid, self.current_user.tid, e.args)
            self.write_ret(status)
开发者ID:jcsy521,项目名称:ydws,代码行数:79,代码来源:appsettings.py

示例5: get

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_corp_by_cid [as 别名]
    def get(self):
        status=ErrorCode.SUCCESS
        # from_ = self.get_argument('from', '').lower()
        index_html = "index.html"
        bizcode = None
        name = ''
        if self.current_user.oid != UWEB.DUMMY_OID: # operator
            index_html = "index_corp.html"
            umobile=self.current_user.oid
            user_info = QueryHelper.get_operator_by_oid(self.current_user.oid, self.db)
            corp_info = QueryHelper.get_corp_by_oid(self.current_user.oid, self.db)
            if user_info:
                name = user_info.name if user_info.name else user_info.mobile 
            user_type = UWEB.USER_TYPE.OPERATOR
            bizcode = corp_info.bizcode
        elif self.current_user.cid != UWEB.DUMMY_CID: # corp
            index_html = "index_corp.html"
            umobile=self.current_user.cid
            user_info = QueryHelper.get_corp_by_cid(self.current_user.cid, self.db)
            if user_info:
                name = user_info.c_linkman if user_info.c_linkman else user_info.c_mobile 
            user_type = UWEB.USER_TYPE.CORP
            bizcode = user_info.bizcode
        else: # user
            umobile=self.current_user.uid
            user_info = QueryHelper.get_user_by_uid(self.current_user.uid, self.db)
            if user_info:
                name = user_info.name if user_info.name else user_info.mobile 
            user_type = UWEB.USER_TYPE.PERSON

        if not user_info:
            status = ErrorCode.LOGIN_AGAIN
            logging.error("The user with uid: %s does not exist, redirect to login.html", self.current_user.uid)
            self.render("login.html",
                        username='',
                        password='',
                        user_type=UWEB.USER_TYPE.PERSON,
                        message=None,
                        message_captcha=None)
            return

        static_hash = self.redis.get('static_hash')
        static_hash = static_hash if static_hash else u'dummy_hash'

        wspush = dict(id='', 
                      key='') 
        json_data = WSPushHelper.register_wspush(umobile, self.redis) 
        if json_data: 
            data = json_data['data'] 
            id = data.get('push_id', '') 
            key = data.get('psd', '') 
            wspush['id'] = id
            wspush['key'] = key

        self.render(index_html,
                    map_type=ConfHelper.LBMP_CONF.map_type,
                    user_type=user_type,
                    bizcode=bizcode,
                    status=status,
                    name=name,
                    umobile=umobile,
                    static_hash=static_hash,
                    wspush=wspush,)
开发者ID:jcsy521,项目名称:ydws,代码行数:65,代码来源:main.py

示例6: post

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_corp_by_cid [as 别名]
    def post(self):
        """Retrieve the password."""
        status = ErrorCode.SUCCESS
        try:
            data = DotDict(json_decode(self.request.body))
            mobile = data.mobile
            captcha = data.get('captcha','')
            logging.info("[UWEB] corp retrieve password request: %s", 
                         data)
        except Exception as e:
            status = ErrorCode.ILLEGAL_DATA_FORMAT
            self.write_ret(status)
            return 

        try:
            status = ErrorCode.SUCCESS
            psd = get_psd()                        
            user = QueryHelper.get_corp_by_cid(mobile, self.db)         
            if user: # corp
                psd_info = dict(user_id=mobile,
                                user_type=UWEB.USER_TYPE.CORP,
                                password=psd)
                if not captcha: # old version 
                    update_password(psd_info, self.db, self.redis)
                else: # new version
                    captcha_key = get_captcha_key(mobile)
                    captcha_old = self.redis.get(captcha_key)
                    if captcha_old:
                        if captcha == str(captcha_old):                            
                            update_password(psd_info, self.db, self.redis)
                        else:
                            status = ErrorCode.WRONG_CAPTCHA
                            logging.error("[UWEB] Crop retrieve password failed."
                                          "  mobile: %s, captcha: %s, captcha_old: %s, Message: %s", 
                                          mobile, captcha, captcha_old, ErrorCode.ERROR_MESSAGE[status])
                    else:
                        status = ErrorCode.NO_CAPTCHA
                        logging.error("[UWEB] Corp retrieve password failed. "
                                      "  mobile: %s, captcha: %s, Message: %s", 
                                      mobile, captcha, ErrorCode.ERROR_MESSAGE[status])
            else: 
                user = QueryHelper.get_operator_by_oid(mobile, self.db)
                if user: # operator
                    psd_info = dict(user_id=mobile,
                                    user_type=UWEB.USER_TYPE.OPERATOR,
                                    password=psd)
                    if not captcha: # old version
                        update_password(psd_info, self.db, self.redis)
                    else: # new version
                        captcha_key = get_captcha_key(mobile)
                        captcha_old = self.redis.get(captcha_key)
                        if captcha_old:
                            if captcha == str(captcha_old):        
                                update_password(psd_info, self.db, self.redis)
                            else:
                                status = ErrorCode.WRONG_CAPTCHA
                                logging.error("[UWEB] Operator retrieve password failed. "
                                              "  mobile: %s, captcha: %s, captcha_old: %s, Message: %s", 
                                               mobile, captcha, captcha_old, ErrorCode.ERROR_MESSAGE[status])
                        else:
                            status = ErrorCode.NO_CAPTCHA
                            logging.error("[UWEB] Operator retrieve password failed. "
                                          "  mobile: %s, captcha: %s, Message: %s", 
                                          mobile, captcha, ErrorCode.ERROR_MESSAGE[status])
                else:
                    status = ErrorCode.USER_NOT_ORDERED
                    logging.error("[UWEB] Operator does not exist, retrieve password failed. mobile: %s", 
                                  mobile)

            if status == ErrorCode.SUCCESS:
                retrieve_password_sms = SMSCode.SMS_RETRIEVE_PASSWORD % (psd) 
                ret = SMSHelper.send(mobile, retrieve_password_sms)
                ret = DotDict(json_decode(ret))
                if ret.status == ErrorCode.SUCCESS:
                    logging.info("[UWEB] Corp retrieve password success, "
                                 "  mobile: %s, the new passwrod: %s", 
                                 mobile, psd)
                else:
                    status = ErrorCode.SERVER_BUSY
                    logging.error("[UWEB] Corp retrieve password failed. mobile: %s", 
                                  mobile)
            self.write_ret(status)
        except Exception as e:
            logging.exception("[UWEB] Corp retrieve password failed. mobile: %s, Exception: %s", 
                              mobile, e.args)
            status = ErrorCode.SERVER_BUSY
            self.write_ret(status)
开发者ID:jcsy521,项目名称:ydws,代码行数:89,代码来源:password.py


注:本文中的helpers.queryhelper.QueryHelper.get_corp_by_cid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。