# generated by appcreator
import django_filters
from django import forms

from dal import autocomplete

from vocabs.filters import generous_concept_filter
from vocabs.models import SkosConcept
from . models import (
    TrpCollection,
    TrpDocument,
    TrpPage,
    TrpTranscript
)


class TrpCollectionListFilter(django_filters.FilterSet):
    legacy_id = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpCollection._meta.get_field('legacy_id').help_text,
        label=TrpCollection._meta.get_field('legacy_id').verbose_name
    )
    name = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpCollection._meta.get_field('name').help_text,
        label=TrpCollection._meta.get_field('name').verbose_name
    )
    description = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpCollection._meta.get_field('description').help_text,
        label=TrpCollection._meta.get_field('description').verbose_name
    )
    image_url = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpCollection._meta.get_field('image_url').help_text,
        label=TrpCollection._meta.get_field('image_url').verbose_name
    )
    thumb_url = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpCollection._meta.get_field('thumb_url').help_text,
        label=TrpCollection._meta.get_field('thumb_url').verbose_name
    )
    role = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpCollection._meta.get_field('role').help_text,
        label=TrpCollection._meta.get_field('role').verbose_name
    )

    class Meta:
        model = TrpCollection
        fields = [
            'id',
            'legacy_id',
            'id',
            'name',
            'description',
            'page_id',
            'image_url',
            'thumb_url',
            'nr_of_documents',
            'role',
            ]


class TrpDocumentListFilter(django_filters.FilterSet):
    legacy_id = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpDocument._meta.get_field('legacy_id').help_text,
        label=TrpDocument._meta.get_field('legacy_id').verbose_name
    )
    title = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpDocument._meta.get_field('title').help_text,
        label=TrpDocument._meta.get_field('title').verbose_name
    )
    author = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpDocument._meta.get_field('author').help_text,
        label=TrpDocument._meta.get_field('author').verbose_name
    )
    genre = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpDocument._meta.get_field('genre').help_text,
        label=TrpDocument._meta.get_field('genre').verbose_name
    )
    writer = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpDocument._meta.get_field('writer').help_text,
        label=TrpDocument._meta.get_field('writer').verbose_name
    )
    script_type = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpDocument._meta.get_field('script_type').help_text,
        label=TrpDocument._meta.get_field('script_type').verbose_name
    )
    uploader = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpDocument._meta.get_field('uploader').help_text,
        label=TrpDocument._meta.get_field('uploader').verbose_name
    )
    image_url = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpDocument._meta.get_field('image_url').help_text,
        label=TrpDocument._meta.get_field('image_url').verbose_name
    )
    thumb_url = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpDocument._meta.get_field('thumb_url').help_text,
        label=TrpDocument._meta.get_field('thumb_url').verbose_name
    )
    external_id = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpDocument._meta.get_field('external_id').help_text,
        label=TrpDocument._meta.get_field('external_id').verbose_name
    )
    authority = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpDocument._meta.get_field('authority').help_text,
        label=TrpDocument._meta.get_field('authority').verbose_name
    )
    description = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpDocument._meta.get_field('description').help_text,
        label=TrpDocument._meta.get_field('description').verbose_name
    )
    language = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpDocument._meta.get_field('language').help_text,
        label=TrpDocument._meta.get_field('language').verbose_name
    )
    col_list = django_filters.ModelMultipleChoiceFilter(
        queryset=TrpCollection.objects.all(),
        help_text=TrpDocument._meta.get_field('col_list').help_text,
        label=TrpDocument._meta.get_field('col_list').verbose_name,
        widget=autocomplete.Select2Multiple(
            url="archiv-ac:trpcollection-autocomplete",
        )
    )

    class Meta:
        model = TrpDocument
        fields = [
            'id',
            'legacy_id',
            'id',
            'title',
            'author',
            'upload_time_stamp',
            'created_at',
            'genre',
            'writer',
            'script_type',
            'uploader',
            'uploader_id',
            'nr_of_pages',
            'page_id',
            'image_url',
            'thumb_url',
            'external_id',
            'authority',
            'description',
            'language',
            'status',
            'created_from_timestamp',
            'created_to_timestamp',
            'orig_doc_id',
            'col_list',
            'nr_of_regions',
            'nr_of_transcribed_regions',
            'nr_of_words_in_regions',
            'nr_of_lines',
            'nr_of_words_in_lines',
            'nr_of_words',
            'nr_of_transcribed_words',
            'nr_of_new',
            'nr_of_in_progress',
            'nr_of_done',
            'nr_of_final',
            'nr_of_gt',
            ]


