Skip to content

Commit

Permalink
embrace black
Browse files Browse the repository at this point in the history
  • Loading branch information
aaxelb committed Nov 29, 2023
1 parent 359061c commit 127ae44
Show file tree
Hide file tree
Showing 21 changed files with 273 additions and 149 deletions.
10 changes: 6 additions & 4 deletions addon_service/authorized_storage_account/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@


class AuthorizedStorageAccount(AddonsServiceBaseModel):

# TODO: capability_set = ArrayField(models.CharField(max_length=128), default=list, blank=True)
# TODO: capabilities = ArrayField(...)
default_root_folder = models.CharField(blank=True)

external_storage_service = models.ForeignKey(
'addon_service.ExternalStorageService',
"addon_service.ExternalStorageService",
on_delete=models.CASCADE,
)
external_account = models.ForeignKey(
"addon_service.ExternalAccount",
on_delete=models.CASCADE,
)
external_account = models.ForeignKey('addon_service.ExternalAccount', on_delete=models.CASCADE)

class Meta:
verbose_name = "Authorized Storage Account"
Expand Down
14 changes: 7 additions & 7 deletions addon_service/authorized_storage_account/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,28 @@

from addon_service.models import (
AuthorizedStorageAccount,
InternalUser,
ExternalService,
InternalUser,
)


class AuthorizedStorageAccountSerializer(serializers.ModelSerializer):
account_owner = SerializerMethodResourceRelatedField(
model=InternalUser,
method_name='_get_account_owner',
method_name="_get_account_owner",
)
external_service = SerializerMethodResourceRelatedField(
model=ExternalService,
method_name='_get_external_service',
method_name="_get_external_service",
)

class Meta:
model = AuthorizedStorageAccount
fields = [
'default_root_folder',
'external_storage_service',
'account_owner',
'external_service',
"default_root_folder",
"external_storage_service",
"account_owner",
"external_service",
]

def _get_account_owner(self, instance: AuthorizedStorageAccount):
Expand Down
2 changes: 1 addition & 1 deletion addon_service/authorized_storage_account/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
class AuthorizedStorageAccountViewSet(CRUDViewSet):
queryset = AuthorizedStorageAccount.objects
serializer_class = AuthorizedStorageAccountSerializer
resource_name = 'authorized-storage-accounts'
resource_name = "authorized-storage-accounts"
# TODO: permissions_classes
1 change: 0 additions & 1 deletion addon_service/common/base_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


class AddonsServiceBaseModel(models.Model):

created = models.DateTimeField(editable=False)
modified = models.DateTimeField()

Expand Down
17 changes: 11 additions & 6 deletions addon_service/common/base_viewset.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
from rest_framework import mixins, viewsets
from rest_framework import (
mixins,
viewsets,
)


class CRUDViewSet(mixins.CreateModelMixin,
mixins.RetrieveModelMixin,
mixins.UpdateModelMixin,
mixins.DestroyModelMixin,
viewsets.GenericViewSet):
class CRUDViewSet(
mixins.CreateModelMixin,
mixins.RetrieveModelMixin,
mixins.UpdateModelMixin,
mixins.DestroyModelMixin,
viewsets.GenericViewSet,
):
pass
7 changes: 3 additions & 4 deletions addon_service/configured_storage_addon/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@


class ConfiguredStorageAddon(AddonsServiceBaseModel):

root_folder = models.CharField()

authorized_storage_account = models.ForeignKey(
'addon_service.AuthorizedStorageAccount',
"addon_service.AuthorizedStorageAccount",
on_delete=models.CASCADE,
)
internal_resource = models.ForeignKey(
'addon_service.InternalResource',
"addon_service.InternalResource",
on_delete=models.CASCADE,
related_name='configured_storage_addons',
related_name="configured_storage_addons",
)

