diff --git a/tests/apps/tethysapp-test_app/tethysapp/test_app/app.py b/tests/apps/tethysapp-test_app/tethysapp/test_app/app.py index 18ac405b6..a222b77e3 100644 --- a/tests/apps/tethysapp-test_app/tethysapp/test_app/app.py +++ b/tests/apps/tethysapp-test_app/tethysapp/test_app/app.py @@ -39,12 +39,14 @@ def custom_settings(self): name="default_name", type=CustomSetting.TYPE_STRING, description="Default model name.", + include_in_api=True, required=True, ), CustomSetting( name="max_count", type=CustomSetting.TYPE_INTEGER, description="Maximum allowed count in a method.", + include_in_api=False, required=False, ), CustomSetting( @@ -57,6 +59,7 @@ def custom_settings(self): name="enable_feature", type=CustomSetting.TYPE_BOOLEAN, description="Enable this feature when True.", + include_in_api=True, required=False, ), JSONCustomSetting( @@ -72,6 +75,7 @@ def custom_settings(self): JSONCustomSetting( name="JSON_setting_default_value_required", description="This is JSON setting with a default value", + include_in_api=True, required=True, default={"Test": "JSON test String"}, ), @@ -84,6 +88,7 @@ def custom_settings(self): SecretCustomSetting( name="Secret_Test_required", description="This is SECRET setting with required True", + include_in_api=True, required=True, ), SecretCustomSetting( diff --git a/tests/unit_tests/test_tethys_portal/test_views/test_api.py b/tests/unit_tests/test_tethys_portal/test_views/test_api.py index 54a40b873..860f01142 100644 --- a/tests/unit_tests/test_tethys_portal/test_views/test_api.py +++ b/tests/unit_tests/test_tethys_portal/test_views/test_api.py @@ -195,10 +195,13 @@ def test_get_app_authenticated(self): ) self.assertDictEqual( { - "change_factor": {"type": "FLOAT", "value": None}, + "JSON_setting_default_value_required": { + "type": "JSON", + "value": {"Test": "JSON test String"}, + }, + "Secret_Test_required": {"type": "SECRET", "value": None}, "default_name": {"type": "STRING", "value": None}, "enable_feature": {"type": "BOOLEAN", "value": None}, - "max_count": {"type": "INTEGER", "value": None}, }, json["customSettings"], ) diff --git a/tethys_apps/migrations/0005_customsettingbase_include_in_api.py b/tethys_apps/migrations/0005_customsettingbase_include_in_api.py index 75223d46b..c64a7e75b 100644 --- a/tethys_apps/migrations/0005_customsettingbase_include_in_api.py +++ b/tethys_apps/migrations/0005_customsettingbase_include_in_api.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('tethys_apps', '0004_rename_display_external_proxyapp_display_external_icon'), + ("tethys_apps", "0004_rename_display_external_proxyapp_display_external_icon"), ] operations = [ migrations.AddField( - model_name='customsettingbase', - name='include_in_api', + model_name="customsettingbase", + name="include_in_api", field=models.BooleanField(default=False), ), ] diff --git a/tethys_portal/views/api.py b/tethys_portal/views/api.py index 809b480be..9ab155315 100644 --- a/tethys_portal/views/api.py +++ b/tethys_portal/views/api.py @@ -63,7 +63,7 @@ def get_app(request, app): if request.user.is_authenticated: metadata["customSettings"] = dict() for s in app.custom_settings: - if s.type_custom_setting != "SIMPLE": + if not s.include_in_api: continue v = None @@ -73,7 +73,9 @@ def get_app(request, app): pass metadata["customSettings"][s.name] = { - "type": s.type, + "type": s.type + if s.type_custom_setting == "SIMPLE" + else s.type_custom_setting, "value": v, }