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


Python RequisitionCase.get_by_external_id方法代码示例

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


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

示例1: sync_requisition_from_openlmis

# 需要导入模块: from corehq.apps.commtrack.models import RequisitionCase [as 别名]
# 或者: from corehq.apps.commtrack.models.RequisitionCase import get_by_external_id [as 别名]
def sync_requisition_from_openlmis(domain, requisition_id, openlmis_endpoint):
    cases = []
    send_notification = False
    lmis_requisition_details = openlmis_endpoint.get_requisition_details(requisition_id)
    if lmis_requisition_details:
        rec_cases = [c for c in RequisitionCase.get_by_external_id(domain, str(lmis_requisition_details.id)) if c.type == const.REQUISITION_CASE_TYPE]

        if len(rec_cases) == 0:
            products = [product for product in lmis_requisition_details.products if product.skipped == False]
            for product in products:
                pdt = Product.get_by_code(domain, product.code.lower())
                if pdt:
                    case = lmis_requisition_details.to_requisition_case(pdt._id)
                    case.save()
                    if case.requisition_status == 'AUTHORIZED':
                        send_notification = True
                    cases.append(case)
        else:
            for case in rec_cases:
                before_status = case.requisition_status
                if apply_updates(case, lmis_requisition_details.to_dict(case.product_id)):
                    after_status = case.requisition_status
                    case.save()
                    if before_status in ['INITIATED', 'SUBMITTED'] and after_status == 'AUTHORIZED':
                        send_notification = True
                cases.append(case)
        return cases, send_notification
    else:
        return None, False
开发者ID:SEL-Columbia,项目名称:commcare-hq,代码行数:31,代码来源:commtrack.py

示例2: sync_requisition_from_openlmis

# 需要导入模块: from corehq.apps.commtrack.models import RequisitionCase [as 别名]
# 或者: from corehq.apps.commtrack.models.RequisitionCase import get_by_external_id [as 别名]
def sync_requisition_from_openlmis(domain, requisition_id, openlmis_endpoint):
    cases = []
    send_notification = False
    lmis_requisition_details = openlmis_endpoint.get_requisition_details(requisition_id)
    rec_cases = [RequisitionCase.wrap(c._doc) for c in RequisitionCase.get_by_external_id(domain, lmis_requisition_details.id) if c.type == const.REQUISITION_CASE_TYPE]
    if rec_cases is None:
        for product in lmis_requisition_details.products:
            pdt = Product.get_by_code(domain, product.code)
            case = lmis_requisition_details.to_requisition_case(pdt._id)
            case.save()
            if case.requisition_status is 'AUTHORIZED':
                send_notification = True
            cases.append(case)
    else:
        for case in rec_cases:
            before_status = case.requisition_status
            if _apply_updates(case, lmis_requisition_details.to_requisition_case(case.product_id)):
                after_status = case.requisition_status
                case.save()
                if before_status in ['INITIATED', 'SUBMITTED'] and after_status is 'AUTHORIZED':
                    send_notification = True
            cases.append(case)
    return cases, send_notification
开发者ID:rigambhir,项目名称:commcare-hq,代码行数:25,代码来源:commtrack.py


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