feat(api): Add return_url to metadata

ref: #410 #411
This commit is contained in:
2024-11-30 13:57:31 +09:30
parent cee396da3f
commit e4ce1b539e
2 changed files with 24 additions and 0 deletions

View File

@ -90,6 +90,10 @@ class ReactUIMetadata(OverRideJSONAPIMetadata):
metadata['urls'].update({'self': url_self})
if view.get_return_url():
metadata['urls'].update({'return_url': view.get_return_url()})
metadata["renders"] = [
renderer.media_type for renderer in view.renderer_classes

View File

@ -115,6 +115,26 @@ class CommonViewSet(
return self.page_layout
def get_return_url(self) -> str:
"""Metadata return URL
This URL is an optional URL that if required the view must
override this method. If the URL for a cancel operation
is not the models URL, then this method is used to return
the URL that will be used.
Defining this URL will predominatly be for sub-models. It's
recommended that the `reverse` function
(rest_framework.reverse.reverse) be used with a `request`
object.
Returns:
str: Full url in format `<protocol>://<doman name>.<tld>/api/<API version>/<model url>`
"""
return None
def get_table_fields(self):
if len(self.table_fields) < 1: