本文整理匯總了Python中corehq.apps.casegroups.models.CommCareCaseGroup.wrap方法的典型用法代碼示例。如果您正苦於以下問題:Python CommCareCaseGroup.wrap方法的具體用法?Python CommCareCaseGroup.wrap怎麽用?Python CommCareCaseGroup.wrap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類corehq.apps.casegroups.models.CommCareCaseGroup
的用法示例。
在下文中一共展示了CommCareCaseGroup.wrap方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: handle
# 需要導入模塊: from corehq.apps.casegroups.models import CommCareCaseGroup [as 別名]
# 或者: from corehq.apps.casegroups.models.CommCareCaseGroup import wrap [as 別名]
def handle(self, *labels, **options):
existing_samples = CommCareCaseGroup.get_db().view(
'reminders/sample_by_domain',
startkey=[],
endkey=[{}],
include_docs=True
).all()
print "Found %d SurveySamples to migrate..." % len(existing_samples)
print "Migrating"
for sample in existing_samples:
try:
sample_doc = sample["doc"]
sample_doc["timezone"] = sample_doc.get("time_zone")
del sample_doc["time_zone"]
sample_doc["cases"] = sample_doc.get("contacts", [])
del sample_doc["contacts"]
sample_doc["doc_type"] = CommCareCaseGroup.__name__
case_group = CommCareCaseGroup.wrap(sample_doc)
case_group.save()
sys.stdout.write('.')
except Exception:
sys.stdout.write('!')
sys.stdout.flush()
print "\nMigration complete."