Example #1
0
class StoryboardFilter(filters.FilterSet):

    storyboarder = filters.ModelMultipleChoiceFilter(
        name='storyboarder__username',
        to_field_name='username',
        queryset=Storyboarder.objects.all(),
        conjoined=True,
    )

    tags = filters.ModelMultipleChoiceFilter(
        name='tags__internal_id',
        to_field_name='internal_id',
        queryset=Tag.objects.all(),
        conjoined=True,
    )

    class Meta:
        model = Storyboard

        fields = [
            'song', 'artist', 'set_id', 'storyboarder', 'mapper', 'date_added',
            'date_created', 'medium', 'tags'
        ]

        filter_overrides = {
            models.CharField: {
                'filter_class': filters.CharFilter,
                'extra': lambda f: {
                    'lookup_expr': 'icontains',
                }
            }
        }
Example #2
0
class CategoryColumnFilterSet(rest_framework.FilterSet):
    categories = rest_framework.ModelMultipleChoiceFilter(
        queryset=create_category_filter(),
        name='field__category',
        label='Categories')
    purposes = rest_framework.ModelMultipleChoiceFilter(
        queryset=CategoryColumnPurpose.objects.all(),
        name='purpose',
        label='Purposes')

    @property
    def qs(self):
        qs = super(CategoryColumnFilterSet, self).qs

        qs = qs.prefetch_related(
            'field__category',
            'country',
            'purpose',
        )

        if self.request:
            categories_with_permission = create_category_filter()(self.request)
            qs = qs.filter(field__category__in=categories_with_permission, )

        return qs

    class Meta:
        model = CategoryColumn
        fields = ('purpose', )
Example #3
0
class EntityFilter(django_filters.FilterSet):
    id = django_filters.ModelMultipleChoiceFilter(
        help_text="Filter by Entity ID",
        queryset=Entity.objects.all().only("id"),
        method="filter_entities",
    )

    contractor_id = django_filters.ModelMultipleChoiceFilter(
        help_text="Filter by Contractor ID",
        queryset=Contractor.objects.all(),
        method="filter_contractors_by_id",
    )

    class Meta:
        model = Entity
        fields = ["id", "contractor_id"]

    def filter_entities(self, queryset, name, value):
        if not value:
            return queryset

        entity_ids = [entity.id for entity in value]
        return queryset.filter(pk__in=entity_ids)

    def filter_contractors_by_id(self, queryset, name, value):
        if not value:
            return queryset

        return queryset.filter(contract__contractors__in=value).distinct()
Example #4
0
class EventFilter(filters.FilterSet):
    """
    Provides useful filtering options for the
    :class:`~research.models.event.Event` model.
    """

    title = filters.LookupChoiceFilter(lookup_choices=LOOKUP_CHOICES)
    description = filters.LookupChoiceFilter(lookup_choices=LOOKUP_CHOICES)
    procedure = filters.ModelMultipleChoiceFilter(
        queryset=Procedure.objects.all(), label="Procedures:")
    exclude_procedure = filters.ModelMultipleChoiceFilter(
        queryset=Procedure.objects.all(),
        exclude=True,
        field_name="procedure",
        label="Exclude procedures:",
    )
    study = filters.ModelMultipleChoiceFilter(
        queryset=Study.objects.all(),
        label="Studies:",
        field_name="procedure__study",
    )

    class Meta:
        model = Event
        fields = ("id", )
Example #5
0
class RunFilter(filters.FilterSet):
    """
    Provides useful filtering options for the
    :class:`~django_analyses.models.run.Run` model.
    """

    analysis = filters.ModelMultipleChoiceFilter(
        "analysis_version__analysis",
        queryset=ANALYSES_WITH_RUNS,
    )
    analysis_version = filters.ModelMultipleChoiceFilter(
        "analysis_version", queryset=ANALYSIS_VERSIONS_WITH_RUNS)
    status = filters.MultipleChoiceFilter(choices=RunStatus.choices())
    start_time = filters.DateTimeFromToRangeFilter()
    end_time = filters.DateTimeFromToRangeFilter()
    if Subject:
        subject = filters.NumberFilter(method="get_subject_runs",
                                       label="By subject ID:",
                                       required=False)

    class Meta:
        model = Run
        fields = ("id", )

    def get_subject_runs(self, queryset: QuerySet, name: str,
                         pk: int) -> QuerySet:
        try:
            subject = Subject.objects.get(id=pk)
        except Subject.DoesNotExist:
            pass
        else:
            return subject.query_run_set()
