本文整理汇总了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
示例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
示例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')
示例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
示例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