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


Python EWSGhanaConfig.for_domain方法代码示例

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


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

示例1: tearDownClass

# 需要导入模块: from custom.ewsghana.models import EWSGhanaConfig [as 别名]
# 或者: from custom.ewsghana.models.EWSGhanaConfig import for_domain [as 别名]
 def tearDownClass(cls):
     MobileBackend.load_by_name(TEST_DOMAIN, TEST_BACKEND).delete()
     CommCareUser.get_by_username('stella').delete()
     CommCareUser.get_by_username('super').delete()
     delete_all_locations()
     LocationType.objects.all().delete()
     for product in Product.by_domain(TEST_DOMAIN):
         product.delete()
     SQLProduct.objects.all().delete()
     EWSGhanaConfig.for_domain(TEST_DOMAIN).delete()
     DocDomainMapping.objects.all().delete()
     generator.delete_all_subscriptions()
     Domain.get_by_name(TEST_DOMAIN).delete()
开发者ID:sheelio,项目名称:commcare-hq,代码行数:15,代码来源:utils.py

示例2: tearDownClass

# 需要导入模块: from custom.ewsghana.models import EWSGhanaConfig [as 别名]
# 或者: from custom.ewsghana.models.EWSGhanaConfig import for_domain [as 别名]
 def tearDownClass(cls):
     CommCareUser.get_by_username("stella").delete()
     CommCareUser.get_by_username("super").delete()
     FacilityInCharge.objects.all().delete()
     delete_all_locations()
     LocationType.objects.all().delete()
     for product in Product.by_domain(TEST_DOMAIN):
         product.delete()
     SQLProduct.objects.all().delete()
     EWSGhanaConfig.for_domain(TEST_DOMAIN).delete()
     DocDomainMapping.objects.all().delete()
     generator.delete_all_subscriptions()
     cls.sms_backend_mapping.delete()
     cls.backend.delete()
     Domain.get_by_name(TEST_DOMAIN).delete()
开发者ID:bazuzi,项目名称:commcare-hq,代码行数:17,代码来源:utils.py

示例3: handle

# 需要导入模块: from custom.ewsghana.models import EWSGhanaConfig [as 别名]
# 或者: from custom.ewsghana.models.EWSGhanaConfig import for_domain [as 别名]
def handle(verified_contact, text, msg=None):
    user = verified_contact.owner if verified_contact else None
    domain = user.domain
    if not domain:
        return False

    if not EWSGhanaConfig.for_domain(domain):
        return False

    args = text.split()
    if not args:
        send_sms_to_verified_number(verified_contact, unicode(INVALID_MESSAGE))
        return True
    keyword = args[0]
    args = args[1:]
    params = {
        'user': user,
        'domain': domain,
        'args': args,
        'msg': msg,
        'verified_contact': verified_contact
    }

    def not_function(word):
        if args and re.match("del", word):
            return NotDeliveredHandler
        elif args and re.match("sub", word):
            return NotSubmittedHandler
        return None

    handlers = {
        ('help', ): HelpHandler,
        ('stop', ): StopHandler,
        ('start', ): StartHandler,
        ('language', 'lang', 'lugha'): LanguageHandler,
        ('yes', 'no', 'y', 'n'): RequisitionHandler,
        ('undo', 'replace', 'revoke'): UndoHandler,
        ('soh',): AlertsHandler,
        ('not',): not_function(args[0]) if args else None,
        ('rec', 'receipts', 'received'): ReceiptsHandler
    }

    def choose_handler(keyword):
        for k, v in handlers.iteritems():
            if keyword.lower() in k:
                return v
        return None

    handler_class = choose_handler(keyword)
    handler = handler_class(**params) if handler_class else None

    if handler:
        if args:
            return handler.handle()
        else:
            handler.help()
            return True
    else:
        return AlertsHandler(**params).handle()
开发者ID:nnestle,项目名称:commcare-hq,代码行数:61,代码来源:handler.py

示例4: ews_sync_stock_data

