Example #1
0
def _build_choice_list_filter(spec):
    wrapped = ChoiceListFilterSpec.wrap(spec)
    choices = [Choice(
        fc.value if fc.value is not None else NONE_CHOICE,
        fc.get_display()
    ) for fc in wrapped.choices]
    if wrapped.show_all:
        choices.insert(0, Choice(SHOW_ALL_CHOICE, _('Show all')))
    return ChoiceListFilter(
        name=wrapped.slug,
        datatype=wrapped.datatype,
        label=wrapped.display,
        choices=choices,
    )
Example #2
0
def _build_choice_list_filter(spec, report):
    wrapped = ChoiceListFilterSpec.wrap(spec)
    choices = [
        Choice(fc.value if fc.value is not None else NONE_CHOICE,
               fc.get_display()) for fc in wrapped.choices
    ]
    if wrapped.show_all:
        choices.insert(0, Choice(SHOW_ALL_CHOICE, _('Show all')))
    return ChoiceListFilter(
        name=wrapped.slug,
        datatype=wrapped.datatype,
        label=wrapped.display,
        choices=choices,
    )
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()
        ],
    )
Example #4
0
                          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()
    ],
)


class ReportFiltersSuiteTest(TestCase, TestXmlMixin):
    file_path = 'data', 'mobile_ucr'
    root = os.path.dirname(__file__)

    @staticmethod
    def make_report_config(domain, report_id):
        class MockChoiceProvider(ChoiceProvider):