def _build_dynamic_choice_list_filter(spec, report): wrapped = DynamicChoiceListFilterSpec.wrap(spec) choice_provider_spec = wrapped.get_choice_provider_spec() choice_provider = FilterChoiceProviderFactory.from_spec( choice_provider_spec)(report, wrapped.slug) choice_provider.configure(choice_provider_spec) invalid_spec = (wrapped.ancestor_expression and not set( wrapped.ancestor_expression.keys()) == set(['field', 'location_type'])) if invalid_spec: raise BadSpecError( _("'ancestor_expression' must be empty dictionary or have 'field', 'location_type' keys" )) if wrapped.ancestor_expression and not isinstance(choice_provider, LocationChoiceProvider): raise BadSpecError( _("'ancestor_expression' is applicable only for location choices")) return DynamicChoiceListFilter( name=wrapped.slug, datatype=wrapped.datatype, field=wrapped.field, label=wrapped.display, show_all=wrapped.show_all, url_generator=dynamic_choice_list_url, choice_provider=choice_provider, ancestor_expression=wrapped.ancestor_expression, )
def _build_dynamic_choice_list_filter(spec, report): wrapped = DynamicChoiceListFilterSpec.wrap(spec) choice_provider_spec = wrapped.get_choice_provider_spec() choice_provider = FilterChoiceProviderFactory.from_spec(choice_provider_spec)(report, wrapped.slug) choice_provider.configure(choice_provider_spec) invalid_spec = ( wrapped.ancestor_expression and not set(wrapped.ancestor_expression.keys()) == set(['field', 'location_type']) ) if invalid_spec: raise BadSpecError(_( "'ancestor_expression' must be empty dictionary or have 'field', 'location_type' keys")) if wrapped.ancestor_expression and not isinstance(choice_provider, LocationChoiceProvider): raise BadSpecError(_( "'ancestor_expression' is applicable only for location choices" )) return DynamicChoiceListFilter( name=wrapped.slug, datatype=wrapped.datatype, field=wrapped.field, label=wrapped.display, show_all=wrapped.show_all, url_generator=dynamic_choice_list_url, choice_provider=choice_provider, ancestor_expression=wrapped.ancestor_expression, )
def _build_dynamic_choice_list_filter(spec): wrapped = DynamicChoiceListFilterSpec.wrap(spec) return DynamicChoiceListFilter( name=wrapped.slug, datatype=wrapped.datatype, field=wrapped.field, label=wrapped.display, show_all=wrapped.show_all, url_generator=dynamic_choice_list_url, choice_provider=FilterChoiceProviderFactory.from_spec(wrapped.get_choice_provider_spec()), )
def _build_dynamic_choice_list_filter(spec, report): wrapped = DynamicChoiceListFilterSpec.wrap(spec) choice_provider_spec = wrapped.get_choice_provider_spec() choice_provider = FilterChoiceProviderFactory.from_spec(choice_provider_spec)(report, wrapped.slug) choice_provider.configure(choice_provider_spec) return DynamicChoiceListFilter( name=wrapped.slug, datatype=wrapped.datatype, field=wrapped.field, label=wrapped.display, show_all=wrapped.show_all, url_generator=dynamic_choice_list_url, choice_provider=choice_provider, )
def MAKE_REPORT_CONFIG(domain, report_id, columns=None): columns = columns or [ FieldColumn(type='field', aggregation="simple", column_id="color_94ec39e6", display="color", field="color_94ec39e6").to_json(), ] return ReportConfiguration( _id=report_id, title="Entry Report", aggregation_columns=["color_94ec39e6"], config_id="516c494736e95b023cc7845b557de0f5", domain=domain, report_meta=ReportMeta(builder_report_type="chart", created_by_builder=True), columns=columns, configured_charts=[ MultibarChartSpec(type='multibar', chart_id="7451243209119342931", x_axis_column="color_94ec39e6", y_axis_columns=[ GraphDisplayColumn(column_id="count", display="count") ]).to_json() ], filters=[ DynamicChoiceListFilterSpec( type='dynamic_choice_list', display="owner name", field="computed_owner_name_40cc88a0", slug="computed_owner_name_40cc88a0_1").to_json(), ChoiceListFilterSpec(type='choice_list', display="fav color", field="fav_fruit_abc123", slug="fav_fruit_abc123_1", choices=[ FilterChoice(value='a', display='apple'), FilterChoice(value='b', display='banana'), FilterChoice(value='c', display='clementine'), ]).to_json() ], )
display="color", field="color_94ec39e6").to_json(), ], configured_charts=[ MultibarChartSpec(type='multibar', chart_id="7451243209119342931", x_axis_column="color_94ec39e6", y_axis_columns=[ GraphDisplayColumn(column_id="count", display="count") ]).to_json() ], filters=[ DynamicChoiceListFilterSpec(type='dynamic_choice_list', display="owner name", field="computed_owner_name_40cc88a0", slug="computed_owner_name_40cc88a0_1"). to_json(), ChoiceListFilterSpec(type='choice_list', display="fav color", field="fav_fruit_abc123", slug="fav_fruit_abc123_1", choices=[ FilterChoice(value='a', display='apple'), FilterChoice(value='b', display='banana'), FilterChoice(value='c', display='clementine'), ]).to_json() ], )