Example #6
0
class SkillFilter(filters.FilterSet):
    name = filters.CharFilter(method='filter_name')
    description = filters.CharFilter(method='filter_description')
    scaling_stats__pk = filters.ModelMultipleChoiceFilter(queryset=ScalingStat.objects.all(), to_field_name='pk', conjoined=True)
    effects_logic = filters.BooleanFilter(method='filter_effects_logic')
    effect__pk = filters.ModelMultipleChoiceFilter(queryset=SkillEffect.objects.all(), method='filter_skill_effects')
    used_on = filters.NumberFilter(method='filter_used_on')

    class Meta:
        model = Skill
        fields = {
            'id': ['in'],
            'name': ['exact'],
            'com2us_id': ['exact'],
            'slot': ['exact'],
            'cooltime': ['exact', 'isnull', 'gte', 'lte', 'gt', 'lt'],
            'hits': ['exact', 'isnull', 'gte', 'lte', 'gt', 'lt'],
            'aoe': ['exact'],
            'passive': ['exact'],
            'max_level': ['exact', 'gte', 'lte', 'gt', 'lt'],
        }

    def filter_name(self, queryset, name, value):
        return queryset.filter(name__istartswith=value)

    def filter_description(self, queryset, name, value):
        return queryset.filter(description__icontains=value)

    def filter_skill_effects(self, queryset, name, value):
        old_filtering = self.form.cleaned_data.get('effects_logic', False)
        stat_scaling = self.form.cleaned_data.get('scaling_stats__pk', [])

        if old_filtering:
            # Filter if any skill on the monster has the designated fields
            for effect in value:
                queryset = queryset.filter(skill_effect=effect)

            for pk in stat_scaling:
                queryset = queryset.filter(scaling_stats=pk)

            return queryset.distinct()
        else:
            # Filter effects based on effects of each individual skill. This ensures a monster will not show up unless it has
            # the desired effects on the same skill rather than across any skills.
            skills = Skill.objects.all()

            for effect in value:
                skills = skills.filter(skill_effect=effect)

            for pk in stat_scaling:
                skills = skills.filter(scaling_stats=pk)

            return queryset.filter(pk__in=skills).distinct()

    def filter_used_on(self, queryset, name, value):
        return queryset.filter(monster__pk=value)

    def filter_effects_logic(self, queryset, name, value):
        # This field is just used to alter the logic of skill effect filter
        return queryset
Example #7
0
class VisitFilterSet(rest_framework.FilterSet):
    timestamp = IsoDateTimeFromToRangeFilter(
        name='timestamp'
    )
    products = rest_framework.ModelMultipleChoiceFilter(
        queryset=create_product_filter(),
        name='product',
        label='Products'
    )
    websites = rest_framework.ModelMultipleChoiceFilter(
        queryset=create_website_filter('view_website_visits'),
        name='website',
        label='Websites'
    )
    categories = rest_framework.ModelMultipleChoiceFilter(
        queryset=create_category_filter('view_category_visits'),
        name='product__instance_model__model__category',
        label='Categories'
    )

    @property
    def qs(self):
        qs = super(VisitFilterSet, self).qs.select_related(
            'product__instance_model__model__category',
            'user'
        )
        if self.request:
            qs = qs.filter_by_user_perms(self.request.user, 'view_visit')
        return qs

    class Meta:
        model = Visit
        fields = []
