feat(api): Added ability to specify table fields within the viewset.

required for models that are external to centurion

ref: #248 #360
This commit is contained in:
2024-10-24 13:32:07 +09:30
parent 00c2826d9a
commit 20dc72d564
2 changed files with 26 additions and 2 deletions

View File

@ -68,6 +68,13 @@ class CommonViewSet(
_Mandatory_, Permission check class
"""
table_fields: list = []
""" Table layout list
_Optional_, used by metadata for the table fields and added to the HTTP/Options
method for detail view, Enables the UI can setup the table.
"""
view_description: str = None
view_name: str = None
@ -105,6 +112,23 @@ class CommonViewSet(
return self.page_layout
def get_table_fields(self):
if len(self.table_fields) < 1:
if hasattr(self, 'model'):
if hasattr(self.model, 'table_fields'):
self.table_fields = self.model.table_fields
else:
self.table_fields = []
return self.table_fields
def get_view_description(self, html=False) -> str:
if not self.view_description: