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


Python QueryHelper.get_default_group_by_cid方法代码示例

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


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

示例1: post

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_default_group_by_cid [as 别名]
    def post(self):
        try:
            data = json_decode(self.request.body)
            tmobile = data.get('tmobile', None)
            cid = data.get('cid', None)
            logging.info("[ADMIN] user_type modify request, data:%s", 
                          data)
        except Exception as e:
            logging.exception("[ADMIN] Invalid data format, data:%s, Exception:%s", 
                              data, e.args)
            status = ErrorCode.FAILED 
            self.write_ret(status) 
            return

        try:
            status = ErrorCode.SUCCESS 
            if cid: # individual --> enterprise
                group = QueryHelper.get_default_group_by_cid(cid, self.db)
                self.db.execute("UPDATE T_TERMINAL_INFO SET group_id = %s"
                                "  WHERE mobile = %s",
                                group.gid, tmobile)
            else: # enterprise --> individual
                self.db.execute("UPDATE T_TERMINAL_INFO SET group_id = -1"
                                "  WHERE mobile = %s",
                                tmobile)
                logging.info("[ADMIN] Terminal: %s becomes a invididual", 
                              tmobile)
            self.write_ret(status) 
        except Exception as e:
            status = ErrorCode.SERVER_BUSY
            logging.exception("[ADMIN] user_type modify failed. Exception:%s", 
                              e.args)
            self.write_ret(status) 
开发者ID:jcsy521,项目名称:ydws,代码行数:35,代码来源:usertype.py

示例2: post

# 需要导入模块: from helpers.queryhelper import QueryHelper [as 别名]
# 或者: from helpers.queryhelper.QueryHelper import get_default_group_by_cid [as 别名]
    def post(self):
        status = ErrorCode.SUCCESS
        try:
            data = DotDict(json_decode(self.request.body))
            tmobile = data.get('tmobile', None)
            umobile = data.get('umobile', None)
            group_id = data.get('group_id', None)
            if int(group_id) == -1:
                group = QueryHelper.get_default_group_by_cid(self.current_user.cid, self.db)
                group_id = group.gid
            cnum = data.get('cnum', None)
            avatar = None
            avatar_ = data.get('avatar', None)
            if avatar_:
                avatar = base64.urlsafe_b64decode(str(avatar_))
            logging.info("[BIND] umobile: %s, tmobile: %s",
                         umobile, tmobile)
        except Exception as e:
            logging.exception("[BIND] Illegal format, body: %s, Exception: %s",
                              self.request.body, e.args)
            status = ErrorCode.ILLEGAL_DATA_FORMAT
            self.write_ret(status)
            return

        try:
            # record the add action 
            begintime = int(time.time())
            now_ = datetime.datetime.now()
            endtime = now_ + relativedelta(years=1)
            endtime = int(time.mktime(endtime.timetuple()))

            # avatar
            terminal = self.db.get("SELECT id, tid, service_status FROM T_TERMINAL_INFO WHERE mobile = %s",
                                   tmobile)
            if terminal:
                if terminal.service_status == UWEB.SERVICE_STATUS.TO_BE_UNBIND:
                    delete_terminal(terminal.tid, self.db, self.redis)
                else:
                    status = ErrorCode.TERMINAL_ORDERED
                    logging.error("[UWEB] mobile: %s already existed.", tmobile)
                    self.write_ret(status)
                    return
 
            tid = get_tid_from_mobile_ydwq(tmobile)
            activation_code = QueryHelper.get_activation_code(self.db)
            terminal_info = dict(tid=tid,
                                 group_id=group_id,
                                 tmobile=tmobile,
                                 owner_mobile=umobile,
                                 mannual_status=UWEB.DEFEND_STATUS.YES,
                                 begintime=begintime,
                                 endtime=4733481600,
                                 offline_time=begintime,
                                 cnum=cnum,
                                 icon_type=0,
                                 login_permit=1,
                                 push_status=1,
                                 vibl=1,
                                 use_scene=3,
                                 activation_code=activation_code,
                                 service_status=UWEB.SERVICE_STATUS.TO_BE_ACTIVATED)
            add_terminal(terminal_info, self.db, self.redis)
            bind_info = dict(tid=tmobile, 
                             tmobile=tmobile,
                             umobile=umobile,
                             group_id=group_id,
                             cid=self.current_user.cid, 
                             add_time=begintime)
            record_add_action(bind_info, self.db)
            avatar_full_path, avatar_path, avatar_name, avatar_time = self.get_avatar_info(tmobile)

            register_sms = SMSCode.SMS_REGISTER_YDWQ % (ConfHelper.UWEB_CONF.url_out, activation_code)
            ret = SMSHelper.send(tmobile, register_sms)
            ret = DotDict(json_decode(ret))
            if ret.status == ErrorCode.SUCCESS:
                self.db.execute("UPDATE T_TERMINAL_INFO"
                                "  SET msgid = %s"
                                "  WHERE mobile = %s",
                                ret['msgid'], tmobile)

                if avatar:
                    avatar_name = tmobile + '.png'
                    avatar_path = self.application.settings['avatar_path'] + avatar_name
                    avatar_full_path = self.application.settings['server_path'] + avatar_path

                    img = open(avatar_full_path, 'w')
                    img.write(avatar)
                    img.close()
                    avatar_time = self.update_avatar_time(tmobile)
                    logging.info("[BIND] avatar_time: %s, tmobile: %s, user: %s",
                                 avatar_time, tmobile, self.current_user.cid)
                else:
                    logging.error("[BIND] Terminal: %s has no avatar.",
                                  tmobile)
            else:
                logging.error("[BIND] Send %s to terminal %s failed.", register_sms, tmobile)

            self.write_ret(status,
                           dict_=dict(avatar_path=avatar_path,
                                      avatar_time=avatar_time))
#.........这里部分代码省略.........
开发者ID:jcsy521,项目名称:ydws,代码行数:103,代码来源:bind.py


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