Skip to content

Commit

Permalink
columns exclude configuration for list views
Browse files Browse the repository at this point in the history
overriding ABSTRACT_ENTITY_COLUMNS_EXCLUDE for entities
  • Loading branch information
gythaogg committed Feb 19, 2025
1 parent 69e60ea commit 5f2cc66
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 13 deletions.
11 changes: 6 additions & 5 deletions apis_ontology/filtersets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
AbstractEntityFilterSet,
)
from apis_core.apis_entities.models import RootObject
from apis_core.generic.filtersets import GenericFilterSet
from apis_core.relations.filtersets import RelationFilterSet
from apis_core.relations.models import Relation
from django.apps import apps
Expand All @@ -13,6 +12,7 @@
from apis_ontology.forms import (
PersonSearchForm,
PlaceSearchForm,
RelationSearchForm,
WorkSearchForm,
)
from apis_ontology.models import Instance, Person, Place, Work
Expand Down Expand Up @@ -90,6 +90,7 @@ class Meta(AbstractEntityFilterSet.Meta):

class TibScholRelationMixinFilterSet(RelationFilterSet):
class Meta(RelationFilterSet.Meta):
form = RelationSearchForm
exclude = RelationFilterSet.Meta.exclude + ABSTRACT_ENTITY_FILTERS_EXCLUDE
filter_overrides = {
models.CharField: {
Expand Down Expand Up @@ -136,7 +137,7 @@ class Meta(AbstractEntityFilterSet.Meta):


class PlaceFilterSet(TibScholEntityMixinFilterSet):
class Meta:
class Meta(TibScholEntityMixinFilterSet.Meta):
exclude = [
*ABSTRACT_ENTITY_FILTERS_EXCLUDE,
"latitude",
Expand Down Expand Up @@ -177,7 +178,7 @@ def custom_name_search(self, queryset, name, value):


class PersonFilterSet(TibScholEntityMixinFilterSet):
class Meta:
class Meta(TibScholEntityMixinFilterSet.Meta):
exclude = [
*ABSTRACT_ENTITY_FILTERS_EXCLUDE,
"alternative_names",
Expand Down Expand Up @@ -216,7 +217,7 @@ def custom_name_search(self, queryset, name, value):


class WorkFilterSet(TibScholEntityMixinFilterSet):
class Meta:
class Meta(TibScholRelationMixinFilterSet.Meta):
exclude = [
*ABSTRACT_ENTITY_FILTERS_EXCLUDE,
"alternative_names",
Expand Down Expand Up @@ -256,7 +257,7 @@ def custom_name_search(self, queryset, name, value):


class InstanceFilterSet(TibScholEntityMixinFilterSet):
class Meta:
class Meta(TibScholEntityMixinFilterSet.Meta):
exclude = [
*ABSTRACT_ENTITY_FILTERS_EXCLUDE,
"alternative_names",
Expand Down
43 changes: 35 additions & 8 deletions apis_ontology/forms.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from apis_core.relations.models import Relation
from apis_core.apis_entities.filtersets import AbstractEntityFilterSetForm
from apis_core.generic.forms import GenericFilterSetForm, GenericModelForm
from apis_core.relations.forms import RelationForm
from django import forms
from apis_core.generic.forms import GenericFilterSetForm, GenericModelForm
from django.forms.models import ModelChoiceField
from django.apps import apps


class TibscholEntityForm(GenericModelForm):
Expand Down Expand Up @@ -92,7 +90,20 @@ class InstanceForm(TibscholEntityForm):
]


class PlaceSearchForm(GenericFilterSetForm):
class TibScholEntityMixinSearchForm(AbstractEntityFilterSetForm):
columns_exclude = [
"start_start_date",
"end_start_date",
"start_date",
"start_end_date",
"end_end_date",
"end_date",
"rootobject_ptr",
"self_contenttype",
]


class PlaceSearchForm(TibScholEntityMixinSearchForm):
field_order = [
"columns",
"label",
Expand All @@ -103,7 +114,7 @@ class PlaceSearchForm(GenericFilterSetForm):
]


class PersonSearchForm(GenericFilterSetForm):
class PersonSearchForm(TibScholEntityMixinSearchForm):
field_order = [
"columns",
"name",
Expand All @@ -117,7 +128,7 @@ class PersonSearchForm(GenericFilterSetForm):
]


class WorkSearchForm(GenericFilterSetForm):
class WorkSearchForm(TibScholEntityMixinSearchForm):
field_order = [
"columns",
"name",
Expand All @@ -131,7 +142,7 @@ class WorkSearchForm(GenericFilterSetForm):
]


class InstanceSearchForm(GenericFilterSetForm):
class InstanceSearchForm(TibScholEntityMixinSearchForm):
field_order = [
"columns",
"name",
Expand All @@ -152,3 +163,19 @@ class InstanceSearchForm(GenericFilterSetForm):
"comments",
"external_links",
]


class RelationSearchForm(GenericFilterSetForm):
columns_exclude = [
"subj_object_id",
"obj_object_id",
"subj_content_type",
"obj_content_type",
"start_date",
"end_date",
"start_start_date",
"start_end_date",
"end_start_date",
"end_end_date",
"relation_ptr",
]

0 comments on commit 5f2cc66

Please sign in to comment.