def _commcare_reports_instances(app, instance_name, prefix): from corehq.apps.app_manager.suite_xml.features.mobile_ucr import get_uuids_by_instance_id if instance_name.startswith(prefix) and toggles.MOBILE_UCR.enabled( app.domain): instance_id = instance_name[len(prefix):] uuid = get_uuids_by_instance_id(app).get(instance_id, [instance_id])[0] return Instance(id=instance_name, src='jr://fixture/{}{}'.format(prefix, uuid))
def _has_duplicate_instance_ids(self): from corehq.apps.app_manager.suite_xml.features.mobile_ucr import get_uuids_by_instance_id duplicate_instance_ids = { instance_id for instance_id, uuids in get_uuids_by_instance_id(self.module.get_app()).items() if len(uuids) > 1 } return any(report_config.instance_id in duplicate_instance_ids for report_config in self.module.report_configs)
def _has_duplicate_instance_ids(self): from corehq.apps.app_manager.suite_xml.features.mobile_ucr import get_uuids_by_instance_id duplicate_instance_ids = { instance_id for instance_id, uuids in get_uuids_by_instance_id(self.module.get_app().domain).items() if len(uuids) > 1 } return any(report_config.instance_id in duplicate_instance_ids for report_config in self.module.report_configs)
def _get_report_module_context(app, module): def _report_to_config(report): return { 'report_id': report._id, 'title': report.title, 'description': report.description, 'charts': [chart for chart in report.charts if chart.type == 'multibar'], 'filter_structure': report.filters_without_prefilters, } all_reports = ReportConfiguration.by_domain(app.domain) + \ StaticReportConfiguration.by_domain(app.domain) validity = module.check_report_validity() # We're now proactively deleting these references, so after that's been # out for a while, this can be removed (say June 2016 or later) if not validity.is_valid: module.report_configs = validity.valid_report_configs filter_choices = [ {'slug': f.doc_type, 'description': f.short_description} for f in get_all_mobile_filter_configs() ] auto_filter_choices = [ {'slug': f.slug, 'description': f.short_description} for f in get_auto_filter_configurations() ] from corehq.apps.app_manager.suite_xml.features.mobile_ucr import get_column_xpath_client_template, get_data_path data_path_placeholders = {} for r in module.report_configs: data_path_placeholders[r.report_id] = {} for chart_id in r.complete_graph_configs.keys(): data_path_placeholders[r.report_id][chart_id] = get_data_path(r, app.domain) context = { 'report_module_options': { 'moduleName': module.name, 'moduleFilter': module.module_filter, 'availableReports': [_report_to_config(r) for r in all_reports], # structure for all reports 'currentReports': [r.to_json() for r in module.report_configs], # config data for app reports 'columnXpathTemplate': get_column_xpath_client_template(app.mobile_ucr_restore_version), 'dataPathPlaceholders': data_path_placeholders, 'languages': app.langs, 'mobileUcrV1': app.mobile_ucr_restore_version == MOBILE_UCR_VERSION_1, 'globalSyncDelay': Domain.get_by_name(app.domain).default_mobile_ucr_sync_interval, }, 'static_data_options': { 'filterChoices': filter_choices, 'autoFilterChoices': auto_filter_choices, 'dateRangeOptions': [choice._asdict() for choice in get_simple_dateranges()], }, 'uuids_by_instance_id': get_uuids_by_instance_id(app.domain), 'legacy_select2': True, } return context
def _get_report_module_context(app, module): def _report_to_config(report): return { 'report_id': report._id, 'title': report.title, 'description': report.description, 'charts': [chart for chart in report.charts if chart.type == 'multibar'], 'filter_structure': report.filters_without_prefilters, } all_reports = ReportConfiguration.by_domain(app.domain) + \ StaticReportConfiguration.by_domain(app.domain) validity = module.check_report_validity() # We're now proactively deleting these references, so after that's been # out for a while, this can be removed (say June 2016 or later) if not validity.is_valid: module.report_configs = validity.valid_report_configs filter_choices = [{ 'slug': f.doc_type, 'description': f.short_description } for f in get_all_mobile_filter_configs()] auto_filter_choices = [{ 'slug': f.slug, 'description': f.short_description } for f in get_auto_filter_configurations()] from corehq.apps.app_manager.suite_xml.features.mobile_ucr import get_column_xpath_client_template, get_data_path data_path_placeholders = {} for r in module.report_configs: data_path_placeholders[r.report_id] = {} for chart_id in r.complete_graph_configs.keys(): data_path_placeholders[r.report_id][chart_id] = get_data_path( r, app.domain) context = { 'report_module_options': { 'moduleName': module.name, 'moduleFilter': module.module_filter, 'availableReports': [_report_to_config(r) for r in all_reports], # structure for all reports 'currentReports': [r.to_json() for r in module.report_configs ], # config data for app reports 'columnXpathTemplate': get_column_xpath_client_template(app.mobile_ucr_restore_version), 'dataPathPlaceholders': data_path_placeholders, 'languages': app.langs, 'mobileUcrV1': app.mobile_ucr_restore_version == MOBILE_UCR_VERSION_1, 'globalSyncDelay': Domain.get_by_name(app.domain).default_mobile_ucr_sync_interval, }, 'static_data_options': { 'filterChoices': filter_choices, 'autoFilterChoices': auto_filter_choices, 'dateRangeOptions': [choice._asdict() for choice in get_simple_dateranges()], }, 'uuids_by_instance_id': get_uuids_by_instance_id(app.domain), 'legacy_select2': True, } return context
def _commcare_reports_instances(domain, instance_name, prefix): from corehq.apps.app_manager.suite_xml.features.mobile_ucr import get_uuids_by_instance_id if instance_name.startswith(prefix) and toggles.MOBILE_UCR.enabled(domain): instance_id = instance_name[len(prefix):] uuid = get_uuids_by_instance_id(domain).get(instance_id, [instance_id])[0] return Instance(id=instance_name, src='jr://fixture/{}{}'.format(prefix, uuid))