當前位置: 首頁>>代碼示例>>Python>>正文


Python CommCareCaseGroup.get_db方法代碼示例

本文整理匯總了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."
開發者ID:puttarajubr,項目名稱:commcare-hq,代碼行數:30,代碼來源:migrate_surveysample_group_2013_09.py

示例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
開發者ID:puttarajubr,項目名稱:commcare-hq,代碼行數:10,代碼來源:dbaccessors.py

示例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)
開發者ID:ansarbek,項目名稱:commcare-hq,代碼行數:23,代碼來源:tests.py

示例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)
開發者ID:ansarbek,項目名稱:commcare-hq,代碼行數:5,代碼來源:tests.py


注:本文中的corehq.apps.casegroups.models.CommCareCaseGroup.get_db方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。