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


Python ILSGatewayConfig.get_all_configs方法代码示例

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


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

示例1: handle

# 需要导入模块: from custom.ilsgateway.models import ILSGatewayConfig [as 别名]
# 或者: from custom.ilsgateway.models.ILSGatewayConfig import get_all_configs [as 别名]
    def handle(self):
        words = self.args
        if len(words) < 2 or len(words) > 3:
            self.respond(REGISTER_HELP)
            return

        name = words[0]
        code = words[1]
        params = {
            "msd_code": code
        }
        if not self.user:
            domains = [config.domain for config in ILSGatewayConfig.get_all_configs()]
            for domain in domains:
                loc = self._get_facility_location(domain, code)
                if not loc:
                    continue

                splited_name = name.split(' ', 1)
                first_name = splited_name[0]
                last_name = splited_name[1] if len(splited_name) > 1 else ""
                clean_name = name.replace(' ', '.')
                username = "%[email protected]%s.commcarehq.org" % (clean_name, domain)
                password = User.objects.make_random_password()
                user = CommCareUser.create(domain=domain, username=username, password=password,
                                           commit=False)
                user.first_name = first_name
                user.last_name = last_name

                if len(words) == 3:
                    user.user_data = {
                        'role': words[2]
                    }

                try:
                    user.set_default_phone_number(self.msg.phone_number.replace('', ''))
                    user.save_verified_number(domain, self.msg.phone_number.replace('', ''), True, self.msg.backend_api)
                except PhoneNumberInUseException as e:
                    v = VerifiedNumber.by_phone(self.msg.phone_number, include_pending=True)
                    v.delete()
                    user.save_verified_number(domain, self.msg.phone_number.replace('', ''), True, self.msg.backend_api)
                except CommCareUser.Inconsistent:
                    continue

                user.language = Languages.DEFAULT

                params.update({
                    'sdp_name': loc.name,
                    'contact_name': name
                })

                dm = user.get_domain_membership(domain)
                dm.location_id = loc._id
                user.save()
                add_location(user, loc._id)

        self.respond(REGISTRATION_CONFIRM, **params)
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:59,代码来源:registration.py

示例2: handle

# 需要导入模块: from custom.ilsgateway.models import ILSGatewayConfig [as 别名]
# 或者: from custom.ilsgateway.models.ILSGatewayConfig import get_all_configs [as 别名]
    def handle(self):
        text = ' '.join(self.msg.text.split()[1:])
        is_district = False
        sp = ""
        msd_code = ""

        if text.find(self.DISTRICT_REG_DELIMITER) != -1:
            phrases = [x.strip() for x in text.split(":")]
            if len(phrases) != 2:
                self.respond(REGISTER_HELP)
                return
            name = phrases[0]
            sp = phrases[1]
            role = Roles.DISTRICT_PHARMACIST
            message = REGISTRATION_CONFIRM_DISTRICT
            params = {}
            is_district = True
        else:
            names = []
            msd_codes = []
            location_regex = '^({prefs})\d+'.format(prefs='|'.join(p.lower() for p in DISTRICT_PREFIXES))
            for the_string in self.args:
                if re.match(location_regex, the_string.strip().lower()):
                    msd_codes.append(the_string.strip().lower())
                else:
                    names.append(the_string)

            name = " ".join(names)
            if len(msd_codes) != 1:
                self.respond(REGISTER_HELP)
                return
            else:
                [msd_code] = msd_codes

            role = Roles.IN_CHARGE
            message = REGISTRATION_CONFIRM
            params = {
                "msd_code": msd_code
            }

        if not self.user:
            domains = [config.domain for config in ILSGatewayConfig.get_all_configs()]
            for domain in domains:
                if is_district:
                    loc = self._get_district_location(domain, sp)
                else:
                    loc = self._get_facility_location(domain, msd_code)
                if not loc:
                    continue
                splited_name = name.split(' ', 1)
                first_name = splited_name[0]
                last_name = splited_name[1] if len(splited_name) > 1 else ""
                clean_name = name.replace(' ', '.')
                username = "%[email protected]%s.commcarehq.org" % (clean_name, domain)
                password = User.objects.make_random_password()
                user = CommCareUser.create(domain=domain, username=username, password=password,
                                           commit=False)
                user.first_name = first_name
                user.last_name = last_name
                try:
                    user.set_default_phone_number(self.msg.phone_number.replace('+', ''))
                    user.save_verified_number(domain, self.msg.phone_number.replace('+', ''), True, self.msg.backend_api)
                except PhoneNumberInUseException as e:
                    v = VerifiedNumber.by_phone(self.msg.phone_number, include_pending=True)
                    v.delete()
                    user.save_verified_number(domain, self.msg.phone_number.replace('+', ''), True, self.msg.backend_api)
                except CommCareUser.Inconsistent:
                    continue
                user.language = Languages.DEFAULT
                params.update({
                    'sdp_name': loc.name,
                    'contact_name': name
                })

                user.user_data = {
                    'role': role
                }

                dm = user.get_domain_membership(domain)
                dm.location_id = loc._id
                user.save()
                add_location(user, loc._id)
        if params:
            self.respond(message, **params)
开发者ID:nnestle,项目名称:commcare-hq,代码行数:86,代码来源:register.py

示例3: migration_task

# 需要导入模块: from custom.ilsgateway.models import ILSGatewayConfig [as 别名]
# 或者: from custom.ilsgateway.models.ILSGatewayConfig import get_all_configs [as 别名]
def migration_task():
    configs = ILSGatewayConfig.get_all_configs()
    for config in configs:
        if config.enabled:
            ils_bootstrap_domain(ILSGatewayAPI(config.domain, ILSGatewayEndpoint.from_config(config)))
开发者ID:jmaina,项目名称:commcare-hq,代码行数:7,代码来源:tasks.py

示例4: migration_task

# 需要导入模块: from custom.ilsgateway.models import ILSGatewayConfig [as 别名]
# 或者: from custom.ilsgateway.models.ILSGatewayConfig import get_all_configs [as 别名]
def migration_task():
    configs = ILSGatewayConfig.get_all_configs()
    for config in configs:
        if config.enabled:
            bootstrap_domain(config)
开发者ID:SEL-Columbia,项目名称:commcare-hq,代码行数:7,代码来源:tasks.py


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