Example #8
0
class InformationPackageFilter(filters.FilterSet):
    archivist_organization = filters.ModelMultipleChoiceFilter(
        label=_("Archivist Organization"),
        queryset=Agent.objects.filter(role__iexact="archivist", type__iexact="organization"),
    )
    responsible = filters.ModelMultipleChoiceFilter(
        field_name="responsible__username",
        to_field_name="username",
        queryset=users
    )
    state = MultipleCharFilter()
    object_size = filters.RangeFilter()
    start_date = filters.IsoDateTimeFromToRangeFilter()
    end_date = filters.IsoDateTimeFromToRangeFilter()
    create_date = filters.IsoDateTimeFromToRangeFilter()
    entry_date = filters.IsoDateTimeFromToRangeFilter()
    package_type = MultipleCharFilter()
    package_type_name_exclude = filters.CharFilter(
        label=_("Excluded Package Type"),
        method='exclude_package_type_name'
    )

    def exclude_package_type_name(self, queryset, name, value):
        for package_type_id, package_type_name in InformationPackage.PACKAGE_TYPE_CHOICES:
            if package_type_name.lower() == value.lower():
                return queryset.exclude(package_type=package_type_id)
        return queryset.none()

    class Meta:
        model = InformationPackage
        fields = ['archivist_organization', 'state', 'responsible',
                  'create_date', 'entry_date', 'object_size', 'start_date', 'end_date',
                  'archived', 'cached', 'package_type', 'package_type_name_exclude']
Example #9
0
class SeekingFilter(django_rest_filters.FilterSet):
    """Custom filter for seekings"""
    class Meta:
        model = Seeking
        fields = ['tags', 'category', 'location_id', 'author_id']

    # tricky part - how to filter by related field?
    # but not by its foreign key (default)
    # `to_field_name` is crucial here
    # `conjoined=True` makes that, the more tags, the more narrow the search
    tags = django_rest_filters.ModelMultipleChoiceFilter(queryset=Tag.objects,
                                                         to_field_name='name',
                                                         conjoined=True,
                                                         method='filter_tags')

    category = django_rest_filters.ModelMultipleChoiceFilter(
        queryset=Category.objects,
        to_field_name='name',
        conjoined=True,
        method='filter_category')

    def filter_tags(self, queryset, name, tags):
        if tags:
            q = queryset.filter(tags__in=tags).distinct()
            return q
        else:
            return queryset

    def filter_category(self, queryset, name, categories):
        if categories and len(categories) > 0:
            return queryset.filter(category=categories[0])
        else:
            return queryset
class RestaurantFilter(filters.FilterSet):
    cuisine_type = filters.ModelMultipleChoiceFilter(queryset=CuisineType.objects.all())
    outlet_type = filters.ModelMultipleChoiceFilter(queryset=OutletType.objects.all())
    affordability = filters.ModelMultipleChoiceFilter(queryset=Affordability.objects.all())

    class Meta:
        model = Restaurant
        fields = ['cuisine_type', 'outlet_type', 'affordability', 'halal', 'vegan_friendly']
class ReviewFilter(filters.FilterSet):
    user = filters.ModelMultipleChoiceFilter(field_name="user_id",
                                             to_field_name="user_id",
                                             queryset=Review.objects.all())
    product = filters.ModelMultipleChoiceFilter(field_name="product_id",
                                                to_field_name="product_id",
                                                queryset=Review.objects.all())
    created_at = filters.DateFromToRangeFilter(lookup_expr='exact')
    updated_at = filters.DateFromToRangeFilter(lookup_expr='exact')
Example #12
0
class BookFilter(filters.FilterSet):
    title = filters.CharFilter(lookup_expr='icontains')
    authors = filters.ModelMultipleChoiceFilter(queryset=Author.objects.all())
    language = filters.ModelMultipleChoiceFilter(
        queryset=Language.objects.all())
    pub_date__gte = filters.NumberFilter(field_name='pub_date',
                                         lookup_expr='gte')
    pub_date__lte = filters.NumberFilter(field_name='pub_date',
                                         lookup_expr='lte')
