Skip to content

Commit

Permalink
feat(api): Add back url to metadata
Browse files Browse the repository at this point in the history
ref: #410 #411
  • Loading branch information
jon-nfc committed Nov 30, 2024
1 parent e4ce1b5 commit 4ae9656
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/api/react_ui_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()})
Expand Down
19 changes: 19 additions & 0 deletions app/api/viewsets/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<protocol>://<doman name>.<tld>/api/<API version>/<model url>`
"""

return None


def get_model_documentation(self):

Expand Down

0 comments on commit 4ae9656

Please sign in to comment.