Skip to content

Commit

Permalink
serialize external_service_name for ExternalService
Browse files Browse the repository at this point in the history
  • Loading branch information
adlius committed Dec 10, 2024
1 parent f50bd1b commit 23174d6
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion addon_service/configured_addon/citation/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions addon_service/external_service/citation/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ class Meta:
"url",
"configurable_api_root",
"wb_key",
"external_service_name",
]
5 changes: 5 additions & 0 deletions addon_service/external_service/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions addon_service/external_service/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
Expand All @@ -39,4 +41,5 @@ class Meta:
"display_name",
"url",
"wb_key",
"external_service_name",
]
1 change: 1 addition & 0 deletions addon_service/external_service/storage/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class Meta:
"display_name",
"url",
"wb_key",
"external_service_name",
"configurable_api_root",
"supported_features",
]

0 comments on commit 23174d6

Please sign in to comment.