Example #13
0
class AgendaFilter(filters.FilterSet):
    medico = filters.ModelMultipleChoiceFilter(queryset=Medico.objects.all())
    especialidade = filters.ModelMultipleChoiceFilter(
        queryset=Especialidade.objects.all(),
        field_name="medico__especialidade",
    )
    data_inicio = filters.DateFilter(field_name='horario', lookup_expr='gte')
    data_final = filters.DateFilter(field_name='horario', lookup_expr='lte')

    class Meta:
        model = Agenda
        fields = ['medico', 'especialidade', 'data_inicio', 'data_final']
Example #14
0
class AgendaFilter(filters.FilterSet):
    doctor = filters.ModelMultipleChoiceFilter(queryset=Doctor.objects.all())
    specialty = filters.ModelMultipleChoiceFilter(
        field_name='doctor__specialty',
        lookup_expr='exact',
        queryset=Specialty.objects.all())
    start_date = filters.CharFilter(field_name="day", lookup_expr='gte')
    end_date = filters.CharFilter(field_name="day", lookup_expr='lte')

    class Meta:
        model = Agenda
        fields = ['doctor', 'specialty', 'start_date', 'end_date']
Example #15
0
class KeyWordListFilter(django_filters.FilterSet):
    rvn_stelle_key_word_keyword__text__autor = django_filters.ModelMultipleChoiceFilter(
        queryset=Autor.objects.all(),
        label="Autor",
        help_text="Stichworte wurde von diesen Autoren verwendet",
        widget=autocomplete.Select2Multiple(
            url="archiv-ac:autor-autocomplete", ))
    legacy_id = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=KeyWord._meta.get_field('legacy_id').help_text,
        label=KeyWord._meta.get_field('legacy_id').verbose_name)
    stichwort = django_filters.LookupChoiceFilter(
        lookup_choices=CHAR_LOOKUP_CHOICES,
        help_text=KeyWord._meta.get_field('stichwort').help_text,
        label=KeyWord._meta.get_field('stichwort').verbose_name)
    wurzel = django_filters.LookupChoiceFilter(
        lookup_choices=CHAR_LOOKUP_CHOICES,
        help_text=KeyWord._meta.get_field('wurzel').help_text,
        label=KeyWord._meta.get_field('wurzel').verbose_name)
    kommentar = django_filters.LookupChoiceFilter(
        lookup_choices=CHAR_LOOKUP_CHOICES,
        help_text=KeyWord._meta.get_field('kommentar').help_text,
        label=KeyWord._meta.get_field('kommentar').verbose_name)
    varianten = django_filters.LookupChoiceFilter(
        lookup_choices=CHAR_LOOKUP_CHOICES,
        help_text=KeyWord._meta.get_field('varianten').help_text,
        label=KeyWord._meta.get_field('varianten').verbose_name)
    rvn_stelle_key_word_keyword = django_filters.ModelMultipleChoiceFilter(
        queryset=Stelle.objects.all(),
        label="Stelle",
        help_text="Stichworte stehen mit diesen Stellen in Verbindung",
        widget=autocomplete.Select2Multiple(
            url="archiv-ac:stelle-autocomplete", ))
    rvn_stelle_key_word_keyword__text = django_filters.ModelMultipleChoiceFilter(
        queryset=Text.objects.all(),
        label="Text",
        help_text="Stichworte stehen mit diesen Texten in Verbindung",
        widget=autocomplete.Select2Multiple(
            url="archiv-ac:text-autocomplete", ))
    rvn_stelle_key_word_keyword__text__autor__ort = django_filters.ModelMultipleChoiceFilter(
        queryset=Ort.objects.all(),
        label="Ort",
        help_text="Stichworte stehen mit diesen Orten in Verbindung",
        widget=autocomplete.Select2Multiple(
            url="archiv-ac:ort-autocomplete", ))

    class Meta:
        model = KeyWord
        fields = [
            'rvn_stelle_key_word_keyword__text__autor', 'id', 'legacy_id',
            'legacy_pk', 'stichwort', 'art', 'wurzel', 'kommentar', 'varianten'
        ]
