diff --git a/app/api/react_ui_metadata.py b/app/api/react_ui_metadata.py index b021da447..2ea73030d 100644 --- a/app/api/react_ui_metadata.py +++ b/app/api/react_ui_metadata.py @@ -90,6 +90,10 @@ def determine_metadata(self, request, view): metadata['urls'].update({'self': url_self}) + if view.get_back_url(): + + metadata['urls'].update({'back': view.get_back_url()}) + if view.get_return_url(): metadata['urls'].update({'return_url': view.get_return_url()}) diff --git a/app/api/viewsets/common.py b/app/api/viewsets/common.py index 71b8eb7f9..c549f59eb 100644 --- a/app/api/viewsets/common.py +++ b/app/api/viewsets/common.py @@ -82,6 +82,25 @@ def allowed_methods(self): view_name: str = None + def get_back_url(self) -> str: + """Metadata Back URL + + This URL is an optional URL that if required the view must + override this method. If the URL for a back 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 `://./api//` + """ + + return None + def get_model_documentation(self):