# 需要导入模块: from custom.ewsghana.models import EWSGhanaConfig [as 别名]
# 或者: from custom.ewsghana.models.EWSGhanaConfig import for_domain [as 别名]
def ews_sync_stock_data(request, domain):
    apis = (
        ('stock_transaction', sync_stock_transactions),
    )
    config = EWSGhanaConfig.for_domain(domain)
    domain = config.domain
    endpoint = GhanaEndpoint.from_config(config)
    stock_data_task.delay(domain, endpoint, apis, config, EWS_FACILITIES)
    return HttpResponse('OK')
开发者ID:aristide,项目名称:commcare-hq,代码行数:11,代码来源:views.py

示例5: ews_stock_data_task

# 需要导入模块: from custom.ewsghana.models import EWSGhanaConfig [as 别名]
# 或者: from custom.ewsghana.models.EWSGhanaConfig import for_domain [as 别名]
def ews_stock_data_task(domain):
    ewsghana_config = EWSGhanaConfig.for_domain(domain)
    domain = ewsghana_config.domain
    endpoint = GhanaEndpoint.from_config(ewsghana_config)
    commtrack_settings_sync(domain, LOCATION_TYPES)
    for product in endpoint.get_products():
        sync_ilsgateway_product(domain, product)
    get_locations(domain, endpoint, EWS_FACILITIES)
    get_product_stock(domain, endpoint, EWS_FACILITIES)
    get_stock_transaction(domain, endpoint, EWS_FACILITIES)
开发者ID:bradmerlin,项目名称:commcare-hq,代码行数:12,代码来源:tasks.py

示例6: fix_users_with_more_than_one_phone_number

# 需要导入模块: from custom.ewsghana.models import EWSGhanaConfig [as 别名]
# 或者: from custom.ewsghana.models.EWSGhanaConfig import for_domain [as 别名]
def fix_users_with_more_than_one_phone_number(domain):
    config = EWSGhanaConfig.for_domain(domain)
    endpoint = GhanaEndpoint.from_config(config)
    ews_api = EWSApi(domain, endpoint)

    offset = 0
    _, smsusers = endpoint.get_smsusers(filters={'with_more_than_one_number': True})
    while smsusers:
        for sms_user in smsusers:
            ews_api.sms_user_sync(sms_user)
        offset += 100
        _, smsusers = endpoint.get_smsusers(filters={'with_more_than_one_number': True}, offset=offset)
开发者ID:johan--,项目名称:commcare-hq,代码行数:14,代码来源:tasks.py

示例7: handle

# 需要导入模块: from custom.ewsghana.models import EWSGhanaConfig [as 别名]
# 或者: from custom.ewsghana.models.EWSGhanaConfig import for_domain [as 别名]
def handle(verified_contact, text, msg=None):
    user = verified_contact.owner if verified_contact else None
    domain = user.domain

    if domain and not EWSGhanaConfig.for_domain(domain):
        return False

    args = text.split()
    if not args:
        return False
    keyword = args[0]
    args = args[1:]
    params = {
        'user': user,
        'domain': domain,
        'args': args,
        'msg': msg,
        'verified_contact': verified_contact
    }

    def not_function(word):
        if args and re.match("del", word):
            return NotDeliveredHandler
        elif args and re.match("sub", word):
            return NotSubmittedHandler
        return None

    handlers = {
        ('language', 'lang', 'lugha'): LanguageHandler,
        ('reg', 'register'): RegistrationHandler,
        ('yes', 'no', 'y', 'n'): RequisitionHandler,
        ('undo', 'replace', 'revoke'): UndoHandler,
        ('soh'): AlertsHandler,
        ('not',): not_function(args[0]) if args else None
    }

    def choose_handler(keyword):
        for k, v in handlers.iteritems():
            if keyword in k:
                return v
        return None

    handler_class = choose_handler(keyword)
    handler = handler_class(**params) if handler_class else None

    if handler:
        if args:
            handler.handle()
        else:
            handler.help()
    if keyword == 'soh':
        return True
    return False
开发者ID:jmaina,项目名称:commcare-hq,代码行数:55,代码来源:handler.py

示例8: migrate_email_settings