Example #16
0
class FacilityStaffFilter(filters.FilterSet):
    facility = filters.ModelMultipleChoiceFilter(
        queryset=facility_models.Facility.objects.all())
    name = filters.CharFilter(lookup_expr='istartswith')
    phone_number = filters.CharFilter()
    email = filters.CharFilter()
    designation = filters.ModelMultipleChoiceFilter(
        field_name="designation__name",
        queryset=facility_models.StaffDesignation.objects.all())

    class Meta:
        model = facility_models.FacilityStaff
        fields = ("facility", "name", "phone_number", "email", "designation")
Example #17
0
class RecordFilter(filters.FilterSet):
    class Meta:
        model = Record
        fields = [
            'assets_from',
            'assets_to',
            'dt_from',
            'dt_to',
            'tags_and',
            'tags_or',
            'mode',
        ]

    dt_from = filters.DateTimeFilter(name='created_dt', lookup_expr='gte')
    dt_to = filters.DateTimeFilter(name='created_dt', lookup_expr='lte')
    tags_or = filters.ModelMultipleChoiceFilter(
        name='tags__pk',
        to_field_name='pk',
        queryset=user_tags,
        conjoined=False,
    )
    tags_and = filters.ModelMultipleChoiceFilter(
        name='tags__pk',
        to_field_name='pk',
        queryset=user_tags,
        conjoined=True,
    )

    assets_from = filters.ModelMultipleChoiceFilter(
        name='asset_from',
        queryset=user_assets,
        conjoined=False,
    )

    assets_to = filters.ModelMultipleChoiceFilter(
        name='asset_to',
        queryset=user_assets,
        conjoined=False,
    )

    mode_or = filters.MultipleChoiceFilter(
        name='mode',
        choices=Record.MODES,
        conjoined=False,
    )

    sort_by = filters.OrderingFilter(
        # tuple-mapping retains order
        fields=(('created_dt', 'created_ts'), ), )
Example #18
0
class InformationPackageFilter(filters.FilterSet):
    archivist_organization = filters.ModelMultipleChoiceFilter(
        label=_("Archivist Organization"),
        queryset=Agent.objects.filter(role__iexact="archivist", type__iexact="organization"),
    )
    responsible = filters.ModelMultipleChoiceFilter(
        field_name="responsible__username",
        to_field_name="username",
        queryset=lambda request: users_in_organization(request.user),
    )
    state = MultipleCharFilter()
    object_size = filters.RangeFilter()
    start_date = filters.IsoDateTimeFromToRangeFilter()
    end_date = filters.IsoDateTimeFromToRangeFilter()
    create_date = filters.IsoDateTimeFromToRangeFilter()
    entry_date = filters.IsoDateTimeFromToRangeFilter()
    package_type = MultipleCharFilter()
    package_type_name_exclude = filters.CharFilter(
        label=_("Excluded Package Type"),
        method='exclude_package_type_name'
    )
    migratable = filters.BooleanFilter(label='migratable', method='filter_migratable')
    workarea = filters.ChoiceFilter(label=_("Workarea"), field_name='workareas__type', choices=Workarea.TYPE_CHOICES)
    medium = filters.ModelChoiceFilter(
        label='Storage Medium', queryset=StorageMedium.objects.all(),
        field_name='storage__storage_medium',
        distinct=True
    )
    policy = filters.ModelChoiceFilter(
        label='Storage Policy', queryset=StoragePolicy.objects.all(),
        field_name='submission_agreement__policy',
        distinct=True
    )

    def exclude_package_type_name(self, queryset, name, value):
        for package_type_id, package_type_name in InformationPackage.PACKAGE_TYPE_CHOICES:
            if package_type_name.lower() == value.lower():
                return queryset.exclude(package_type=package_type_id)
        return queryset.none()

    def filter_migratable(self, queryset, name, value):
        return queryset.migratable()

    class Meta:
        model = InformationPackage
        fields = ['archivist_organization', 'state', 'responsible', 'active', 'label',
                  'create_date', 'entry_date', 'object_size', 'start_date', 'end_date', 'policy',
                  'archived', 'cached', 'package_type', 'package_type_name_exclude', 'workarea']
