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


Python CommCareCaseAction.wrap方法代码示例

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


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

示例1: allocated_to

# 需要导入模块: from casexml.apps.case.models import CommCareCaseAction [as 别名]
# 或者: from casexml.apps.case.models.CommCareCaseAction import wrap [as 别名]
    def allocated_to(self):
        if self.status == "Closed":
            close_action = [CommCareCaseAction.wrap(a) for a in self.case['actions'] if a['action_type'] ==
                const.CASE_ACTION_CLOSE][0]

            CATI_FOLLOW_UP_FORMS = (
                "http://openrosa.org/formdesigner/A5B08D8F-139D-46C6-9FDF-B1AD176EAE1F",
            )
            if close_action.xform.xmlns in CATI_FOLLOW_UP_FORMS:
                return 'CATI'
            else:
                return 'Field'

        else:
            follow_up_type = self.case.get('follow_up_type', '')
            house_number = self.case.get('phone_house_number', '')
            husband_number = self.case.get('phone_husband_number', '')
            mother_number = self.case.get('phone_mother_number', '')
            asha_number = self.case.get('phone_asha_number', '')

            if follow_up_type != 'field_follow_up' and (house_number or
                   husband_number or mother_number or asha_number):
                return 'CATI'
            else:
                return 'Field'
开发者ID:tsinkala,项目名称:hsph-reports,代码行数:27,代码来源:call_center.py

示例2: testActionEquality

# 需要导入模块: from casexml.apps.case.models import CommCareCaseAction [as 别名]
# 或者: from casexml.apps.case.models.CommCareCaseAction import wrap [as 别名]
    def testActionEquality(self):
        case_id = _post_util(create=True)
        _post_util(case_id=case_id, p1='p1', p2='p2')

        case = CommCareCase.get(case_id)
        self.assertEqual(2, len(case.actions)) # create + update
        self.assertTrue(case.actions[0] != case.actions[1])
        self.assertTrue(case.actions[1] == case.actions[1])

        orig = case.actions[1]
        copy = CommCareCaseAction.wrap(orig._doc.copy())
        self.assertTrue(copy != case.actions[0])
        self.assertTrue(copy == orig)

        copy.server_date = copy.server_date + timedelta(seconds=1)
        self.assertTrue(copy != orig)
        copy.server_date = orig.server_date
        self.assertTrue(copy == orig)

        copy.updated_unknown_properties['p1'] = 'not-p1'
        self.assertTrue(copy != orig)
        copy.updated_unknown_properties['p1'] = 'p1'
        self.assertTrue(copy == orig)
        copy.updated_unknown_properties['pnew'] = ''
        self.assertTrue(copy != orig)
开发者ID:johan--,项目名称:commcare-hq,代码行数:27,代码来源:test_rebuild.py

示例3: test_couch_action_equality

# 需要导入模块: from casexml.apps.case.models import CommCareCaseAction [as 别名]
# 或者: from casexml.apps.case.models.CommCareCaseAction import wrap [as 别名]
    def test_couch_action_equality(self):
        case_id = _post_util(create=True)
        _post_util(case_id=case_id, p1='p1', p2='p2')

        case = CommCareCase.get(case_id)
        self.assertEqual(3, len(case.actions))  # (1) create & (2) update date opened (3) update properties
        self.assertTrue(case.actions[0] != case.actions[1])
        self.assertTrue(case.actions[1] == case.actions[1])

        orig = case.actions[2]
        copy = CommCareCaseAction.wrap(deepcopy(orig._doc))
        self.assertTrue(copy != case.actions[0])
        self.assertTrue(copy == orig)

        copy.server_date = copy.server_date + timedelta(seconds=1)
        self.assertTrue(copy != orig)
        copy.server_date = orig.server_date
        self.assertTrue(copy == orig)

        copy.updated_unknown_properties['p1'] = 'not-p1'
        self.assertTrue(copy != orig)
        copy.updated_unknown_properties['p1'] = 'p1'
        self.assertTrue(copy == orig)
        copy.updated_unknown_properties['pnew'] = ''
        self.assertTrue(copy != orig)
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:27,代码来源:test_rebuild.py

示例4: creating_user

# 需要导入模块: from casexml.apps.case.models import CommCareCaseAction [as 别名]
# 或者: from casexml.apps.case.models.CommCareCaseAction import wrap [as 别名]
 def creating_user(self):
     creator_id = None
     for action in self.case['actions']:
         if action['action_type'] == 'create':
             action_doc = CommCareCaseAction.wrap(action)
             creator_id = action_doc.get_user_id()
             break
     if not creator_id:
         return None
     return self._user_meta(creator_id)
开发者ID:nnestle,项目名称:commcare-hq,代码行数:12,代码来源:data_sources.py

示例5: creating_user

# 需要导入模块: from casexml.apps.case.models import CommCareCaseAction [as 别名]
# 或者: from casexml.apps.case.models.CommCareCaseAction import wrap [as 别名]
    def creating_user(self):
        try:
            creator_id = self.case['opened_by']
        except KeyError:
            creator_id = None
            if 'actions' in self.case:
                for action in self.case['actions']:
                    if action['action_type'] == 'create':
                        action_doc = CommCareCaseAction.wrap(action)
                        creator_id = action_doc.get_user_id()
                        break

        if not creator_id:
            return None
        return self._user_meta(creator_id)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:17,代码来源:data_sources.py

示例6: prepare_case_json

# 需要导入模块: from casexml.apps.case.models import CommCareCaseAction [as 别名]
# 或者: from casexml.apps.case.models.CommCareCaseAction import wrap [as 别名]
def prepare_case_json(planning_db):
    case_ids = planning_db.get_all_case_ids(valid_only=False)
    for case_json in iter_docs(CommCareCase.get_db(), case_ids):
        case = CommCareCase.wrap(case_json)
        if case.doc_type != "CommCareCase":
            assert case.doc_type == "CommCareCase-Deleted"
            continue

        # to normalize for any new fields added
        case_json = deepcopy(case.to_json())
        actions = [CommCareCaseAction.wrap(action) for action in planning_db.get_actions_by_case(case.case_id)]
        rebuild_case_from_actions(case, actions)
        planning_db.update_case_json(case.case_id, case.to_json())
        planning_db.add_diffs("case", case.case_id, json_diff(case_json, case.to_json()))

    return planning_db
开发者ID:philipkaare,项目名称:commcare-hq,代码行数:18,代码来源:timezonemigration.py

示例7: test_couch_action_not_equals

# 需要导入模块: from casexml.apps.case.models import CommCareCaseAction [as 别名]
# 或者: from casexml.apps.case.models.CommCareCaseAction import wrap [as 别名]
 def test_couch_action_not_equals(self):
     orig = CommCareCaseAction()
     copy = CommCareCaseAction.wrap(deepcopy(orig._doc))
     self.assertTrue(orig == copy)
     self.assertFalse(orig != copy)
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:7,代码来源:test_rebuild.py


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