(self, configuration, index)
return filter
Return a UCR report filter configuration for the given configuration.
        :param configuration:  dictionary representing options selected in UI.
        :param index: Index of this filter in the list of filters configured by the user.
        :return:
Return a UCR report filter configuration for the given configuration.
        :param configuration:  dictionary representing options selected in UI.
        :param index: Index of this filter in the list of filters configured by the user.
        :return:
Return a UCR report filter configuration for the given configuration . : param configuration : dictionary representing options selected in UI . : param index : Index of this filter in the list of filters configured by the user . : return :
def to_report_filter(self, configuration, index):
        """
        Return a UCR report filter configuration for the given configuration.
        :param configuration:  dictionary representing options selected in UI.
        :param index: Index of this filter in the list of filters configured by the user.
        :return:
        """
        filter_format = self._get_filter_format(configuration)
        ui_aggregation = self._get_ui_aggregation_for_filter_format(filter_format)
        column_id = self.to_report_column_option().get_indicators(ui_aggregation)[0]['column_id']

        filter = {
            "field": column_id,
            "slug": "{}_{}".format(column_id, index),
            "display": configuration["display_text"],
            "type": filter_format
        }
        if configuration['format'] == const.FORMAT_DATE:
            filter.update({'compare_as_string': True})

        if filter_format == 'dynamic_choice_list' and self._id == COMPUTED_OWNER_NAME_PROPERTY_ID:
            filter.update({"choice_provider": {"type": "owner"}})
        if filter_format == 'dynamic_choice_list' and self._id == COMPUTED_USER_NAME_PROPERTY_ID:
            filter.update({"choice_provider": {"type": "user"}})
        if filter_format == 'dynamic_choice_list' and self._id == COMPUTED_OWNER_LOCATION_PROPERTY_ID:
            filter.update({"choice_provider": {"type": "location"}})
        if filter_format == 'dynamic_choice_list' and self._id == COMPUTED_OWNER_LOCATION_WITH_DESENDANTS_PROPERTY_ID:
            filter.update({"choice_provider": {"type": "location", "include_descendants": True}})
        if filter_format == 'dynamic_choice_list' and self._id == COMPUTED_OWNER_LOCATION_ARCHIVED_WITH_DESCENDANTS_PROPERTY_ID:
            filter.update({"choice_provider": {"type": "location", "include_descendants": True, "show_all_locations": True}})
        if filter_format == 'dynamic_choice_list' and self._id == COMMCARE_PROJECT:
            filter.update({"choice_provider": {"type": COMMCARE_PROJECT}})
        if configuration.get('pre_value') or configuration.get('pre_operator'):
            filter.update({
                'type': 'pre',  # type could have been "date"
                'pre_operator': configuration.get('pre_operator', None),
                'pre_value': configuration.get('pre_value', []),
            })
        if configuration['format'] == const.PRE_FILTER_VALUE_IS_EMPTY:
            filter.update({
                'type': 'pre',
                'pre_operator': "",
                'pre_value': "",  # for now assume strings - this may not always work but None crashes
            })
        if configuration['format'] == const.PRE_FILTER_VALUE_EXISTS:
            filter.update({
                'type': 'pre',
                'pre_operator': "!=",
                'pre_value': "",
            })
        if configuration['format'] == const.PRE_FILTER_VALUE_NOT_EQUAL:
            filter.update({
                'type': 'pre',
                'pre_operator': "distinct from",
                # pre_value already set by "pre" clause
            })
        return filter
def to_report_filter ( self , configuration , index ) : filter_format = self . _get_filter_format ( configuration ) ui_aggregation = self . _get_ui_aggregation_for_filter_format ( filter_format ) column_id = self . to_report_column_option ( ) . get_indicators ( ui_aggregation ) [ 0 ] [ 'column_id' ] filter = { "field" : column_id , "slug" : "{}_{}" . format ( column_id , index ) , "display" : configuration [ "display_text" ] , "type" : filter_format } if configuration [ 'format' ] == const . FORMAT_DATE : filter . update ( { 'compare_as_string' : True } ) if filter_format == 'dynamic_choice_list' and self . _id == COMPUTED_OWNER_NAME_PROPERTY_ID : filter . update ( { "choice_provider" : { "type" : "owner" } } ) if filter_format == 'dynamic_choice_list' and self . _id == COMPUTED_USER_NAME_PROPERTY_ID : filter . update ( { "choice_provider" : { "type" : "user" } } ) if filter_format == 'dynamic_choice_list' and self . _id == COMPUTED_OWNER_LOCATION_PROPERTY_ID : filter . update ( { "choice_provider" : { "type" : "location" } } ) if filter_format == 'dynamic_choice_list' and self . _id == COMPUTED_OWNER_LOCATION_WITH_DESENDANTS_PROPERTY_ID : filter . update ( { "choice_provider" : { "type" : "location" , "include_descendants" : True } } ) if filter_format == 'dynamic_choice_list' and self . _id == COMPUTED_OWNER_LOCATION_ARCHIVED_WITH_DESCENDANTS_PROPERTY_ID : filter . update ( { "choice_provider" : { "type" : "location" , "include_descendants" : True , "show_all_locations" : True } } ) if filter_format == 'dynamic_choice_list' and self . _id == COMMCARE_PROJECT : filter . update ( { "choice_provider" : { "type" : COMMCARE_PROJECT } } ) if configuration . get ( 'pre_value' ) or configuration . get ( 'pre_operator' ) : filter . update ( { 'type' : 'pre' , # type could have been "date" 'pre_operator' : configuration . get ( 'pre_operator' , None ) , 'pre_value' : configuration . get ( 'pre_value' , [ ] ) , } ) if configuration [ 'format' ] == const . PRE_FILTER_VALUE_IS_EMPTY : filter . update ( { 'type' : 'pre' , 'pre_operator' : "" , 'pre_value' : "" , # for now assume strings - this may not always work but None crashes } ) if configuration [ 'format' ] == const . PRE_FILTER_VALUE_EXISTS : filter . update ( { 'type' : 'pre' , 'pre_operator' : "!=" , 'pre_value' : "" , } ) if configuration [ 'format' ] == const . PRE_FILTER_VALUE_NOT_EQUAL : filter . update ( { 'type' : 'pre' , 'pre_operator' : "distinct from" , # pre_value already set by "pre" clause } ) return filter