Example #19
0
class CoursePageFilter(filters.FilterSet):
    lang_code = filters.MultipleChoiceFilter(name='lang_code', \
            lookup_expr='exact', choices=settings.LANGUAGES, \
            widget=forms.CheckboxSelectMultiple, initial='en', \
            label=_('Language'))
    keywords = filters.ModelMultipleChoiceFilter(
        name='multilang_keywords',
        queryset=MultilangKeyword.objects.all(),
        widget=forms.CheckboxSelectMultiple,
        label=_('Keywords'))
    level = filters.MultipleChoiceFilter(name='level', \
            lookup_expr='exact', choices=LEVELS, \
            widget=forms.CheckboxSelectMultiple, \
            label=_('Level'))
    delivery_method = filters.MultipleChoiceFilter(name='delivery_format', \
            lookup_expr='exact', choices=CoursePage.DELIVERY_FORMAT, \
            widget=forms.CheckboxSelectMultiple, \
            label=_('Delivery Method'))
    o = filters.OrderingFilter(choices=(('title', _('Title')), ),
                               fields={
                                   'title': 'title',
                               },
                               initial='title',
                               help_text='')

    class Meta:
        model = CoursePage
        fields = {}
Example #20
0
class SubmissionsFilter(filters.FilterSet):
    round = RoundLabFilter(queryset=RoundsAndLabs.objects.all())
    status = filters.MultipleChoiceFilter(choices=PHASES)
    active = filters.BooleanFilter(method='filter_active', label='Active')
    submit_date = filters.DateFromToRangeFilter(field_name='submit_time',
                                                label='Submit date')
    fund = filters.ModelMultipleChoiceFilter(
        field_name='page',
        label='fund',
        queryset=Page.objects.type(FundType) | Page.objects.type(LabType))

    class Meta:
        model = ApplicationSubmission
        fields = (
            'status',
            'round',
            'active',
            'submit_date',
            'fund',
        )

    def filter_active(self, qs, name, value):
        if value is None:
            return qs

        if value:
            return qs.active()
        else:
            return qs.inactive()
Example #21
0
class MedicoFilter(filters.FilterSet):
    especialidade = filters.ModelMultipleChoiceFilter(
        queryset=Especialidade.objects.all())

    class Meta:
        model = Medico
        fields = ['especialidade']
Example #22
0
class EventFilter(filters.FilterSet):
    start_after = filters.DateFilter(field_name='start', lookup_expr='gte')
    start_before = filters.DateFilter(field_name='start', lookup_expr='lte')
    end_after = filters.DateFilter(field_name='end', lookup_expr='gte')
    end_before = filters.DateFilter(field_name='end', lookup_expr='lte')
    tags = filters.ModelMultipleChoiceFilter(
        field_name='tags__name',
        to_field_name='name',
        queryset=Tag.objects.all(),
        conjoined=True,
    )
    order_by = filters.OrderingFilter(fields=(
        'slug',
        'start',
        'end',
    ), )

    class Meta:
        model = Event
        fields = (
            'completed',
            'tags',
            'administrator',
            'host',
            'start',
            'start_before',
            'start_after',
            'end',
            'end_before',
            'end_after',
            'country',
        )
Example #23
0
class ProcedureFilter(filters.FilterSet):
    """
    Provides useful filtering options for the
    :class:`~research.models.procedure.Procedure` model.
    """

    title = filters.LookupChoiceFilter(lookup_choices=LOOKUP_CHOICES)
    description = filters.LookupChoiceFilter(lookup_choices=LOOKUP_CHOICES)
    study = filters.ModelMultipleChoiceFilter(queryset=Study.objects.all())
    exclude_study = filters.ModelMultipleChoiceFilter(
        field_name="study", exclude=True, queryset=Study.objects.all()
    )

    class Meta:
        model = Procedure
        fields = ("id",)
