From 9f4203128a60b4b58637f02baa3916587ecc2767 Mon Sep 17 00:00:00 2001 From: Michael Collins <15347726+michaeljcollinsuk@users.noreply.github.com> Date: Fri, 3 Jan 2025 17:26:30 +0000 Subject: [PATCH] Update tool deployment field name --- controlpanel/api/views/tool_deployments.py | 2 +- controlpanel/frontend/forms.py | 8 ++++---- controlpanel/frontend/jinja2/tool-list.html | 4 ++-- .../static/javascripts/modules/tool-status.js | 12 ++++++------ 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/controlpanel/api/views/tool_deployments.py b/controlpanel/api/views/tool_deployments.py index b6207879..94712c4c 100644 --- a/controlpanel/api/views/tool_deployments.py +++ b/controlpanel/api/views/tool_deployments.py @@ -29,7 +29,7 @@ def _deploy(self): ) def post(self, request, *args, **kwargs): - self.serializer = self.get_serializer(data={"tool": request.data.get("version")}) + self.serializer = self.get_serializer(data=request.data) self.serializer.is_valid(raise_exception=True) tool_action = self.kwargs["action"] diff --git a/controlpanel/frontend/forms.py b/controlpanel/frontend/forms.py index 17a6c4e2..b2a3db71 100644 --- a/controlpanel/frontend/forms.py +++ b/controlpanel/frontend/forms.py @@ -682,7 +682,7 @@ def create_option(self, name, value, label, selected, index, subindex=None, attr class ToolForm(forms.Form): - version = forms.ModelChoiceField( + tool = forms.ModelChoiceField( queryset=Tool.objects.none(), empty_label=None, widget=ToolChoice(attrs={"class": "govuk-select govuk-!-width-full govuk-!-font-size-16"}), @@ -693,12 +693,12 @@ def __init__(self, *args, **kwargs): self.tool_type = kwargs.pop("tool_type") self.deployment = kwargs.pop("deployment", None) super().__init__(*args, **kwargs) - self.fields["version"].queryset = self.get_tool_release_choices(tool_type=self.tool_type) - self.fields["version"].widget.attrs.update( + self.fields["tool"].queryset = self.get_tool_release_choices(tool_type=self.tool_type) + self.fields["tool"].widget.attrs.update( {"data-action-target": self.tool_type, "id": f"tools-{self.tool_type}"} ) if self.deployment: - self.fields["version"].initial = self.deployment.tool + self.fields["tool"].initial = self.deployment.tool def get_tool_release_choices(self, tool_type: str): return Tool.objects.filter( diff --git a/controlpanel/frontend/jinja2/tool-list.html b/controlpanel/frontend/jinja2/tool-list.html index e5139362..0ff019ef 100644 --- a/controlpanel/frontend/jinja2/tool-list.html +++ b/controlpanel/frontend/jinja2/tool-list.html @@ -23,10 +23,10 @@