当前位置: 首页>>代码示例>>Python>>正文


Python models.StaticReportConfiguration类代码示例

本文整理汇总了Python中corehq.apps.userreports.models.StaticReportConfiguration的典型用法代码示例。如果您正苦于以下问题:Python StaticReportConfiguration类的具体用法?Python StaticReportConfiguration怎么用?Python StaticReportConfiguration使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了StaticReportConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: copy_ucr_reports

    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
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:32,代码来源:clone_domain.py

示例2: get_static_report_mapping

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
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:30,代码来源:util.py

示例3: _get_report_module_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,
        }

    all_reports = ReportConfiguration.by_domain(app.domain) + \
                  StaticReportConfiguration.by_domain(app.domain)
    warnings = []
    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
        warnings.append(
            gettext_lazy('Your app contains references to reports that are '
                         'deleted. These will be removed on save.')
        )

    return {
        'all_reports': [_report_to_config(r) for r in all_reports],
        'current_reports': [r.to_json() for r in module.report_configs],
        'warnings': warnings,
    }
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:30,代码来源:modules.py

示例4: _get_static_report_configuration_without_owner_transform

 def _get_static_report_configuration_without_owner_transform(self, report_id, domain):
     static_report_configuration = StaticReportConfiguration.by_id(report_id, domain)
     for report_column in static_report_configuration.report_columns:
         transform = report_column.transform
         if transform.get('type') == 'custom' and transform.get('custom_type') == 'owner_display':
             report_column.transform = {}
     return static_report_configuration
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:7,代码来源:__init__.py

示例5: _get_configurable_reports

def _get_configurable_reports(project):
    """
    User configurable reports
    """
    configs = ReportConfiguration.by_domain(project.name) + StaticReportConfiguration.by_domain(project.name)
    if configs:
        def _make_report_class(config):
            from corehq.apps.reports.generic import GenericReportView

            # this is really annoying.
            # the report metadata should really be pulled outside of the report classes
            @classmethod
            def get_url(cls, domain, **kwargs):
                from corehq.apps.userreports.models import CUSTOM_REPORT_PREFIX
                slug = (
                    ConfigurableReport.slug
                    if not config._id.startswith(CUSTOM_REPORT_PREFIX)
                    else CustomConfigurableReportDispatcher.slug
                )
                return reverse(slug, args=[domain, config._id])

            @classmethod
            def show_in_navigation(cls, domain=None, project=None, user=None):
                return config.visible or (user and toggles.USER_CONFIGURABLE_REPORTS.enabled(user.username))

            return type('DynamicReport{}'.format(config._id), (GenericReportView, ), {
                'name': config.title,
                'description': config.description or None,
                'get_url': get_url,
                'show_in_navigation': show_in_navigation,
            })

        yield (_('Reports'), [_make_report_class(config) for config in configs])
开发者ID:johan--,项目名称:commcare-hq,代码行数:33,代码来源:reports.py

示例6: test_for_report_id_conflicts

 def test_for_report_id_conflicts(self):
     counts = Counter(rc.get_id for rc in
                      StaticReportConfiguration.all())
     duplicates = [k for k, v in counts.items() if v > 1]
     msg = "The following report configs have duplicate generated report_ids:\n{}".format(
         "\n".join("report_id: {}".format(report_id) for report_id in duplicates)
     )
     self.assertEqual(0, len(duplicates), msg)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:8,代码来源:test_static_reports.py

示例7: _shared_context

def _shared_context(domain):
    static_reports = list(StaticReportConfiguration.by_domain(domain))
    static_data_sources = list(StaticDataSourceConfiguration.by_domain(domain))
    return {
        'domain': domain,
        'reports': ReportConfiguration.by_domain(domain) + static_reports,
        'data_sources': DataSourceConfiguration.by_domain(domain) + static_data_sources,
    }
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:8,代码来源:views.py

示例8: test_get_all

 def test_get_all(self):
     with override_settings(STATIC_UCR_REPORTS=[self.get_path('static_report_config', 'json')]):
         all = list(StaticReportConfiguration.all())
         self.assertEqual(2, len(all))
         example, dimagi = all
         self.assertEqual('example', example.domain)
         self.assertEqual('dimagi', dimagi.domain)
         for config in all:
             self.assertEqual('Custom Title', config.title)
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:9,代码来源:test_static_reports.py