Example #24
0
class VideoFilter(djfilters.FilterSet):
    categories__name__icontains = djfilters.ModelMultipleChoiceFilter(
        field_name='categories__name',
        to_field_name='name',
        lookup_expr='icontains',
        queryset=Category.objects.all(),
    )
    created_time = djfilters.DateTimeFromToRangeFilter()
    updated_time = djfilters.DateTimeFromToRangeFilter()
    uploaded_time = djfilters.DateTimeFromToRangeFilter()

    class Meta:
        model = Video
        fields = {
            'duration': ['exact', 'gt', 'gte', 'lt', 'lte'],
            'creator__email': ['exact'],
            'framerate': ['exact'],
            'has_tono_records': ['exact'],
            'is_filler': ['exact'],
            'name': ['exact', 'icontains'],
            'organization': ['exact'],
            'played_count_web': ['exact', 'gt', 'gte', 'lt', 'lte'],
            'publish_on_web': ['exact'],
            'ref_url': ['exact', 'startswith', 'icontains'],
        }
Example #25
0
class DietaEspecialFilter(filters.FilterSet):
    aluno = filters.CharFilter(field_name='aluno__uuid', lookup_expr='iexact')
    nome_aluno = filters.CharFilter(field_name='aluno__nome',
                                    lookup_expr='icontains')
    nome_completo_aluno = filters.CharFilter(field_name='aluno__nome',
                                             lookup_expr='iexact')
    codigo_eol_aluno = filters.CharFilter(field_name='aluno__codigo_eol',
                                          lookup_expr='iexact')
    escola = filters.CharFilter(field_name='rastro_escola__uuid',
                                lookup_expr='iexact')
    dre = filters.CharFilter(
        field_name='rastro_escola__diretoria_regional__uuid',
        lookup_expr='iexact')
    cpf_responsavel = filters.CharFilter(field_name='aluno__responsaveis__cpf',
                                         lookup_expr='iexact')
    ativo = filters.BooleanFilter(field_name='ativo')
    tipo_solicitacao = filters.CharFilter(field_name='tipo_solicitacao',
                                          lookup_expr='iexact')
    data_inicial = filters.DateFilter(field_name='criado_em',
                                      lookup_expr='date__gte')
    data_final = filters.DateFilter(field_name='criado_em',
                                    lookup_expr='date__lte')
    classificacao = filters.ModelMultipleChoiceFilter(
        field_name='classificacao__id',
        to_field_name='id',
        queryset=ClassificacaoDieta.objects.all())
    status = filters.MultipleChoiceFilter(
        choices=[(str(state), state)
                 for state in DietaEspecialWorkflow.states])
Example #26
0
class AssociateFilter(filters.FilterSet):
    associate_name = filters.ModelMultipleChoiceFilter(
        queryset=Associate.objects.all(),
        field_name="associate__name",
        to_field_name="name",
    )
    associate_id = filters.ModelMultipleChoiceFilter(
        queryset=Associate.objects.all(),
        field_name="associate__id",
        to_field_name="id",
    )
    associate_slug = filters.ModelMultipleChoiceFilter(
        queryset=Associate.objects.all(),
        field_name="associate__slug",
        to_field_name="slug",
    )
Example #27
0
class EventFilter(filters.FilterSet):
    start_after = filters.DateFilter(field_name="start", lookup_expr="gte")
    start_before = filters.DateFilter(field_name="start", lookup_expr="lte")
    end_after = filters.DateFilter(field_name="end", lookup_expr="gte")
    end_before = filters.DateFilter(field_name="end", lookup_expr="lte")
    tags = filters.ModelMultipleChoiceFilter(
        field_name="tags__name",
        to_field_name="name",
        queryset=Tag.objects.all(),
        conjoined=True,
    )
    order_by = filters.OrderingFilter(fields=(
        "slug",
        "start",
        "end",
    ), )

    class Meta:
        model = Event
        fields = (
            "completed",
            "tags",
            "administrator",
            "host",
            "start",
            "start_before",
            "start_after",
            "end",
            "end_before",
            "end_after",
            "country",
        )