class Meta:
Expand Down
9 changes: 5 additions & 4 deletions addon_service/configured_storage_addon/serializers.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from addon_service.models import ConfiguredStorageAddon
from rest_framework_json_api import serializers

from addon_service.models import ConfiguredStorageAddon


class ConfiguredStorageAddonSerializer(serializers.ModelSerializer):
class Meta:
model = ConfiguredStorageAddon
fields = [
'root_folder',
'authorized_storage_account',
'internal_resource',
"root_folder",
"authorized_storage_account",
"internal_resource",
]
2 changes: 1 addition & 1 deletion addon_service/configured_storage_addon/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
class ConfiguredStorageAddonViewSet(CRUDViewSet):
queryset = ConfiguredStorageAddon.objects
serializer_class = ConfiguredStorageAddonSerializer
resource_name = 'configured-storage-addons'
resource_name = "configured-storage-addons"
# TODO: permissions_classes
11 changes: 7 additions & 4 deletions addon_service/external_account/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@


class ExternalAccount(AddonsServiceBaseModel):

# The user's ID on the remote service
remote_account_id = models.CharField()
remote_account_display_name = models.CharField()

external_service = models.ForeignKey('addon_service.ExternalService', on_delete=models.CASCADE)
owner = models.ForeignKey('addon_service.InternalUser', on_delete=models.CASCADE)
credentials = models.ForeignKey('addon_service.ExternalCredentials', on_delete=models.CASCADE)
external_service = models.ForeignKey(
"addon_service.ExternalService", on_delete=models.CASCADE
)
owner = models.ForeignKey("addon_service.InternalUser", on_delete=models.CASCADE)
credentials = models.ForeignKey(
"addon_service.ExternalCredentials", on_delete=models.CASCADE
)

class Meta:
verbose_name = "External Account"
Expand Down
1 change: 0 additions & 1 deletion addon_service/external_credentials/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class ExternalCredentials(AddonsServiceBaseModel):

# TODO: Settle on encryption solution
oauth_key = models.CharField(blank=True, null=True)

Expand Down
1 change: 0 additions & 1 deletion addon_service/external_service/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

# TODO: consider another name
class ExternalService(AddonsServiceBaseModel):

name = models.CharField(null=False)

class Meta:
Expand Down
5 changes: 3 additions & 2 deletions addon_service/external_storage_service/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@


class ExternalStorageService(AddonsServiceBaseModel):

max_concurrent_downloads = models.IntegerField(null=False)
max_upload_mb = models.IntegerField(null=False)

auth_uri = models.URLField(null=False)

external_service = models.ForeignKey('addon_service.ExternalService', on_delete=models.CASCADE)
external_service = models.ForeignKey(
"addon_service.ExternalService", on_delete=models.CASCADE
)

class Meta:
verbose_name = "External Storage Service"
Expand Down
2 changes: 1 addition & 1 deletion addon_service/external_storage_service/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@
class ExternalStorageServiceViewSet(CRUDViewSet):
queryset = ExternalStorageService.objects
serializer_class = ExternalStorageServiceSerializer
resource_name = 'external-storage-services'
resource_name = "external-storage-services"
# TODO: permissions_classes
8 changes: 4 additions & 4 deletions addon_service/internal_resource/serializers.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from addon_service.models import InternalResource
from rest_framework_json_api import serializers

from addon_service.models import InternalResource


class InternalResourceSerializer(serializers.ModelSerializer):

class Meta:
model = InternalResource
fields = [
'resource_uri',
'configured_storage_addons',
"resource_uri",
"configured_storage_addons",
]
2 changes: 1 addition & 1 deletion addon_service/internal_resource/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class InternalResourceViewSet(CRUDViewSet): # TODO: read-only
queryset = InternalResource.objects
serializer_class = InternalResourceSerializer
resource_name = 'internal-resources'
resource_name = "internal-resources"
# TODO: permissions_classes


Expand Down
Loading

0 comments on commit 127ae44

Please sign in to comment.