From aa846e9406a89b6f1a6df4893a64f279834f3061 Mon Sep 17 00:00:00 2001 From: jamesstottmoj Date: Mon, 19 Feb 2024 12:51:05 +0000 Subject: [PATCH 1/4] Changed code to allow for new tool, vscode, to be displayed on the tools page --- controlpanel/api/models/tool.py | 4 +++- controlpanel/frontend/forms.py | 2 ++ controlpanel/frontend/jinja2/release-create.html | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/controlpanel/api/models/tool.py b/controlpanel/api/models/tool.py index aea233002..ee1f7a836 100644 --- a/controlpanel/api/models/tool.py +++ b/controlpanel/api/models/tool.py @@ -22,7 +22,9 @@ class Tool(TimeStampedModel): # Defines how a matching chart name is put into a named tool bucket. # E.g. jupyter-* charts all end up in the jupyter-lab bucket. # chart name match: tool bucket - TOOL_BOX_CHART_LOOKUP = {"jupyter": "jupyter-lab", "rstudio": "rstudio"} + TOOL_BOX_CHART_LOOKUP = {"jupyter": "jupyter-lab", + "rstudio": "rstudio", + "vscode": "vscode"} description = models.TextField(blank=True) chart_name = models.CharField(max_length=100, blank=False) diff --git a/controlpanel/frontend/forms.py b/controlpanel/frontend/forms.py index 982c37d87..ef1b78768 100644 --- a/controlpanel/frontend/forms.py +++ b/controlpanel/frontend/forms.py @@ -456,6 +456,7 @@ def clean_chart_name(self): "airflow-sqlite", "jupyter-", "rstudio", + "vscode" ] value = self.cleaned_data["chart_name"] is_valid = False @@ -478,6 +479,7 @@ def clean_tool_domain(self): "airflow-sqlite", "jupyter-lab", "rstudio", + "vscode" ] value = self.cleaned_data.get("tool_domain") if value and value not in valid_names: diff --git a/controlpanel/frontend/jinja2/release-create.html b/controlpanel/frontend/jinja2/release-create.html index 33d4cbc72..770b3f726 100644 --- a/controlpanel/frontend/jinja2/release-create.html +++ b/controlpanel/frontend/jinja2/release-create.html @@ -45,7 +45,7 @@

