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


Python StaticReportConfiguration.by_domain方法代码示例

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


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

示例1: _get_report_module_context

# 需要导入模块: from corehq.apps.userreports.models import StaticReportConfiguration [as 别名]
# 或者: from corehq.apps.userreports.models.StaticReportConfiguration import by_domain [as 别名]
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,代码行数:32,代码来源:modules.py

示例2: _get_configurable_reports

# 需要导入模块: from corehq.apps.userreports.models import StaticReportConfiguration [as 别名]
# 或者: from corehq.apps.userreports.models.StaticReportConfiguration import by_domain [as 别名]
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,代码行数:35,代码来源:reports.py

示例3: copy_ucr_reports

# 需要导入模块: from corehq.apps.userreports.models import StaticReportConfiguration [as 别名]
# 或者: from corehq.apps.userreports.models.StaticReportConfiguration import by_domain [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
开发者ID:saketkanth,项目名称:commcare-hq,代码行数:34,代码来源:clone_domain.py

示例4: get_static_report_mapping

# 需要导入模块: from corehq.apps.userreports.models import StaticReportConfiguration [as 别名]
# 或者: from corehq.apps.userreports.models.StaticReportConfiguration import by_domain [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
开发者ID:kkrampa,项目名称:commcare-hq,代码行数:32,代码来源:util.py

示例5: _shared_context

# 需要导入模块: from corehq.apps.userreports.models import StaticReportConfiguration [as 别名]
# 或者: from corehq.apps.userreports.models.StaticReportConfiguration import by_domain [as 别名]
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,代码行数:10,代码来源:views.py

示例6: main_context

# 需要导入模块: from corehq.apps.userreports.models import StaticReportConfiguration [as 别名]
# 或者: from corehq.apps.userreports.models.StaticReportConfiguration import by_domain [as 别名]
 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,代码行数:11,代码来源:views.py

示例7: _get_report_module_context

# 需要导入模块: from corehq.apps.userreports.models import StaticReportConfiguration [as 别名]
# 或者: from corehq.apps.userreports.models.StaticReportConfiguration import by_domain [as 别名]
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,代码行数:57,代码来源:modules.py


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