Skip to content

Commit

Permalink
Merge pull request #203 from opaduchak/feature/ENG-6831
Browse files Browse the repository at this point in the history
[ENG-6831] Fixed external_service_name to match wb_key
  • Loading branch information
adlius authored Jan 10, 2025
2 parents 010ec19 + c9adebe commit 0dab0fc
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
16 changes: 8 additions & 8 deletions addon_service/common/known_imps.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,18 @@ def get_imp_number(imp: type[AddonImp]) -> int:
class KnownAddonImps(enum.Enum):
"""Static mapping from API-facing name for an AddonImp to the Imp itself"""

BOX_DOT_COM = box_dot_com.BoxDotComStorageImp
BOX = box_dot_com.BoxDotComStorageImp
S3 = s3.S3StorageImp
ONEDRIVE = onedrive.OneDriveStorageImp
ZOTERO_ORG = zotero_org.ZoteroOrgCitationImp
GOOGLE_DRIVE = google_drive.GoogleDriveStorageImp
ZOTERO = zotero_org.ZoteroOrgCitationImp
GOOGLEDRIVE = google_drive.GoogleDriveStorageImp
FIGSHARE = figshare.FigshareStorageImp
MENDELEY = mendeley.MendeleyCitationImp
BITBUCKET = bitbucket.BitbucketStorageImp
DATAVERSE = dataverse.DataverseStorageImp
OWNCLOUD = owncloud.OwnCloudStorageImp

GIT_HUB = github.GitHubStorageImp
GITHUB = github.GitHubStorageImp
GITLAB = gitlab.GitlabStorageImp
DROPBOX = dropbox.DropboxStorageImp

Expand All @@ -95,11 +95,11 @@ class KnownAddonImps(enum.Enum):
class AddonImpNumbers(enum.Enum):
"""Static mapping from each AddonImp name to a unique integer (for database use)"""

BOX_DOT_COM = 1001
ZOTERO_ORG = 1002
BOX = 1001
ZOTERO = 1002
S3 = 1003
MENDELEY = 1004
GOOGLE_DRIVE = 1005
GOOGLEDRIVE = 1005
DROPBOX = 1006
FIGSHARE = 1007
ONEDRIVE = 1008
Expand All @@ -108,7 +108,7 @@ class AddonImpNumbers(enum.Enum):
GITLAB = 1011
BITBUCKET = 1012

GIT_HUB = 1013
GITHUB = 1013

BOA = 1020

Expand Down
6 changes: 0 additions & 6 deletions addon_service/configured_addon/citation/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.db import models

from addon_service.common.known_imps import AddonImpNumbers
from addon_service.configured_addon.models import ConfiguredAddon
from addon_toolkit.interfaces.citation import CitationConfig

Expand All @@ -20,8 +19,3 @@ class JSONAPIMeta:
@property
def config(self) -> CitationConfig:
return self.base_account.authorizedcitationaccount.config

@property
def external_service_name(self):
number = self.base_account.external_service.int_addon_imp
return AddonImpNumbers(number).name.lower()
1 change: 1 addition & 0 deletions addon_service/configured_addon/computing/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,5 @@ class Meta:
"external_service_name",
"external_computing_service",
"current_user_is_owner",
"external_service_name",
]
6 changes: 6 additions & 0 deletions addon_service/configured_addon/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from addon_service.addon_operation.models import AddonOperationModel
from addon_service.common.base_model import AddonsServiceBaseModel
from addon_service.common.known_imps import AddonImpNumbers
from addon_service.common.validators import validate_addon_capability
from addon_toolkit import (
AddonCapabilities,
Expand Down Expand Up @@ -108,6 +109,11 @@ def external_service(self):
def imp_cls(self) -> type[AddonImp]:
return self.base_account.imp_cls

@property
def external_service_name(self):
number = self.base_account.external_service.int_addon_imp
return AddonImpNumbers(number).name.lower()

def clean_fields(self, *args, **kwargs):
super().clean_fields(*args, **kwargs)
_connected_caps = set(self.connected_capabilities)
Expand Down
1 change: 1 addition & 0 deletions addon_service/configured_addon/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@ class Meta:
"connected_operations",
"connected_operation_names",
"current_user_is_owner",
"external_service_name",
]
1 change: 1 addition & 0 deletions addon_service/configured_addon/storage/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,5 @@ class Meta:
"connected_operation_names",
"external_storage_service",
"current_user_is_owner",
"external_service_name",
]

0 comments on commit 0dab0fc

Please sign in to comment.