示例9: main_context

 def main_context(self):
     static_reports = list(StaticReportConfiguration.by_domain(self.domain))
     static_data_sources = list(StaticDataSourceConfiguration.by_domain(self.domain))
     context = super(BaseUserConfigReportsView, self).main_context
     context.update({
         'reports': ReportConfiguration.by_domain(self.domain) + static_reports,
         'data_sources': DataSourceConfiguration.by_domain(self.domain) + static_data_sources,
     })
     return context
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:9,代码来源:views.py

示例10: test_static_reports

    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)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:19,代码来源:test_get_report_configs.py

示例11: clean_columns

def clean_columns(json_spec):
    static_config = StaticReportConfiguration.wrap(deepcopy(json_spec))
    report_config = ReportConfiguration.wrap(static_config.config)
    cleaned_columns = []
    for col_spec, wrapped_col in zip(json_spec['config']['columns'],
                                     report_config.report_columns):
        print("Checking column '{}'".format(col_spec['column_id']))
        new_col_spec = clean_spec(col_spec, wrapped_col)
        cleaned_columns.append(order_dict(new_col_spec, COLUMN_PARAMS_ORDER))
    return cleaned_columns
开发者ID:dimagi,项目名称:commcare-hq,代码行数:10,代码来源:clean_report_config.py

示例12: _get_report_module_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
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:55,代码来源:modules.py

示例13: _get_report_configuration

 def _get_report_configuration(self, id_, domain):
     """
     Fetch the required ReportConfiguration object
     :param id_: The id of the ReportConfiguration
     :param domain: The domain of the ReportConfiguration
     :return: A ReportConfiguration
     """
     try:
         if report_config_id_is_static(id_):
             return StaticReportConfiguration.by_id(id_, domain=domain)
         else:
             return get_document_or_not_found(ReportConfiguration, domain, id_)
     except DocumentNotFound:
         raise NotFound
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:14,代码来源:v0_5.py

示例14: test_data_sources_actually_exist

    def test_data_sources_actually_exist(self):

        data_sources_on_domain = defaultdict(set)
        for data_source in StaticDataSourceConfiguration.all():
            data_sources_on_domain[data_source.domain].add(data_source.get_id)

        def has_no_data_source(report_config):
            available_data_sources = data_sources_on_domain[report_config.domain]
            return report_config.config_id not in available_data_sources

        all_configs = StaticReportConfiguration.all()
        configs_missing_data_source = list(filter(has_no_data_source, all_configs))

        msg = ("There are {} report configs which reference data sources that "
               "don't exist (or which don't exist on that domain):\n{}".format(
                   len(configs_missing_data_source),
                   "\n".join(config.get_id for config in configs_missing_data_source)))
        self.assertEqual(0, len(configs_missing_data_source), msg)
开发者ID:dimagi,项目名称:commcare-hq,代码行数:18,代码来源:test_static_reports.py

示例15: handle

    def handle(self, **options):
        config_ids = get_doc_ids_by_class(ReportConfiguration)

        builder_count, ucr_count = 0, 0
        for doc in iter_docs(ReportConfiguration.get_db(), config_ids):
            if doc['report_meta']['created_by_builder']:
                builder_count += 1
            else:
                ucr_count += 1

        static_count = len(list(StaticReportConfiguration.all()))
        total_count = builder_count + ucr_count + static_count

        print(textwrap.dedent("""
            As of {}, on {} there are {} total UCRs:
            {} Report Builder Reports
            {} UCR Report Configs
            {} Static Report Configs enabled for the environment
        """.format(datetime.utcnow().date(), settings.SERVER_ENVIRONMENT, total_count,
                   builder_count, ucr_count, static_count)))
开发者ID:dimagi,项目名称:commcare-hq,代码行数:20,代码来源:count_ucrs.py


注:本文中的corehq.apps.userreports.models.StaticReportConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。