def by_ids(cls, config_ids): mapping = cls.by_id_mapping() config_by_ids = {} for config_id in set(config_ids): try: domain, wrapped = mapping[config_id] except KeyError: raise ReportConfigurationNotFoundError( _("The following report configuration could not be found: {}" .format(config_id))) config_by_ids[config_id] = cls._get_report_config(wrapped, domain) return config_by_ids
def wrap_report_config_by_type(config): from corehq.apps.userreports.models import ( ReportConfiguration, RegistryReportConfiguration, ) try: return { "ReportConfiguration": ReportConfiguration, "RegistryReportConfiguration": RegistryReportConfiguration, }[config["doc_type"]].wrap(config) except KeyError: raise ReportConfigurationNotFoundError()
def by_ids(cls, config_ids): config_ids = set(config_ids) mapping = cls.by_id_mapping() if not config_ids <= set(mapping.keys()): mapping = cls.by_id_mapping(rebuild=True) return_configs = [] for config_id in config_ids: metadata = mapping.get(config_id, None) if not metadata: raise ReportConfigurationNotFoundError( _("The following report configuration could not be found: {}" .format(config_id))) return_configs.append(cls._get_from_metadata(metadata)) return return_configs