本文整理汇总了Python中corehq.apps.casegroups.models.CommCareCaseGroup.get_db方法的典型用法代码示例。如果您正苦于以下问题:Python CommCareCaseGroup.get_db方法的具体用法?Python CommCareCaseGroup.get_db怎么用?Python CommCareCaseGroup.get_db使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.casegroups.models.CommCareCaseGroup
的用法示例。
在下文中一共展示了CommCareCaseGroup.get_db方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handle
# 需要导入模块: from corehq.apps.casegroups.models import CommCareCaseGroup [as 别名]
# 或者: from corehq.apps.casegroups.models.CommCareCaseGroup import get_db [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."
示例2: get_number_of_case_groups_in_domain
# 需要导入模块: from corehq.apps.casegroups.models import CommCareCaseGroup [as 别名]
# 或者: from corehq.apps.casegroups.models.CommCareCaseGroup import get_db [as 别名]
def get_number_of_case_groups_in_domain(domain):
data = CommCareCaseGroup.get_db().view(
'casegroups/groups_by_domain',
startkey=[domain],
endkey=[domain, {}],
reduce=True
).first()
return data['value'] if data else 0
示例3: setUpClass
# 需要导入模块: from corehq.apps.casegroups.models import CommCareCaseGroup [as 别名]
# 或者: from corehq.apps.casegroups.models.CommCareCaseGroup import get_db [as 别名]
def setUpClass(cls):
cls.domain = 'skbanskdjoasdkng'
cls.cases = [
CommCareCase(name='A', domain=cls.domain),
CommCareCase(name='B', domain=cls.domain),
CommCareCase(name='C', domain=cls.domain),
CommCareCase(name='D', domain=cls.domain),
CommCareCase(name='X', domain='bunny'),
]
CommCareCase.get_db().bulk_save(cls.cases)
cls.case_groups = [
CommCareCaseGroup(name='alpha', domain=cls.domain,
cases=[cls.cases[0]._id, cls.cases[1]._id]),
CommCareCaseGroup(name='beta', domain=cls.domain,
cases=[cls.cases[2]._id, cls.cases[3]._id]),
CommCareCaseGroup(name='gamma', domain=cls.domain,
cases=[cls.cases[0]._id, cls.cases[3]._id]),
CommCareCaseGroup(name='delta', domain=cls.domain,
cases=[cls.cases[1]._id, cls.cases[2]._id]),
]
CommCareCaseGroup.get_db().bulk_save(cls.case_groups)
示例4: tearDownClass
# 需要导入模块: from corehq.apps.casegroups.models import CommCareCaseGroup [as 别名]
# 或者: from corehq.apps.casegroups.models.CommCareCaseGroup import get_db [as 别名]
def tearDownClass(cls):
CommCareCase.get_db().bulk_delete(cls.cases)
CommCareCaseGroup.get_db().bulk_delete(cls.case_groups)