From 23174d617e614e5631b40def3e6436fa69474c32 Mon Sep 17 00:00:00 2001 From: Yuhuai Liu Date: Tue, 10 Dec 2024 09:33:44 -0500 Subject: [PATCH] serialize external_service_name for ExternalService --- addon_service/configured_addon/citation/serializers.py | 2 +- addon_service/external_service/citation/serializers.py | 1 + addon_service/external_service/models.py | 5 +++++ addon_service/external_service/serializers.py | 3 +++ addon_service/external_service/storage/serializers.py | 1 + 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/addon_service/configured_addon/citation/serializers.py b/addon_service/configured_addon/citation/serializers.py index 83484a38..aa1a5e77 100644 --- a/addon_service/configured_addon/citation/serializers.py +++ b/addon_service/configured_addon/citation/serializers.py @@ -37,7 +37,7 @@ class ConfiguredCitationAddonSerializer(ConfiguredAddonSerializer): many=False, read_only=True, model=ExternalCitationService, - source="base_account.external_service.externalstorageservice", + source="base_account.external_service.externalcitationservice", related_link_view_name=view_names.related_view(RESOURCE_TYPE), ) authorized_resource = ResourceRelatedField( diff --git a/addon_service/external_service/citation/serializers.py b/addon_service/external_service/citation/serializers.py index f174f9eb..fcd7a983 100644 --- a/addon_service/external_service/citation/serializers.py +++ b/addon_service/external_service/citation/serializers.py @@ -33,4 +33,5 @@ class Meta: "url", "configurable_api_root", "wb_key", + "external_service_name", ] diff --git a/addon_service/external_service/models.py b/addon_service/external_service/models.py index 1af8106d..f554f2cc 100644 --- a/addon_service/external_service/models.py +++ b/addon_service/external_service/models.py @@ -80,6 +80,11 @@ def service_type(self): def configurable_api_root(self): return ServiceTypes.HOSTED in self.service_type + @property + def external_service_name(self): + number = self.int_addon_imp + return known_imps.AddonImpNumbers(number).name.lower() + def clean_fields(self, *args, **kwargs): super().clean_fields(*args, **kwargs) if not self.configurable_api_root and not self.api_base_url: diff --git a/addon_service/external_service/serializers.py b/addon_service/external_service/serializers.py index 14097f60..f5859e22 100644 --- a/addon_service/external_service/serializers.py +++ b/addon_service/external_service/serializers.py @@ -23,6 +23,8 @@ def __init__(self, *args, **kwargs): read_only=True, ) + external_service_name = serializers.CharField(read_only=True) + included_serializers = { "addon_imp": "addon_service.serializers.AddonImpSerializer", } @@ -39,4 +41,5 @@ class Meta: "display_name", "url", "wb_key", + "external_service_name", ] diff --git a/addon_service/external_service/storage/serializers.py b/addon_service/external_service/storage/serializers.py index 5b0115b8..9bb411fc 100644 --- a/addon_service/external_service/storage/serializers.py +++ b/addon_service/external_service/storage/serializers.py @@ -41,6 +41,7 @@ class Meta: "display_name", "url", "wb_key", + "external_service_name", "configurable_api_root", "supported_features", ]