{{ page_title }}

}, "classes": "govuk-!-width-two-thirds", "hint": { - "text": 'Helm chart name. Use only variations of: airflow-sqlite, jupyter-* or rstudio' + "text": 'Helm chart name. Use only variations of: airflow-sqlite, jupyter-*, rstudio or vscode' }, "name": "chart_name", "attributes": { @@ -95,7 +95,7 @@

{{ page_title }}

}, "classes": "govuk-!-width-two-thirds", "hint": { - "text": 'If the chart name is non-standard, use this value in the domain name for the tool. Use only one of: airflow-sqlite, jupyter-lab or rstudio.' + "text": 'If the chart name is non-standard, use this value in the domain name for the tool. Use only one of: airflow-sqlite, jupyter-lab, rstudio or vscode.' }, "name": "tool_domain", "attributes": { From 5931fff97f17608fd61a26952624f2299a1d02ae Mon Sep 17 00:00:00 2001 From: jamesstottmoj Date: Mon, 19 Feb 2024 13:55:18 +0000 Subject: [PATCH 2/4] modified unit tests to cover vscode tooling --- tests/frontend/test_forms.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/frontend/test_forms.py b/tests/frontend/test_forms.py index 8473182a8..c4924bc1c 100644 --- a/tests/frontend/test_forms.py +++ b/tests/frontend/test_forms.py @@ -54,6 +54,15 @@ def test_tool_release_form_check_release_name(): } f = forms.ToolReleaseForm(data) assert f.is_valid() + data = { + "name": "Test Release", + "chart_name": "vscode", + "version": "1.2.3", + "values": {"foo": "bar"}, + "is_restricted": False, + } + f = forms.ToolReleaseForm(data) + assert f.is_valid() data = { "name": "Test Release", "chart_name": "invalid-chartname", @@ -90,6 +99,16 @@ def test_tool_release_form_check_tool_domain(): } f = forms.ToolReleaseForm(data) assert f.is_valid() + data = { + "name": "Test Release", + "chart_name": "vscode", + "version": "1.2.3", + "values": {"foo": "bar"}, + "is_restricted": False, + "tool_domain": "vscode", + } + f = forms.ToolReleaseForm(data) + assert f.is_valid() data = { "name": "Test Release", "chart_name": "jupyter-lab-all-spark", From 8f43765dfb88315d3d00433be96310783ef7e1d7 Mon Sep 17 00:00:00 2001 From: jamesstottmoj Date: Tue, 20 Feb 2024 09:17:13 +0000 Subject: [PATCH 3/4] added missing references to vscode --- controlpanel/frontend/jinja2/release-detail.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/controlpanel/frontend/jinja2/release-detail.html b/controlpanel/frontend/jinja2/release-detail.html index 9cd9a58b0..7c73873c3 100644 --- a/controlpanel/frontend/jinja2/release-detail.html +++ b/controlpanel/frontend/jinja2/release-detail.html @@ -48,7 +48,7 @@

{{ page_title }}

}, "classes": "govuk-!-width-two-thirds", "hint": { - "text": 'Helm chart name. Use only variations of: airflow-sqlite, jupyter-* or rstudio' + "text": 'Helm chart name. Use only variations of: airflow-sqlite, jupyter-*, rstudio or vscode' }, "name": "chart_name", "attributes": { @@ -98,7 +98,7 @@

{{ page_title }}

}, "classes": "govuk-!-width-two-thirds", "hint": { - "text": 'If the chart name is non-standard, use this value in the domain name for the tool. Use only one of: airflow-sqlite, jupyter-lab or rstudio.' + "text": 'If the chart name is non-standard, use this value in the domain name for the tool. Use only one of: airflow-sqlite, jupyter-lab, rstudio or vscode.' }, "name": "tool_domain", "attributes": { @@ -153,7 +153,7 @@

{{ page_title }}

{{ csrf_input }} From 479410390ed1cf518f57c60bee3973fe017c1488 Mon Sep 17 00:00:00 2001 From: jamesstottmoj Date: Mon, 26 Feb 2024 15:53:46 +0000 Subject: [PATCH 4/4] updated references of vscode to visual-studio-code --- controlpanel/api/models/tool.py | 2 +- controlpanel/frontend/forms.py | 4 ++-- controlpanel/frontend/jinja2/release-create.html | 4 ++-- controlpanel/frontend/jinja2/release-detail.html | 4 ++-- tests/frontend/test_forms.py | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/controlpanel/api/models/tool.py b/controlpanel/api/models/tool.py index ee1f7a836..32243f1e1 100644 --- a/controlpanel/api/models/tool.py +++ b/controlpanel/api/models/tool.py @@ -24,7 +24,7 @@ class Tool(TimeStampedModel): # chart name match: tool bucket TOOL_BOX_CHART_LOOKUP = {"jupyter": "jupyter-lab", "rstudio": "rstudio", - "vscode": "vscode"} + "visual-studio-code": "visual-studio-code"} description = models.TextField(blank=True) chart_name = models.CharField(max_length=100, blank=False) diff --git a/controlpanel/frontend/forms.py b/controlpanel/frontend/forms.py index ea4a249a0..017ea538d 100644 --- a/controlpanel/frontend/forms.py +++ b/controlpanel/frontend/forms.py @@ -470,7 +470,7 @@ def clean_chart_name(self): "airflow-sqlite", "jupyter-", "rstudio", - "vscode" + "visual-studio-code" ] value = self.cleaned_data["chart_name"] is_valid = False @@ -493,7 +493,7 @@ def clean_tool_domain(self): "airflow-sqlite", "jupyter-lab", "rstudio", - "vscode" + "visual-studio-code" ] value = self.cleaned_data.get("tool_domain") if value and value not in valid_names: diff --git a/controlpanel/frontend/jinja2/release-create.html b/controlpanel/frontend/jinja2/release-create.html index 770b3f726..42f10e8f0 100644 --- a/controlpanel/frontend/jinja2/release-create.html +++ b/controlpanel/frontend/jinja2/release-create.html @@ -45,7 +45,7 @@

{{ page_title }}

}, "classes": "govuk-!-width-two-thirds", "hint": { - "text": 'Helm chart name. Use only variations of: airflow-sqlite, jupyter-*, rstudio or vscode' + "text": 'Helm chart name. Use only variations of: airflow-sqlite, jupyter-*, rstudio or visual-studio-code' }, "name": "chart_name", "attributes": { @@ -95,7 +95,7 @@

{{ page_title }}

}, "classes": "govuk-!-width-two-thirds", "hint": { - "text": 'If the chart name is non-standard, use this value in the domain name for the tool. Use only one of: airflow-sqlite, jupyter-lab, rstudio or vscode.' + "text": 'If the chart name is non-standard, use this value in the domain name for the tool. Use only one of: airflow-sqlite, jupyter-lab, rstudio or visual-studio-code.' }, "name": "tool_domain", "attributes": { diff --git a/controlpanel/frontend/jinja2/release-detail.html b/controlpanel/frontend/jinja2/release-detail.html index 7c73873c3..c9b497ceb 100644 --- a/controlpanel/frontend/jinja2/release-detail.html +++ b/controlpanel/frontend/jinja2/release-detail.html @@ -48,7 +48,7 @@

{{ page_title }}

}, "classes": "govuk-!-width-two-thirds", "hint": { - "text": 'Helm chart name. Use only variations of: airflow-sqlite, jupyter-*, rstudio or vscode' + "text": 'Helm chart name. Use only variations of: airflow-sqlite, jupyter-*, rstudio or visual-studio-code' }, "name": "chart_name", "attributes": { @@ -98,7 +98,7 @@

{{ page_title }}

}, "classes": "govuk-!-width-two-thirds", "hint": { - "text": 'If the chart name is non-standard, use this value in the domain name for the tool. Use only one of: airflow-sqlite, jupyter-lab, rstudio or vscode.' + "text": 'If the chart name is non-standard, use this value in the domain name for the tool. Use only one of: airflow-sqlite, jupyter-lab, rstudio or visual-studio-code.' }, "name": "tool_domain", "attributes": { diff --git a/tests/frontend/test_forms.py b/tests/frontend/test_forms.py index 755becbd9..bc3cfcec8 100644 --- a/tests/frontend/test_forms.py +++ b/tests/frontend/test_forms.py @@ -57,7 +57,7 @@ def test_tool_release_form_check_release_name(): assert f.is_valid() data = { "name": "Test Release", - "chart_name": "vscode", + "chart_name": "visual-studio-code", "version": "1.2.3", "values": {"foo": "bar"}, "is_restricted": False, @@ -102,11 +102,11 @@ def test_tool_release_form_check_tool_domain(): assert f.is_valid() data = { "name": "Test Release", - "chart_name": "vscode", + "chart_name": "visual-studio-code", "version": "1.2.3", "values": {"foo": "bar"}, "is_restricted": False, - "tool_domain": "vscode", + "tool_domain": "visual-studio-code", } f = forms.ToolReleaseForm(data) assert f.is_valid()