Skip to content

Commit

Permalink
Moved code to clean method in form. Enabled in dev for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesstottmoj committed Nov 28, 2024
1 parent c3da923 commit a741d3b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
9 changes: 9 additions & 0 deletions controlpanel/frontend/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,15 @@ def clean(self):
if connect_data_source == "existing" and not existing_datasource:
self.add_error("existing_datasource_id", "This field is required.")

assume_role = cleaned_data.get("allow_cloud_platform_assume_role")
role_arn = cleaned_data.get("cloud_platform_role_arn")

if assume_role and not role_arn:
self.add_error("cloud_platform_role_arn", "Role ARN is required")

if not assume_role and role_arn:
cleaned_data.pop("cloud_platform_role_arn")

return cleaned_data

def clean_repo_url(self):
Expand Down
9 changes: 0 additions & 9 deletions controlpanel/frontend/views/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,6 @@ def get_success_url(self):

def form_valid(self, form):
try:
assume_role = form.cleaned_data.get("allow_cloud_platform_assume_role")
role_arn = form.cleaned_data.get("cloud_platform_role_arn")
if assume_role and not role_arn:
form.add_error("cloud_platform_role_arn", "Role ARN is required")
return FormMixin.form_invalid(self, form)

if not assume_role and role_arn:
form.cleaned_data.pop("cloud_platform_role_arn")

self.object = AppManager().register_app(self.request.user, form.cleaned_data)
except Exception as ex:
form.add_error("repo_url", str(ex))
Expand Down
2 changes: 1 addition & 1 deletion settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ enabled_features:
_HOST_prod: true
cloud_platform_assume_role:
_DEFAULT: false
_HOST_dev: false
_HOST_dev: true
_HOST_prod: false
_HOST_alpha: false

Expand Down

0 comments on commit a741d3b

Please sign in to comment.