Skip to content

Commit

Permalink
fix: readd exclude list of fields in detail view and allow customization
Browse files Browse the repository at this point in the history
This excludes fields that are part of TempEntityClass - in the long run,
this can be removed. But given that there are still projects using
TempEntityClass, this is a temporary workaround
It also introduces a setting to add additional fields per entity.
  • Loading branch information
b1rger committed Oct 18, 2023
1 parent 05e8ad9 commit 0bd2446
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
24 changes: 21 additions & 3 deletions apis_core/apis_entities/detail_generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,28 @@ def get(self, request, *args, **kwargs):
no_merge_labels = []

relevant_fields = []
# those are fields from TempEntityClass, this exclude list can be removed once TempEntityClass is dropped
exclude_fields = [
"start_date",
"start_start_date",
"start_end_date",
"end_date",
"end_start_date",
"end_end_date",
"tempentityclass_ptr",
"rootobject_ptr",
"collection",
]
entity_settings = get_entity_settings_by_modelname(self.entity)
exclude_fields.extend(entity_settings.get("detail_view_exclude", []))
for field in model_to_dict(self.instance).keys():
relevant_fields.append(
(self.instance._meta.get_field(field), getattr(self.instance, field))
)
if field not in exclude_fields:
relevant_fields.append(
(
self.instance._meta.get_field(field),
getattr(self.instance, field),
)
)

return HttpResponse(
template.render(
Expand Down
2 changes: 2 additions & 0 deletions docs/source/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ APIS_ENTITIES
},
},
"list_filters_exclude": ["lat", "lng", "status"],
"detail_view_exclude": ["notes", "references"],
},}
``APIS_ENTITIES`` is the setting to define the behavior of the entities list views. Every entity has its own setting.
Expand All @@ -202,6 +203,7 @@ allows to merge several entities in one target entity at once.
``table_fields`` sets the default columns to show in the list views.
``additional_cols`` allows to set the columns that user can add to the result view.
``relations_per_page`` allows to set the number of relations listed before pagination begins
``detail_view_exclude`` allows to set fields that are excluded from the default detail view

``list_filters``
^^^^^^^^^^^^^^^^
Expand Down

0 comments on commit 0bd2446

Please sign in to comment.