From 6d966fddf8b7ef74fc2c0959b81736e9225fac14 Mon Sep 17 00:00:00 2001 From: Matthew John Date: Fri, 2 Aug 2024 06:36:46 +0100 Subject: [PATCH] fix: Fix use of ListView, which was removed in main, with new TerraformVersionListView --- terrarun/api_entities/terraform_version.py | 6 ++++++ terrarun/server/routes/admin_terraform_versions.py | 14 ++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/terrarun/api_entities/terraform_version.py b/terrarun/api_entities/terraform_version.py index 1514669..db5b4fa 100644 --- a/terrarun/api_entities/terraform_version.py +++ b/terrarun/api_entities/terraform_version.py @@ -15,6 +15,7 @@ AttributeModifier, BaseEntity, EntityView, + ListEntityView, ) @@ -103,3 +104,8 @@ class TerraformVersionView(TerraformVersionEntity, EntityView): """View for terraform-version""" pass + + +class TerraformVersionListView(ListEntityView): + + ENTITY_CLASS = TerraformVersionView diff --git a/terrarun/server/routes/admin_terraform_versions.py b/terrarun/server/routes/admin_terraform_versions.py index 9fb170f..f1361b8 100644 --- a/terrarun/server/routes/admin_terraform_versions.py +++ b/terrarun/server/routes/admin_terraform_versions.py @@ -4,11 +4,11 @@ from flask import request -from terrarun.api_entities.base_entity import ListView from terrarun.api_entities.terraform_version import ( TerraformVersionCreateEntity, TerraformVersionUpdateEntity, TerraformVersionView, + TerraformVersionListView, ) from terrarun.errors import ( ApiError, @@ -92,13 +92,11 @@ def _get(self, current_user, current_job): version=version, version_exact=version_exact, ) - views = [ - TerraformVersionView.from_object( - tool, effective_user=current_user - ) - for tool in tool_list - ] - return ListView(views=views).to_response() + view = TerraformVersionListView.from_object( + obj=tool_list, + effective_user=current_user + ) + return view.to_response() def check_permissions_post(self, current_user, current_job): """Can only be access by site admins"""