"""
Author: Michel Peltriaux
Organization: Struktur- und Genehmigungsdirektion Nord, Rhineland-Palatinate, Germany
Contact: michel.peltriaux@sgdnord.rlp.de
Created on: 22.07.21

"""
from konova.filters.table_filters import AbstractTableFilter, SelectionTableFilter, QueryTableFilter, CheckboxTableFilter


class InterventionTableFilter(AbstractTableFilter):
    def __init__(self, user=None, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.user = user
        qs = kwargs.get("queryset", None)
        request_data = kwargs.get("data", None)

        # Pipe the queryset through all needed filters
        self.selection_filter = SelectionTableFilter(
            data=request_data,
            queryset=qs,
        )
        self.query_filter = QueryTableFilter(
            data=request_data,
            queryset=self.selection_filter.qs,
        )
        self.checkbox_filter = CheckboxTableFilter(
            user=user,
            data=request_data,
            queryset=self.query_filter.qs,
        )
        self.qs = self.checkbox_filter.qs

