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


Python models.EWSGhanaConfig类代码示例

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


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

示例1: setUp

    def setUp(self):
        self.endpoint = MockEndpoint('http://test-api.com/', 'dummy', 'dummy')
        self.stock_api_object = MockEWSStockDataSynchronization(TEST_DOMAIN, self.endpoint)
        self.datapath = os.path.join(os.path.dirname(__file__), 'data')
        initial_bootstrap(TEST_DOMAIN)
        self.api_object = EWSApi(TEST_DOMAIN, self.endpoint)
        self.api_object.prepare_commtrack_config()
        config = EWSGhanaConfig()
        config.domain = TEST_DOMAIN
        config.enabled = True
        config.all_stock_data = True
        config.password = 'dummy'
        config.username = 'dummy'
        config.url = 'http://test-api.com/'
        config.save()
        l1 = Location(
            name='Test location 1',
            external_id='3445',
            location_type='Hospital',
            domain=TEST_DOMAIN
        )

        l2 = Location(
            name='Test location 2',
            external_id='4407',
            location_type='Hospital',
            domain=TEST_DOMAIN
        )

        l1.save()
        l2.save()

        with open(os.path.join(self.datapath, 'sample_products.json')) as f:
            for product_json in json.loads(f.read()):
                self.api_object.product_sync(Product(product_json))
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:35,代码来源:test_stock_data_sync.py

示例2: tearDownClass

 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,代码行数:13,代码来源:utils.py

示例3: prepare_domain

def prepare_domain(domain_name):
    domain = create_domain(domain_name)
    domain.convert_to_commtrack()

    domain.default_sms_backend_id = TEST_BACKEND
    domain.save()

    def _make_loc_type(name, administrative=False, parent_type=None):
        return LocationType.objects.get_or_create(
            domain=domain_name,
            name=name,
            administrative=administrative,
            parent_type=parent_type,
        )[0]

    country = _make_loc_type(name="country", administrative=True)
    _make_loc_type(name="Central Medical Store", parent_type=country)
    _make_loc_type(name="Teaching Hospital", parent_type=country)

    region = _make_loc_type(name="region", administrative=True, parent_type=country)
    _make_loc_type(name="Regional Medical Store", parent_type=region)
    _make_loc_type(name="Regional Hospital", parent_type=region)

    district = _make_loc_type(name="district", administrative=True, parent_type=region)
    _make_loc_type(name="Clinic", parent_type=district)
    _make_loc_type(name="District Hospital", parent_type=district)
    _make_loc_type(name="Health Centre", parent_type=district)
    _make_loc_type(name="CHPS Facility", parent_type=district)
    _make_loc_type(name="Hospital", parent_type=district)
    _make_loc_type(name="Psychiatric Hospital", parent_type=district)
    _make_loc_type(name="Polyclinic", parent_type=district)
    _make_loc_type(name="facility", parent_type=district)

    generator.instantiate_accounting_for_tests()
    account = BillingAccount.get_or_create_account_by_domain(
        domain.name,
        created_by="automated-test",
    )[0]
    plan = DefaultProductPlan.get_default_plan_by_domain(
        domain, edition=SoftwarePlanEdition.ADVANCED
    )
    subscription = Subscription.new_domain_subscription(
        account,
        domain.name,
        plan
    )
    subscription.is_active = True
    subscription.save()
    ews_config = EWSGhanaConfig(enabled=True, domain=domain.name)
    ews_config.save()
    return domain
开发者ID:nnestle,项目名称:commcare-hq,代码行数:51,代码来源:utils.py

示例4: tearDownClass

 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,代码行数:15,代码来源:utils.py

示例5: first_soh_reminder

def first_soh_reminder():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            role = user.user_data.get('role')
            if role and role != IN_CHARGE_ROLE:
                first_soh_process_user(user)
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:7,代码来源:reminders.py

示例6: on_going_non_reporting

def on_going_non_reporting():
    now = datetime.datetime.utcnow()
    date = now - datetime.timedelta(days=21)
    domains = EWSGhanaConfig.get_all_enabled_domains()

    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            try:
                user_location = SQLLocation.objects.get(domain=domain, location_id=user.location._id)
            except AttributeError:
                continue
            if user_location:
                facilities = []
                if user_location.location_type == 'district':
                    facilities = user_location.get_children()
                elif user_location.location_type == 'region':
                    facilities = SQLLocation.objects.filter(domain=domain,
                                                            parent__parent__location_id=user.location._id)
                fac = set()
                for facility in facilities:
                    sp = facility.supply_point_id
                    if sp and not StockTransaction.objects.filter(
                            case_id=sp, type="stockonhand", report__date__gte=date).exists():
                        fac.add(str(facility.name))
                if fac and user.get_verified_number():
                    message = ONGOING_NON_REPORTING % " \n".join(fac)
                    send_sms_to_verified_number(user.get_verified_number(), message)
                    if user.email:
                        email = str(user.email)
                        send_mail('ONGOING NON REPORTING', message, '[email protected]', [email])
开发者ID:jmaina,项目名称:commcare-hq,代码行数:30,代码来源:alerts.py

示例7: second_soh_reminder

def second_soh_reminder():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            roles = user.user_data.get('role')
            if roles and IN_CHARGE_ROLE in roles:
                second_soh_process_user(user)
开发者ID:sheelio,项目名称:commcare-hq,代码行数:7,代码来源:reminders.py

示例8: second_soh_reminder

def second_soh_reminder():
    now = datetime.datetime.utcnow()
    date = now - datetime.timedelta(days=DAYS_UNTIL_LATE)
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            second_soh_process_user(user, date)
开发者ID:jmaina,项目名称:commcare-hq,代码行数:7,代码来源:reminders.py

示例9: handle

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,代码行数:59,代码来源:handler.py

示例10: migration_task

def migration_task():
    for config in EWSGhanaConfig.get_all_steady_sync_configs():
        if config.enabled:
            endpoint = GhanaEndpoint.from_config(config)
            ews_bootstrap_domain(EWSApi(config.domain, endpoint))
            apis = (
                ('stock_transaction', sync_stock_transactions),
            )
            stock_data_task.delay(config.domain, endpoint, apis, config, EWS_FACILITIES)
开发者ID:aristide,项目名称:commcare-hq,代码行数:9,代码来源:tasks.py

示例11: ews_sync_stock_data

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,代码行数:9,代码来源:views.py

示例12: ews_stock_data_task

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,代码行数:10,代码来源:tasks.py

示例13: fix_users_with_more_than_one_phone_number

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,代码行数:12,代码来源:tasks.py

示例14: handle

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,代码行数:53,代码来源:handler.py

示例15: reminder_to_visit_website

def reminder_to_visit_website():
    domains = EWSGhanaConfig.get_all_enabled_domains()
    for domain in domains:
        for user in CommCareUser.by_domain(domain):
            thirteen_days_ago = datetime.datetime.utcnow() - datetime.timedelta(weeks=13)
            if user.location and user.last_login < thirteen_days_ago and user.get_verified_number()\
                    and user.location.location_type.name in ['district', 'region', 'country']:
                    message = WEB_REMINDER % user.name
                    verified_number = user.get_verified_number()
                    send_sms_to_verified_number(verified_number, message)
                    if can_receive_email(user, verified_number):
                        email = str(user.email)
                        send_mail('REMINDER TO VISIT WEBSITE', message, '[email protected]', [email])
开发者ID:LifeCoaching,项目名称:commcare-hq,代码行数:13,代码来源:alerts.py


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