本文整理汇总了Python中corehq.apps.userreports.models.StaticReportConfiguration.get_doc_id方法的典型用法代码示例。如果您正苦于以下问题:Python StaticReportConfiguration.get_doc_id方法的具体用法?Python StaticReportConfiguration.get_doc_id怎么用?Python StaticReportConfiguration.get_doc_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类corehq.apps.userreports.models.StaticReportConfiguration
的用法示例。
在下文中一共展示了StaticReportConfiguration.get_doc_id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copy_ucr_reports
# 需要导入模块: from corehq.apps.userreports.models import StaticReportConfiguration [as 别名]
# 或者: from corehq.apps.userreports.models.StaticReportConfiguration import get_doc_id [as 别名]
def copy_ucr_reports(self, datasource_map):
report_map = {}
reports = get_report_configs_for_domain(self.existing_domain)
for report in reports:
old_datasource_id = report.config_id
try:
report.config_id = datasource_map[old_datasource_id]
except KeyError:
pass # datasource not found
old_id, new_id = self.save_couch_copy(report, self.new_domain)
report_map[old_id] = new_id
for static_report in StaticReportConfiguration.by_domain(self.existing_domain):
if static_report.get_id.startswith(STATIC_PREFIX):
report_id = static_report.get_id.replace(
STATIC_PREFIX + self.existing_domain + '-',
''
)
is_custom_report = False
else:
report_id = static_report.get_id.replace(
CUSTOM_REPORT_PREFIX + self.existing_domain + '-',
''
)
is_custom_report = True
new_id = StaticReportConfiguration.get_doc_id(
self.new_domain, report_id, is_custom_report
)
# check that new report is in new domain's list of static reports
StaticReportConfiguration.by_id(new_id)
report_map[static_report.get_id] = new_id
return report_map
示例2: get_static_report_mapping
# 需要导入模块: from corehq.apps.userreports.models import StaticReportConfiguration [as 别名]
# 或者: from corehq.apps.userreports.models.StaticReportConfiguration import get_doc_id [as 别名]
def get_static_report_mapping(from_domain, to_domain):
from corehq.apps.userreports.models import StaticReportConfiguration, STATIC_PREFIX, \
CUSTOM_REPORT_PREFIX
report_map = {}
for static_report in StaticReportConfiguration.by_domain(from_domain):
if static_report.get_id.startswith(STATIC_PREFIX):
report_id = static_report.get_id.replace(
STATIC_PREFIX + from_domain + '-',
''
)
is_custom_report = False
else:
report_id = static_report.get_id.replace(
CUSTOM_REPORT_PREFIX + from_domain + '-',
''
)
is_custom_report = True
new_id = StaticReportConfiguration.get_doc_id(
to_domain, report_id, is_custom_report
)
# check that new report is in new domain's list of static reports
try:
StaticReportConfiguration.by_id(new_id, to_domain)
except (BadSpecError, DocumentNotFound):
pass
else:
report_map[static_report.get_id] = new_id
return report_map
示例3: test_static_reports
# 需要导入模块: from corehq.apps.userreports.models import StaticReportConfiguration [as 别名]
# 或者: from corehq.apps.userreports.models.StaticReportConfiguration import get_doc_id [as 别名]
def test_static_reports(self):
with override_settings(STATIC_UCR_REPORTS=[
self.get_path('static_report_config', 'json'),
self.get_path('static_report_2_config', 'json')
]):
reports = get_report_configs(
[StaticReportConfiguration.get_doc_id('example', 'a-custom-report', False)],
'example'
)
self.assertEqual(len(reports), 1)
reports = get_report_configs(
[
StaticReportConfiguration.get_doc_id('example', 'a-custom-report', False),
StaticReportConfiguration.get_doc_id('example', 'another-custom-report', False),
],
'example'
)
self.assertEqual(len(reports), 2)
示例4: test_mixed_reports
# 需要导入模块: from corehq.apps.userreports.models import StaticReportConfiguration [as 别名]
# 或者: from corehq.apps.userreports.models.StaticReportConfiguration import get_doc_id [as 别名]
def test_mixed_reports(self):
dynamic_report_id = uuid.uuid4().hex
dynamic_report = ReportConfiguration(
_id=dynamic_report_id,
domain='example',
config_id=uuid.uuid4().hex
)
def get_docs_mock(db, ids):
if ids == [dynamic_report_id]:
return [dynamic_report.to_json()]
return []
with patch('corehq.apps.userreports.models.get_docs', new=get_docs_mock):
with override_settings(STATIC_UCR_REPORTS=[self.get_path('static_report_config', 'json')]):
configs = get_report_configs(
[dynamic_report_id, StaticReportConfiguration.get_doc_id('example', 'a-custom-report', False)],
'example'
)
self.assertEqual(len(configs), 2)