class TrpPageListFilter(django_filters.FilterSet):
    legacy_id = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpPage._meta.get_field('legacy_id').help_text,
        label=TrpPage._meta.get_field('legacy_id').verbose_name
    )
    part_of = django_filters.ModelMultipleChoiceFilter(
        queryset=TrpDocument.objects.all(),
        help_text=TrpPage._meta.get_field('part_of').help_text,
        label=TrpPage._meta.get_field('part_of').verbose_name,
        widget=autocomplete.Select2Multiple(
            url="archiv-ac:trpdocument-autocomplete",
        )
    )
    page_key = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpPage._meta.get_field('page_key').help_text,
        label=TrpPage._meta.get_field('page_key').verbose_name
    )
    page_url = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpPage._meta.get_field('page_url').help_text,
        label=TrpPage._meta.get_field('page_url').verbose_name
    )
    thum_url = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpPage._meta.get_field('thum_url').help_text,
        label=TrpPage._meta.get_field('thum_url').verbose_name
    )
    img_file_name = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpPage._meta.get_field('img_file_name').help_text,
        label=TrpPage._meta.get_field('img_file_name').verbose_name
    )

    class Meta:
        model = TrpPage
        fields = [
            'id',
            'legacy_id',
            'id',
            'part_of',
            'page_nr',
            'page_key',
            'image_id',
            'page_url',
            'thum_url',
            'img_file_name',
            'width',
            'height',
            'created',
            'indexed',
            ]


class TrpTranscriptListFilter(django_filters.FilterSet):
    legacy_id = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpTranscript._meta.get_field('legacy_id').help_text,
        label=TrpTranscript._meta.get_field('legacy_id').verbose_name
    )
    following = django_filters.ModelMultipleChoiceFilter(
        queryset=TrpTranscript.objects.all(),
        help_text=TrpTranscript._meta.get_field('following').help_text,
        label=TrpTranscript._meta.get_field('following').verbose_name,
        widget=autocomplete.Select2Multiple(
            url="archiv-ac:trptranscript-autocomplete",
        )
    )
    transcript_key = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpTranscript._meta.get_field('transcript_key').help_text,
        label=TrpTranscript._meta.get_field('transcript_key').verbose_name
    )
    part_of = django_filters.ModelMultipleChoiceFilter(
        queryset=TrpPage.objects.all(),
        help_text=TrpTranscript._meta.get_field('part_of').help_text,
        label=TrpTranscript._meta.get_field('part_of').verbose_name,
        widget=autocomplete.Select2Multiple(
            url="archiv-ac:trppage-autocomplete",
        )
    )
    part_of_document = django_filters.ModelMultipleChoiceFilter(
        queryset=TrpDocument.objects.all(),
        help_text=TrpTranscript._meta.get_field('part_of_document').help_text,
        label=TrpTranscript._meta.get_field('part_of_document').verbose_name,
        widget=autocomplete.Select2Multiple(
            url="archiv-ac:trpdocument-autocomplete",
        )
    )
    transcript_url = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpTranscript._meta.get_field('transcript_url').help_text,
        label=TrpTranscript._meta.get_field('transcript_url').verbose_name
    )
    status = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpTranscript._meta.get_field('status').help_text,
        label=TrpTranscript._meta.get_field('status').verbose_name
    )
    transcriber = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=TrpTranscript._meta.get_field('transcriber').help_text,
        label=TrpTranscript._meta.get_field('transcriber').verbose_name
    )

    class Meta:
        model = TrpTranscript
        fields = [
            'id',
            'legacy_id',
            'id',
            'following',
            'transcript_key',
            'part_of',
            'part_of_document',
            'transcript_url',
            'status',
            'transcriber',
            'transcriber_id',
            'timestamp',
            'nr_of_regions',
            'nr_of_transcribed_regions',
            'nr_of_words_in_regions',
            'nr_of_lines',
            'nr_of_words_in_lines',
            'nr_of_words',
            'gt_id',
            ]