Example #28
0
class ProductionFilter(filters.FilterSet):
    title = filters.CharFilter(lookup_expr='iexact')
    platform = filters.ModelMultipleChoiceFilter(
        field_name='platforms', queryset=Platform.objects.all())
    released_before = filters.DateFilter(field_name='release_date_date',
                                         lookup_expr='lt',
                                         label="Released before")
    released_since = filters.DateFilter(field_name='release_date_date',
                                        lookup_expr='gte',
                                        label="Released since")
    added_before = filters.DateTimeFilter(field_name='created_at',
                                          lookup_expr='lt',
                                          label="Added before")
    added_since = filters.DateTimeFilter(field_name='created_at',
                                         lookup_expr='gte',
                                         label="Added since")
    updated_before = filters.DateTimeFilter(field_name='updated_at',
                                            lookup_expr='lt',
                                            label="Updated before")
    updated_since = filters.DateTimeFilter(field_name='updated_at',
                                           lookup_expr='gte',
                                           label="Updated since")
    author = filters.NumberFilter(method='filter_author', label="Author ID")

    def filter_author(self, queryset, name, value):
        return queryset.filter(
            Q(author_nicks__releaser_id=value)
            | Q(author_affiliation_nicks__releaser_id=value))

    class Meta:
        model = Production
        fields = ['supertype']
Example #29
0
class StelleListFilter(django_filters.FilterSet):
    legacy_id = django_filters.CharFilter(
        lookup_expr='icontains',
        help_text=Stelle._meta.get_field('legacy_id').help_text,
        label=Stelle._meta.get_field('legacy_id').verbose_name)
    text = django_filters.ModelMultipleChoiceFilter(
        queryset=Text.objects.all(),
        help_text=Stelle._meta.get_field('text').help_text,
        label=Stelle._meta.get_field('text').verbose_name,
        widget=autocomplete.Select2Multiple(
            url="archiv-ac:text-autocomplete", ))
    summary = django_filters.LookupChoiceFilter(
        lookup_choices=CHAR_LOOKUP_CHOICES,
        help_text=Stelle._meta.get_field('summary').help_text,
        label=Stelle._meta.get_field('summary').verbose_name)
    zitat = django_filters.LookupChoiceFilter(
        lookup_choices=CHAR_LOOKUP_CHOICES,
        help_text=Stelle._meta.get_field('zitat').help_text,
        label=Stelle._meta.get_field('zitat').verbose_name)
    translation = django_filters.LookupChoiceFilter(
        lookup_choices=CHAR_LOOKUP_CHOICES,
        help_text=Stelle._meta.get_field('translation').help_text,
        label=Stelle._meta.get_field('translation').verbose_name)
    key_word = django_filters.ModelMultipleChoiceFilter(
        queryset=KeyWord.objects.all(),
        help_text=Stelle._meta.get_field('key_word').help_text,
        label=Stelle._meta.get_field('key_word').verbose_name,
        widget=autocomplete.Select2Multiple(
            url="archiv-ac:keyword-autocomplete", ))
    use_case = django_filters.ModelMultipleChoiceFilter(
        queryset=UseCase.objects.all(),
        help_text="Related UseCase",
        label="UseCase",
        widget=autocomplete.Select2Multiple(
            url="archiv-ac:usecase-autocomplete", ))
    kommentar = django_filters.LookupChoiceFilter(
        lookup_choices=CHAR_LOOKUP_CHOICES,
        help_text=Stelle._meta.get_field('kommentar').help_text,
        label=Stelle._meta.get_field('kommentar').verbose_name)

    class Meta:
        model = Stelle
        fields = [
            'id', 'legacy_id', 'legacy_pk', 'text', 'summary', 'zitat',
            'translation', 'key_word', 'kommentar', 'use_case'
        ]
Example #30
0
class DoctorFilter(filters.FilterSet):
    search = filters.CharFilter(field_name="name", lookup_expr='icontains')
    specialty = filters.ModelMultipleChoiceFilter(
        queryset=Specialty.objects.all())

    class Meta:
        model = Doctor
        fields = ['search', 'specialty']