# 需要导入模块: from custom.ewsghana.models import EWSGhanaConfig [as 别名]
# 或者: from custom.ewsghana.models.EWSGhanaConfig import for_domain [as 别名]
def migrate_email_settings(domain):
    config = EWSGhanaConfig.for_domain(domain)
    endpoint = GhanaEndpoint.from_config(config)
    migrate_email = EmailSettingsSync(domain)

    for report in endpoint.get_daily_reports()[1]:
        migrate_email.daily_report_sync(report)

    for report in endpoint.get_weekly_reports()[1]:
        migrate_email.weekly_report_sync(report)

    for report in endpoint.get_monthly_reports()[1]:
        migrate_email.monthly_report_sync(report)
开发者ID:johan--,项目名称:commcare-hq,代码行数:15,代码来源:tasks.py

示例9: endpoint

# 需要导入模块: from custom.ewsghana.models import EWSGhanaConfig [as 别名]
# 或者: from custom.ewsghana.models.EWSGhanaConfig import for_domain [as 别名]
 def endpoint(self):
     from custom.ewsghana.api import GhanaEndpoint
     return GhanaEndpoint.from_config(EWSGhanaConfig.for_domain(self.domain))
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:5,代码来源:comparison_report.py

示例10: ews_bootstrap_domain_task

# 需要导入模块: from custom.ewsghana.models import EWSGhanaConfig [as 别名]
# 或者: from custom.ewsghana.models.EWSGhanaConfig import for_domain [as 别名]
def ews_bootstrap_domain_task(domain):
    ews_config = EWSGhanaConfig.for_domain(domain)
    return bootstrap_domain(EWSApi(domain, GhanaEndpoint.from_config(ews_config)))
开发者ID:johan--,项目名称:commcare-hq,代码行数:5,代码来源:tasks.py

示例11: balance_migration_task

# 需要导入模块: from custom.ewsghana.models import EWSGhanaConfig [as 别名]
# 或者: from custom.ewsghana.models.EWSGhanaConfig import for_domain [as 别名]
def balance_migration_task(domain):
    endpoint = GhanaEndpoint.from_config(EWSGhanaConfig.for_domain(domain))
    BalanceMigration(domain, endpoint).balance_email_reports()
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:5,代码来源:tasks.py

示例12: ews_add_products_to_locs

# 需要导入模块: from custom.ewsghana.models import EWSGhanaConfig [as 别名]
# 或者: from custom.ewsghana.models.EWSGhanaConfig import for_domain [as 别名]
def ews_add_products_to_locs(request, domain):
    config = EWSGhanaConfig.for_domain(domain)
    endpoint = GhanaEndpoint.from_config(config)
    add_products_to_loc.delay(EWSApi(domain=domain, endpoint=endpoint))
    return HttpResponse('OK')
开发者ID:aristide,项目名称:commcare-hq,代码行数:7,代码来源:views.py

示例13: endpoint

# 需要导入模块: from custom.ewsghana.models import EWSGhanaConfig [as 别名]
# 或者: from custom.ewsghana.models.EWSGhanaConfig import for_domain [as 别名]
 def endpoint(self):
     return GhanaEndpoint.from_config(EWSGhanaConfig.for_domain(self.domain))
开发者ID:jmaina,项目名称:commcare-hq,代码行数:4,代码来源:comparison_report.py

示例14: ews_fix_sms_users

# 需要导入模块: from custom.ewsghana.models import EWSGhanaConfig [as 别名]
# 或者: from custom.ewsghana.models.EWSGhanaConfig import for_domain [as 别名]
def ews_fix_sms_users(request, domain):
    config = EWSGhanaConfig.for_domain(domain)
    endpoint = GhanaEndpoint.from_config(config)
    sms_users_fix.delay(EWSApi(domain=domain, endpoint=endpoint))
    return HttpResponse('OK')
开发者ID:aristide,项目名称:commcare-hq,代码行数:7,代码来源:views.py

示例15: ews_resync_passwords

# 需要导入模块: from custom.ewsghana.models import EWSGhanaConfig [as 别名]
# 或者: from custom.ewsghana.models.EWSGhanaConfig import for_domain [as 别名]
def ews_resync_passwords(request, domain):
    config = EWSGhanaConfig.for_domain(domain)
    endpoint = GhanaEndpoint.from_config(config)
    resync_webusers_passwords_task.delay(config, endpoint)
    return HttpResponse('OK')
开发者ID:bradmerlin,项目名称:commcare-hq,代码行数:7,代码来源:views.py


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