(self, filter)
Given a filter_spec, return a FilterViewModel representing
        the knockout view model representing this filter in the report builder.
Given a filter_spec, return a FilterViewModel representing
        the knockout view model representing this filter in the report builder.
Given a filter_spec return a FilterViewModel representing the knockout view model representing this filter in the report builder .
def _get_view_model(self, filter):
        """
        Given a filter_spec, return a FilterViewModel representing
        the knockout view model representing this filter in the report builder.

        """
        field = filter['field']
        field, exists = self._check_and_update_column(field)
        if filter['type'] == 'pre':
            return self._get_default_filter_view_model_from_pre_filter(field, filter, exists)
        else:
            filter_type_map = {
                'dynamic_choice_list': const.FORMAT_CHOICE,
                # This exists to handle the `closed` filter that might exist
                'choice_list': const.FORMAT_CHOICE,
                'date': const.FORMAT_DATE,
                'numeric': const.FORMAT_NUMERIC
            }
            try:
                format_ = filter_type_map[filter['type']]
            except KeyError:
                raise BadBuilderConfigError(_(
                    "This report references the '{}' filter, which is not compatible with "
                    "the Report Builder. It is only editable in the advanced interface."
                ).format(filter['type']))
            return UserFilterViewModel(
                exists_in_current_version=exists,
                display_text=filter['display'],
                format=format_,
                property=self._get_property_id_by_indicator_id(field) if exists else None,
                data_source_field=field if not exists else None
            )
def _get_view_model ( self , filter ) : field = filter [ 'field' ] field , exists = self . _check_and_update_column ( field ) if filter [ 'type' ] == 'pre' : return self . _get_default_filter_view_model_from_pre_filter ( field , filter , exists ) else : filter_type_map = { 'dynamic_choice_list' : const . FORMAT_CHOICE , # This exists to handle the `closed` filter that might exist 'choice_list' : const . FORMAT_CHOICE , 'date' : const . FORMAT_DATE , 'numeric' : const . FORMAT_NUMERIC } try : format_ = filter_type_map [ filter [ 'type' ] ] except KeyError : raise BadBuilderConfigError ( _ ( "This report references the '{}' filter, which is not compatible with " "the Report Builder. It is only editable in the advanced interface." ) . format ( filter [ 'type' ] ) ) return UserFilterViewModel ( exists_in_current_version = exists , display_text = filter [ 'display' ] , format = format_ , property = self . _get_property_id_by_indicator_id ( field ) if exists else None , data_source_field = field if not exists else None )