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


Python VerifiedNumber.phone_number方法代码示例

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


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

示例1: _test_cache_clear

# 需要导入模块: from corehq.apps.sms.mixin import VerifiedNumber [as 别名]
# 或者: from corehq.apps.sms.mixin.VerifiedNumber import phone_number [as 别名]
    def _test_cache_clear(self, refresh_each_time=True):
        """
        A test to make sure that the cache clearing is working as expected.
        This test gets run twice using different values for refresh_each_time.
        This makes sure that the mechanism used for clearing the cache works
        whether you're updating a document you just saved or getting a document
        fresh from the database and updating it.
        """
        created = VerifiedNumber(
            domain='phone-number-test',
            owner_doc_type='CommCareCase',
            owner_id='fake-owner-id1',
            phone_number='99912341234',
            backend_id=None,
            ivr_backend_id=None,
            verified=True,
            contact_last_modified=datetime.utcnow()
        )
        created.save()
        self.assertTrue(created._rev.startswith('1-'))
        self.assertNoMatch('99952345234', '52345234', 'fake-owner-id2')
        self.assertMatch(created, '99912341234', '12341234', 'fake-owner-id1')

        # Update Phone Number
        if refresh_each_time:
            created = VerifiedNumber.get(created._id)
        created.phone_number = '99952345234'
        created.save()
        self.assertTrue(created._rev.startswith('2-'))
        self.assertNoMatch('99912341234', '12341234', 'fake-owner-id2')
        self.assertMatch(created, '99952345234', '52345234', 'fake-owner-id1')

        # Update Owner Id
        if refresh_each_time:
            created = VerifiedNumber.get(created._id)
        created.owner_id = 'fake-owner-id2'
        created.save()
        self.assertTrue(created._rev.startswith('3-'))
        self.assertNoMatch('99912341234', '12341234', 'fake-owner-id1')
        self.assertMatch(created, '99952345234', '52345234', 'fake-owner-id2')

        created.delete()
        self.assertNoMatch('99952345234', '52345234', 'fake-owner-id2')
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:45,代码来源:test_phone_numbers.py

示例2: _sync_case_phone_number

# 需要导入模块: from corehq.apps.sms.mixin import VerifiedNumber [as 别名]
# 或者: from corehq.apps.sms.mixin.VerifiedNumber import phone_number [as 别名]
def _sync_case_phone_number(contact_case):
    phone_info = contact_case.get_phone_info()

    lock_keys = ['sync-case-phone-number-for-%s' % contact_case._id]
    if phone_info.phone_number:
        lock_keys.append('verifying-phone-number-%s' % phone_info.phone_number)

    with CriticalSection(lock_keys):
        phone_number = contact_case.get_verified_number()
        if (
            phone_number and
            phone_number.contact_last_modified and
            phone_number.contact_last_modified >= contact_case.server_modified_on
        ):
            return

        if phone_info.requires_entry:
            try:
                contact_case.verify_unique_number(phone_info.phone_number)
            except (InvalidFormatException, PhoneNumberInUseException):
                if phone_number:
                    phone_number.delete()
                return

            if not phone_number:
                phone_number = VerifiedNumber(
                    domain=contact_case.domain,
                    owner_doc_type=contact_case.doc_type,
                    owner_id=contact_case._id,
                )
            elif _phone_number_is_same(phone_number, phone_info):
                return

            phone_number.phone_number = phone_info.phone_number
            phone_number.backend_id = phone_info.sms_backend_id
            phone_number.ivr_backend_id = phone_info.ivr_backend_id
            phone_number.verified = True
            phone_number.contact_last_modified = contact_case.server_modified_on
            phone_number.save()
        else:
            if phone_number:
                phone_number.delete()
开发者ID:tlwakwella,项目名称:commcare-hq,代码行数:44,代码来源:tasks.py


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