From 8ec874f53adaea11b128d4495fc31a7fb8cdb8bf Mon Sep 17 00:00:00 2001 From: Nathan Swain Date: Fri, 5 Jan 2024 15:45:52 -0700 Subject: [PATCH] Return custom settings with app API requests --- tethys_portal/views/api.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tethys_portal/views/api.py b/tethys_portal/views/api.py index 8f9feae4d..4af1f98ae 100644 --- a/tethys_portal/views/api.py +++ b/tethys_portal/views/api.py @@ -44,6 +44,16 @@ def get_app(request, app): except TethysApp.DoesNotExist: return JsonResponse({"error": f'Could not find app "{app}".'}) + custom_settings = {} + if request.user.is_authenticated: + custom_settings = { + s.name: { + "type": s.type, + "value": s.get_value(), + } + for s in app.custom_settings + } + metadata = { "title": app.name, "description": app.description, @@ -55,5 +65,6 @@ def get_app(request, app): "exitUrl": reverse("app_library"), "rootUrl": reverse(app.index_url), "settingsUrl": f'{reverse("admin:index")}tethys_apps/tethysapp/{ app.id }/change/', + "customSettings": custom_settings, } return JsonResponse(metadata)