From 127ae44aa77aeef3b3f030df41116e3601de6b12 Mon Sep 17 00:00:00 2001 From: Abram Booth Date: Wed, 29 Nov 2023 13:39:22 -0500 Subject: [PATCH] embrace `black` --- .../authorized_storage_account/models.py | 10 +- .../authorized_storage_account/serializers.py | 14 +- .../authorized_storage_account/views.py | 2 +- addon_service/common/base_model.py | 1 - addon_service/common/base_viewset.py | 17 +- .../configured_storage_addon/models.py | 7 +- .../configured_storage_addon/serializers.py | 9 +- .../configured_storage_addon/views.py | 2 +- addon_service/external_account/models.py | 11 +- addon_service/external_credentials/models.py | 1 - addon_service/external_service/models.py | 1 - .../external_storage_service/models.py | 5 +- .../external_storage_service/views.py | 2 +- .../internal_resource/serializers.py | 8 +- addon_service/internal_resource/views.py | 2 +- addon_service/migrations/0001_initial.py | 266 ++++++++++++------ addon_service/models.py | 19 +- addon_service/tests/test_base.py | 5 +- addon_service/views.py | 15 +- app/env.py | 16 +- app/urls.py | 9 +- 21 files changed, 273 insertions(+), 149 deletions(-) diff --git a/addon_service/authorized_storage_account/models.py b/addon_service/authorized_storage_account/models.py index 9b2b366c..fce68f80 100644 --- a/addon_service/authorized_storage_account/models.py +++ b/addon_service/authorized_storage_account/models.py @@ -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" diff --git a/addon_service/authorized_storage_account/serializers.py b/addon_service/authorized_storage_account/serializers.py index 4f258d3e..f71e803b 100644 --- a/addon_service/authorized_storage_account/serializers.py +++ b/addon_service/authorized_storage_account/serializers.py @@ -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): diff --git a/addon_service/authorized_storage_account/views.py b/addon_service/authorized_storage_account/views.py index 7897f6e2..6cf5a990 100644 --- a/addon_service/authorized_storage_account/views.py +++ b/addon_service/authorized_storage_account/views.py @@ -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 diff --git a/addon_service/common/base_model.py b/addon_service/common/base_model.py index cbeaf54e..0a6d3413 100644 --- a/addon_service/common/base_model.py +++ b/addon_service/common/base_model.py @@ -3,7 +3,6 @@ class AddonsServiceBaseModel(models.Model): - created = models.DateTimeField(editable=False) modified = models.DateTimeField() diff --git a/addon_service/common/base_viewset.py b/addon_service/common/base_viewset.py index 8b7a27e7..95c834ec 100644 --- a/addon_service/common/base_viewset.py +++ b/addon_service/common/base_viewset.py @@ -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 diff --git a/addon_service/configured_storage_addon/models.py b/addon_service/configured_storage_addon/models.py index 749ca68b..2cd974e3 100644 --- a/addon_service/configured_storage_addon/models.py +++ b/addon_service/configured_storage_addon/models.py @@ -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: diff --git a/addon_service/configured_storage_addon/serializers.py b/addon_service/configured_storage_addon/serializers.py index 108d89ce..03185747 100644 --- a/addon_service/configured_storage_addon/serializers.py +++ b/addon_service/configured_storage_addon/serializers.py @@ -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", ] diff --git a/addon_service/configured_storage_addon/views.py b/addon_service/configured_storage_addon/views.py index 5b41b06c..fb45fa33 100644 --- a/addon_service/configured_storage_addon/views.py +++ b/addon_service/configured_storage_addon/views.py @@ -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 diff --git a/addon_service/external_account/models.py b/addon_service/external_account/models.py index 8d50470a..ea3a0773 100644 --- a/addon_service/external_account/models.py +++ b/addon_service/external_account/models.py @@ -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" diff --git a/addon_service/external_credentials/models.py b/addon_service/external_credentials/models.py index a8d2f283..d0f6ee5f 100644 --- a/addon_service/external_credentials/models.py +++ b/addon_service/external_credentials/models.py @@ -4,7 +4,6 @@ class ExternalCredentials(AddonsServiceBaseModel): - # TODO: Settle on encryption solution oauth_key = models.CharField(blank=True, null=True) diff --git a/addon_service/external_service/models.py b/addon_service/external_service/models.py index d9109c13..9c5a3625 100644 --- a/addon_service/external_service/models.py +++ b/addon_service/external_service/models.py @@ -5,7 +5,6 @@ # TODO: consider another name class ExternalService(AddonsServiceBaseModel): - name = models.CharField(null=False) class Meta: diff --git a/addon_service/external_storage_service/models.py b/addon_service/external_storage_service/models.py index 76d80d36..40be3bfb 100644 --- a/addon_service/external_storage_service/models.py +++ b/addon_service/external_storage_service/models.py @@ -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" diff --git a/addon_service/external_storage_service/views.py b/addon_service/external_storage_service/views.py index 78d6e779..80fe71c0 100644 --- a/addon_service/external_storage_service/views.py +++ b/addon_service/external_storage_service/views.py @@ -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 diff --git a/addon_service/internal_resource/serializers.py b/addon_service/internal_resource/serializers.py index 33977ad8..8121664f 100644 --- a/addon_service/internal_resource/serializers.py +++ b/addon_service/internal_resource/serializers.py @@ -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", ] diff --git a/addon_service/internal_resource/views.py b/addon_service/internal_resource/views.py index 11e57874..d30e28c0 100644 --- a/addon_service/internal_resource/views.py +++ b/addon_service/internal_resource/views.py @@ -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 diff --git a/addon_service/migrations/0001_initial.py b/addon_service/migrations/0001_initial.py index aa5793bb..5639ad8c 100644 --- a/addon_service/migrations/0001_initial.py +++ b/addon_service/migrations/0001_initial.py @@ -1,142 +1,250 @@ # Generated by Django 4.2.7 on 2023-11-28 19:41 -from django.db import migrations, models import django.db.models.deletion +from django.db import ( + migrations, + models, +) class Migration(migrations.Migration): - initial = True - dependencies = [ - ] + dependencies = [] operations = [ migrations.CreateModel( - name='AuthorizedStorageAccount', + name="AuthorizedStorageAccount", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(editable=False)), - ('modified', models.DateTimeField()), - ('default_root_folder', models.CharField(blank=True)), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("created", models.DateTimeField(editable=False)), + ("modified", models.DateTimeField()), + ("default_root_folder", models.CharField(blank=True)), ], options={ - 'verbose_name': 'Authorized Storage Account', - 'verbose_name_plural': 'Authorized Storage Accounts', + "verbose_name": "Authorized Storage Account", + "verbose_name_plural": "Authorized Storage Accounts", }, ), migrations.CreateModel( - name='ExternalCredentials', + name="ExternalCredentials", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(editable=False)), - ('modified', models.DateTimeField()), - ('oauth_key', models.CharField(blank=True, null=True)), - ('oauth_secret', models.CharField(blank=True, null=True)), - ('refresh_token', models.CharField(blank=True, null=True)), - ('date_last_refreshed', models.DateTimeField(blank=True, null=True)), - ('expires_at', models.DateTimeField(blank=True, null=True)), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("created", models.DateTimeField(editable=False)), + ("modified", models.DateTimeField()), + ("oauth_key", models.CharField(blank=True, null=True)), + ("oauth_secret", models.CharField(blank=True, null=True)), + ("refresh_token", models.CharField(blank=True, null=True)), + ("date_last_refreshed", models.DateTimeField(blank=True, null=True)), + ("expires_at", models.DateTimeField(blank=True, null=True)), ], options={ - 'verbose_name': 'External Credentials', - 'verbose_name_plural': 'External Credentials', + "verbose_name": "External Credentials", + "verbose_name_plural": "External Credentials", }, ), migrations.CreateModel( - name='ExternalService', + name="ExternalService", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(editable=False)), - ('modified', models.DateTimeField()), - ('name', models.CharField()), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("created", models.DateTimeField(editable=False)), + ("modified", models.DateTimeField()), + ("name", models.CharField()), ], options={ - 'verbose_name': 'External Service', - 'verbose_name_plural': 'External Services', + "verbose_name": "External Service", + "verbose_name_plural": "External Services", }, ), migrations.CreateModel( - name='InternalResource', + name="InternalResource", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(editable=False)), - ('modified', models.DateTimeField()), - ('resource_uri', models.URLField(db_index=True, unique=True)), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("created", models.DateTimeField(editable=False)), + ("modified", models.DateTimeField()), + ("resource_uri", models.URLField(db_index=True, unique=True)), ], options={ - 'verbose_name': 'Internal Resource', - 'verbose_name_plural': 'Internal Resources', + "verbose_name": "Internal Resource", + "verbose_name_plural": "Internal Resources", }, ), migrations.CreateModel( - name='InternalUser', + name="InternalUser", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(editable=False)), - ('modified', models.DateTimeField()), - ('user_uri', models.URLField(db_index=True, unique=True)), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("created", models.DateTimeField(editable=False)), + ("modified", models.DateTimeField()), + ("user_uri", models.URLField(db_index=True, unique=True)), ], options={ - 'verbose_name': 'Internal User', - 'verbose_name_plural': 'Internal Users', + "verbose_name": "Internal User", + "verbose_name_plural": "Internal Users", }, ), migrations.CreateModel( - name='ExternalStorageService', + name="ExternalStorageService", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(editable=False)), - ('modified', models.DateTimeField()), - ('max_concurrent_downloads', models.IntegerField()), - ('max_upload_mb', models.IntegerField()), - ('auth_uri', models.URLField()), - ('external_service', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='addon_service.externalservice')), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("created", models.DateTimeField(editable=False)), + ("modified", models.DateTimeField()), + ("max_concurrent_downloads", models.IntegerField()), + ("max_upload_mb", models.IntegerField()), + ("auth_uri", models.URLField()), + ( + "external_service", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="addon_service.externalservice", + ), + ), ], options={ - 'verbose_name': 'External Storage Service', - 'verbose_name_plural': 'External Storage Services', + "verbose_name": "External Storage Service", + "verbose_name_plural": "External Storage Services", }, ), migrations.CreateModel( - name='ExternalAccount', + name="ExternalAccount", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(editable=False)), - ('modified', models.DateTimeField()), - ('remote_account_id', models.CharField()), - ('remote_account_display_name', models.CharField()), - ('credentials', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='addon_service.externalcredentials')), - ('external_service', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='addon_service.externalservice')), - ('owner', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='addon_service.internaluser')), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("created", models.DateTimeField(editable=False)), + ("modified", models.DateTimeField()), + ("remote_account_id", models.CharField()), + ("remote_account_display_name", models.CharField()), + ( + "credentials", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="addon_service.externalcredentials", + ), + ), + ( + "external_service", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="addon_service.externalservice", + ), + ), + ( + "owner", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="addon_service.internaluser", + ), + ), ], options={ - 'verbose_name': 'External Account', - 'verbose_name_plural': 'External Accounts', + "verbose_name": "External Account", + "verbose_name_plural": "External Accounts", }, ), migrations.CreateModel( - name='ConfiguredStorageAddon', + name="ConfiguredStorageAddon", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('created', models.DateTimeField(editable=False)), - ('modified', models.DateTimeField()), - ('root_folder', models.CharField()), - ('authorized_storage_account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='addon_service.authorizedstorageaccount')), - ('internal_resource', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='configured_storage_addons', to='addon_service.internalresource')), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("created", models.DateTimeField(editable=False)), + ("modified", models.DateTimeField()), + ("root_folder", models.CharField()), + ( + "authorized_storage_account", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="addon_service.authorizedstorageaccount", + ), + ), + ( + "internal_resource", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="configured_storage_addons", + to="addon_service.internalresource", + ), + ), ], options={ - 'verbose_name': 'Configured Storage Addon', - 'verbose_name_plural': 'Configured Storage Addons', + "verbose_name": "Configured Storage Addon", + "verbose_name_plural": "Configured Storage Addons", }, ), migrations.AddField( - model_name='authorizedstorageaccount', - name='external_account', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='addon_service.externalaccount'), + model_name="authorizedstorageaccount", + name="external_account", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="addon_service.externalaccount", + ), ), migrations.AddField( - model_name='authorizedstorageaccount', - name='external_storage_service', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='addon_service.externalstorageservice'), + model_name="authorizedstorageaccount", + name="external_storage_service", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="addon_service.externalstorageservice", + ), ), ] diff --git a/addon_service/models.py b/addon_service/models.py index 83e9dfa0..c4dd90c3 100644 --- a/addon_service/models.py +++ b/addon_service/models.py @@ -4,20 +4,21 @@ from addon_service.external_account.models import ExternalAccount from addon_service.external_credentials.models import ExternalCredentials from addon_service.external_service.models import ExternalService +from addon_service.external_storage_service.models import ExternalStorageService from addon_service.internal_resource.models import InternalResource from addon_service.internal_user.models import InternalUser -from addon_service.external_storage_service.models import ExternalStorageService + __all__ = ( - 'AuthorizedStorageAccount', + "AuthorizedStorageAccount", # 'AuthorizedComputeAccount', - 'ConfiguredStorageAddon', + "ConfiguredStorageAddon", # 'ConfiguredComputeAddon', - 'ExternalAccount', - 'ExternalCredentials', - 'ExternalService', - 'ExternalStorageService', + "ExternalAccount", + "ExternalCredentials", + "ExternalService", + "ExternalStorageService", # 'ExternalComputeService', - 'InternalResource', - 'InternalUser', + "InternalResource", + "InternalUser", ) diff --git a/addon_service/tests/test_base.py b/addon_service/tests/test_base.py index 085d8e8f..dc308e39 100644 --- a/addon_service/tests/test_base.py +++ b/addon_service/tests/test_base.py @@ -1,4 +1,5 @@ from django.test import TestCase + from .factories import InternalUserFactory @@ -9,6 +10,6 @@ def test_tests(self): def test_model(self): """Simple base test to test test models""" - user = InternalUserFactory(user_uri='http://osf.example/hurts') + user = InternalUserFactory(user_uri="http://osf.example/hurts") user.save() - assert user.user_uri == 'http://osf.example/hurts' + assert user.user_uri == "http://osf.example/hurts" diff --git a/addon_service/views.py b/addon_service/views.py index d96c2a3f..64f1a85c 100644 --- a/addon_service/views.py +++ b/addon_service/views.py @@ -1,17 +1,20 @@ """ Import views/viewsets here for convenience """ -from addon_service.authorized_storage_account.views import AuthorizedStorageAccountViewSet +from addon_service.authorized_storage_account.views import ( + AuthorizedStorageAccountViewSet, +) from addon_service.configured_storage_addon.views import ConfiguredStorageAddonViewSet from addon_service.external_storage_service.views import ExternalStorageServiceViewSet from addon_service.internal_resource.views import InternalResourceViewSet from addon_service.internal_user.views import InternalUserViewSet + __all__ = ( - 'AuthorizedStorageAccountViewSet', + "AuthorizedStorageAccountViewSet", # 'AuthorizedComputeAccountViewSet', - 'ConfiguredStorageAddonViewSet', + "ConfiguredStorageAddonViewSet", # 'ConfiguredComputeAddonViewSet', - 'ExternalStorageServiceViewSet', + "ExternalStorageServiceViewSet", # 'ExternalComputeServiceViewSet', - 'InternalResourceViewSet', - 'InternalUserViewSet', + "InternalResourceViewSet", + "InternalUserViewSet", ) diff --git a/app/env.py b/app/env.py index 5401b17f..d85a45a7 100644 --- a/app/env.py +++ b/app/env.py @@ -3,16 +3,16 @@ import os -POSTGRES_DB = os.environ.get('POSTGRES_DB') -POSTGRES_USER = os.environ.get('POSTGRES_USER') -POSTGRES_PASSWORD = os.environ.get('POSTGRES_PASSWORD') -POSTGRES_HOST = os.environ.get('POSTGRES_HOST') -POSTGRES_PORT = os.environ.get('POSTGRES_PORT', '5432') +POSTGRES_DB = os.environ.get("POSTGRES_DB") +POSTGRES_USER = os.environ.get("POSTGRES_USER") +POSTGRES_PASSWORD = os.environ.get("POSTGRES_PASSWORD") +POSTGRES_HOST = os.environ.get("POSTGRES_HOST") +POSTGRES_PORT = os.environ.get("POSTGRES_PORT", "5432") -SECRET_KEY = os.environ.get('SECRET_KEY') +SECRET_KEY = os.environ.get("SECRET_KEY") # any non-empty value enables debug mode: -DEBUG = bool(os.environ.get('DEBUG')) +DEBUG = bool(os.environ.get("DEBUG")) # comma-separated list: -ALLOWED_HOSTS = os.environ.get('ALLOWED_HOSTS', '').split(',') +ALLOWED_HOSTS = os.environ.get("ALLOWED_HOSTS", "").split(",") diff --git a/app/urls.py b/app/urls.py index 5380ed0b..3c38cc2c 100644 --- a/app/urls.py +++ b/app/urls.py @@ -13,7 +13,10 @@ 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ -from django.urls import include, path +from django.urls import ( + include, + path, +) from rest_framework.routers import DefaultRouter from addon_service import views @@ -23,7 +26,7 @@ def _register_viewset(viewset): - '''convenience for viewsets with `resource_name`''' + """convenience for viewsets with `resource_name`""" router.register(viewset.resource_name, viewset) @@ -33,5 +36,5 @@ def _register_viewset(viewset): urlpatterns = [ - path('v1/', include(router.urls)), + path("v1/", include(router.urls)), ]