From c9bfbfda411bc6c3eac19425920e81c0bcf1a8e0 Mon Sep 17 00:00:00 2001 From: Chandrasekharan M <117059509+chandrasekharan-zipstack@users.noreply.github.com> Date: Fri, 20 Sep 2024 14:26:12 +0530 Subject: [PATCH] fix: Deprecated django tenant schema function replaced (#647) Replaced deprecated django tenant schema function --- backend/api/deployment_helper.py | 2 +- backend/api/models.py | 4 ++-- backend/api_v2/deployment_helper.py | 2 +- backend/pipeline/models.py | 2 +- backend/platform_settings/platform_auth_service.py | 4 ++-- backend/platform_settings/views.py | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/api/deployment_helper.py b/backend/api/deployment_helper.py index b1b9a521e..494eb002e 100644 --- a/backend/api/deployment_helper.py +++ b/backend/api/deployment_helper.py @@ -89,7 +89,7 @@ def construct_complete_endpoint(api_name: str) -> str: Returns: - str: The complete API endpoint URL. """ - org_schema = connection.get_tenant().schema_name + org_schema = connection.tenant.schema_name return f"{ApiExecution.PATH}/{org_schema}/{api_name}/" @staticmethod diff --git a/backend/api/models.py b/backend/api/models.py index 2119ff85b..a6f417fef 100644 --- a/backend/api/models.py +++ b/backend/api/models.py @@ -87,12 +87,12 @@ def save(self, *args: Any, **kwargs: Any) -> None: try: original = APIDeployment.objects.get(pk=self.pk) if original.api_name != self.api_name: - org_schema = connection.get_tenant().schema_name + org_schema = connection.tenant.schema_name self.api_endpoint = ( f"{ApiExecution.PATH}/{org_schema}/{self.api_name}/" ) except APIDeployment.DoesNotExist: - org_schema = connection.get_tenant().schema_name + org_schema = connection.tenant.schema_name self.api_endpoint = f"{ApiExecution.PATH}/{org_schema}/{self.api_name}/" super().save(*args, **kwargs) diff --git a/backend/api_v2/deployment_helper.py b/backend/api_v2/deployment_helper.py index e94c84e46..4c6d1698b 100644 --- a/backend/api_v2/deployment_helper.py +++ b/backend/api_v2/deployment_helper.py @@ -134,7 +134,7 @@ def construct_complete_endpoint(api_name: str) -> str: Returns: - str: The complete API endpoint URL. """ - org_schema = connection.get_tenant().schema_name + org_schema = connection.tenant.schema_name return f"{ApiExecution.PATH}/{org_schema}/{api_name}/" @staticmethod diff --git a/backend/pipeline/models.py b/backend/pipeline/models.py index 8860d027a..bf0dc5494 100644 --- a/backend/pipeline/models.py +++ b/backend/pipeline/models.py @@ -91,7 +91,7 @@ def api_key_data(self): @property def api_endpoint(self): - org_schema = connection.get_tenant().schema_name + org_schema = connection.tenant.schema_name deployment_endpoint = settings.API_DEPLOYMENT_PATH_PREFIX + "/pipeline/api" api_endpoint = f"{deployment_endpoint}/{org_schema}/{self.id}/" return api_endpoint diff --git a/backend/platform_settings/platform_auth_service.py b/backend/platform_settings/platform_auth_service.py index 054291ba8..318c23591 100644 --- a/backend/platform_settings/platform_auth_service.py +++ b/backend/platform_settings/platform_auth_service.py @@ -155,7 +155,7 @@ def toggle_platform_key_status( error: IntegrityError """ try: - organization = connection.get_tenant() + organization = connection.tenant platform_key.modified_by = user if action == PlatformServiceConstants.ACTIVATE: active_keys: list[PlatformKey] = PlatformKey.objects.filter( @@ -193,7 +193,7 @@ def list_platform_key_ids() -> list[PlatformKey]: Any: List of platform keys. """ try: - organization_id = connection.get_tenant().id + organization_id = connection.tenant.id platform_keys: list[PlatformKey] = PlatformKey.objects.filter( organization=organization_id ) diff --git a/backend/platform_settings/views.py b/backend/platform_settings/views.py index 6b4c918fa..8745eafd1 100644 --- a/backend/platform_settings/views.py +++ b/backend/platform_settings/views.py @@ -109,7 +109,7 @@ def create(self, request: Request) -> Response: is_active = request.data.get(PlatformServiceConstants.IS_ACTIVE) key_name = request.data.get(PlatformServiceConstants.KEY_NAME) - organization: Organization = connection.get_tenant() + organization: Organization = connection.tenant PlatformAuthHelper.validate_token_count(organization=organization)