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


Python Program.save方法代码示例

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


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

示例1: make_program

# 需要导入模块: from corehq.apps.commtrack.models import Program [as 别名]
# 或者: from corehq.apps.commtrack.models.Program import save [as 别名]
def make_program(domain, name, code):
    p = Program()
    p.domain = domain
    p.name = name
    p.code = code.lower()
    p.save()
    return p
开发者ID:hashimoto-hb,项目名称:commcare-hq,代码行数:9,代码来源:util.py

示例2: make_program

# 需要导入模块: from corehq.apps.commtrack.models import Program [as 别名]
# 或者: from corehq.apps.commtrack.models.Program import save [as 别名]
def make_program(domain, name, code, default=False):
    p = Program()
    p.domain = domain
    p.name = name
    p.code = code.lower()
    p.default = default
    p.save()
    return p
开发者ID:kamilk161,项目名称:commcare-hq,代码行数:10,代码来源:util.py

示例3: SignalsTest

# 需要导入模块: from corehq.apps.commtrack.models import Program [as 别名]
# 或者: from corehq.apps.commtrack.models.Program import save [as 别名]
class SignalsTest(OpenLMISTestBase):
    requisitions_enabled = True
    program = None

    def createProgram(self):
        self.program = Program()
        self.program.domain = TEST_DOMAIN
        self.program.code = 'QYZ'
        self.program.name = "hiv_program"

        self.program.save()

    def createProducts(self):
        with open(os.path.join(self.datapath, 'sample_product_1.json')) as f:
            lmis_product_1 = json.loads(f.read())

        with open(os.path.join(self.datapath, 'sample_product_2.json')) as f:
            lmis_product_2 = json.loads(f.read())

        lmis_product_1['program_id'] =  self.program._id
        lmis_product_2['program_id'] =  self.program._id

        product_1 = Product(lmis_product_1)
        product_2 = Product(lmis_product_2)
        product_1.save()
        product_2.save()

        self.products = []
        self.products.append(product_1)
        self.products.append(product_2)

    def setUp(self):
        super(SignalsTest, self).setUp()
        self.datapath = os.path.join(os.path.dirname(__file__), 'data')
        self.spps.clear()
        self.createProgram()
        self.createProducts()

    def fixmetestSyncStockRequisition(self):
        from corehq.apps.commtrack.stockreport import Requisition
        requisition_cases = []
        config = self.domain.commtrack_settings
        for spp in self.spps.values():
            transaction = Requisition(
                config=config,
                product_id=spp.product,
                case_id=spp._id,
                action_name=config.get_action_by_type(RequisitionActions.REQUEST).action_name,
                value=20,
            )
            req = create_requisition(self.user._id, spp, transaction)
            requisition_cases.append(req)
        endpoint = MockOpenLMISSubmitEndpoint("uri://mock/lmis/endpoint", username='ned', password='honor')
        stock_data_submission(sender=None, cases=requisition_cases, endpoint=endpoint)

        for req in requisition_cases:
            self.assertEqual(req.external_id, 'REQ_123')
开发者ID:NoahCarnahan,项目名称:commcare-hq,代码行数:59,代码来源:test_signals.py

示例4: sync_openlmis_program

# 需要导入模块: from corehq.apps.commtrack.models import Program [as 别名]
# 或者: from corehq.apps.commtrack.models.Program import save [as 别名]
def sync_openlmis_program(domain, lmis_program):
    program = get_program(domain, lmis_program)
    if program is None:
        program = Program(domain=domain)

    program.name = lmis_program.name
    program.code = lmis_program.code.lower()
    program._doc_type_attr = "Program"
    program.save()
    if lmis_program.products:
        for lmis_product in lmis_program.products:
            sync_openlmis_product(domain, program, lmis_product)
    return program
开发者ID:SEL-Columbia,项目名称:commcare-hq,代码行数:15,代码来源:commtrack.py

示例5: sync_openlmis_program

# 需要导入模块: from corehq.apps.commtrack.models import Program [as 别名]
# 或者: from corehq.apps.commtrack.models.Program import save [as 别名]
def sync_openlmis_program(domain, lmis_program):
    program = get_program(domain, lmis_program)
    if program is None:
        program = Program(domain=domain)
    else:
        # currently impossible
        raise NotImplementedError('updating existing programs is not yet supported')
    program.name = lmis_program.name
    program.code = lmis_program.code
    program.save()
    if lmis_program.products:
        for lmis_product in lmis_program.products:
            sync_openlmis_product(domain, program, lmis_product)
    return program
开发者ID:rigambhir,项目名称:commcare-hq,代码行数:16,代码来源:commtrack.py


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