"""This module holds filters for the ``common`` app."""

from django_filters import FilterSet


class MTPFilterSet(FilterSet):
    """An overwritten version of ``FilterSet`` to edit help_text of filter field."""

    def __init__(self, *args, **kwargs):
        """Add an empty help_text for each filter field if not already set.

        If we we don't provide an explicit value for help_text,
        the django-filters ``BaseFilterSet`` will set one,
        with the ``Filter`` value, and we don't want that.


        For the parameters, see ``django_filters.FilterSet``
        """

        super().__init__(*args, **kwargs)

        for filter_field in self.filters.values():
            filter_field.extra.update({
                'help_text': filter_field.extra.get('help_text', ''),
            })
