当前位置: 首页>>代码示例>>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;未经允许,请勿转载。