本文整理汇总了Python中corehq.form_processor.interfaces.processor.FormProcessorInterface.mark_changed方法的典型用法代码示例。如果您正苦于以下问题:Python FormProcessorInterface.mark_changed方法的具体用法?Python FormProcessorInterface.mark_changed怎么用?Python FormProcessorInterface.mark_changed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.form_processor.interfaces.processor.FormProcessorInterface
的用法示例。
在下文中一共展示了FormProcessorInterface.mark_changed方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_stock
# 需要导入模块: from corehq.form_processor.interfaces.processor import FormProcessorInterface [as 别名]
# 或者: from corehq.form_processor.interfaces.processor.FormProcessorInterface import mark_changed [as 别名]
def process_stock(xforms, case_db=None):
"""
process the commtrack xml constructs in an incoming submission
"""
if not case_db:
case_db = FormProcessorInterface(xforms[0].domain).casedb_cache()
else:
assert isinstance(case_db, AbstractCaseDbCache)
sorted_forms = sorted(xforms, key=lambda f: 0 if f.is_deprecated else 1)
stock_report_helpers = []
case_action_intents = []
for xform in sorted_forms:
actions_for_form = get_stock_actions(xform)
stock_report_helpers += actions_for_form.stock_report_helpers
case_action_intents += actions_for_form.case_action_intents
# omitted: normalize_transactions (used for bulk requisitions?)
# validate the parsed transactions
for stock_report_helper in stock_report_helpers:
stock_report_helper.validate()
relevant_cases = []
# touch every case for proper ota restore logic syncing to be preserved
for action_intent in case_action_intents:
case_id = action_intent.case_id
case = case_db.get(action_intent.case_id)
relevant_cases.append(case)
if case is None:
raise IllegalCaseId(
_('Ledger transaction references invalid Case ID "{}"')
.format(case_id))
if action_intent.is_deprecation:
# just remove the old stock actions for the form from the case
case.actions = [
a for a in case.actions if not
(a.xform_id == action_intent.form_id and a.action_type == CASE_ACTION_COMMTRACK)
]
else:
case_action = action_intent.action
# hack: clear the sync log id so this modification always counts
# since consumption data could change server-side
case_action.sync_log_id = ''
case.actions.append(case_action)
if action_intent.form_id not in case.xform_ids:
case.xform_ids.append(action_intent.form_id)
case_db.mark_changed(case)
return StockProcessingResult(
xform=sorted_forms[-1],
relevant_cases=relevant_cases,
stock_report_helpers=stock_report_helpers,
)