Skip to content

Commit 3bbb56d

Browse files
committed
Reformat files with black
1 parent 1336677 commit 3bbb56d

File tree

16 files changed

+291
-182
lines changed

16 files changed

+291
-182
lines changed

conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22

3+
34
# Ensures pytest waits for the database to load
45
# https://pytest-django.readthedocs.io/en/latest/faq.html#how-can-i-give-database-access-to-all-my-tests-without-the-django-db-marker
56
@pytest.fixture(autouse=True)

manage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,5 @@ def main():
2626
execute_from_command_line(sys.argv)
2727

2828

29-
if __name__ == '__main__':
29+
if __name__ == "__main__":
3030
main()

vbos/config/common.py

Lines changed: 101 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -2,198 +2,189 @@
22
from os.path import join
33
import dj_database_url
44
from configurations import Configuration
5+
56
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
67

78

89
class Common(Configuration):
910

1011
INSTALLED_APPS = (
11-
'django.contrib.admin',
12-
'django.contrib.auth',
13-
'django.contrib.contenttypes',
14-
'django.contrib.sessions',
15-
'django.contrib.messages',
16-
'django.contrib.staticfiles',
17-
12+
"django.contrib.admin",
13+
"django.contrib.auth",
14+
"django.contrib.contenttypes",
15+
"django.contrib.sessions",
16+
"django.contrib.messages",
17+
"django.contrib.staticfiles",
1818
# Third party apps
19-
'rest_framework', # utilities for rest apis
20-
'rest_framework.authtoken', # token authentication
21-
'django_filters', # for filtering rest endpoints
22-
19+
"rest_framework", # utilities for rest apis
20+
"rest_framework.authtoken", # token authentication
21+
"django_filters", # for filtering rest endpoints
2322
# Your apps
24-
'vbos.users',
25-
23+
"vbos.users",
2624
)
2725

2826
# https://docs.djangoproject.com/en/2.0/topics/http/middleware/
2927
MIDDLEWARE = (
30-
'django.middleware.security.SecurityMiddleware',
31-
'django.contrib.sessions.middleware.SessionMiddleware',
32-
'django.middleware.common.CommonMiddleware',
33-
'django.middleware.csrf.CsrfViewMiddleware',
34-
'django.contrib.auth.middleware.AuthenticationMiddleware',
35-
'django.contrib.messages.middleware.MessageMiddleware',
36-
'django.middleware.clickjacking.XFrameOptionsMiddleware',
28+
"django.middleware.security.SecurityMiddleware",
29+
"django.contrib.sessions.middleware.SessionMiddleware",
30+
"django.middleware.common.CommonMiddleware",
31+
"django.middleware.csrf.CsrfViewMiddleware",
32+
"django.contrib.auth.middleware.AuthenticationMiddleware",
33+
"django.contrib.messages.middleware.MessageMiddleware",
34+
"django.middleware.clickjacking.XFrameOptionsMiddleware",
3735
)
3836

3937
ALLOWED_HOSTS = ["*"]
40-
ROOT_URLCONF = 'vbos.urls'
41-
SECRET_KEY = os.getenv('DJANGO_SECRET_KEY')
42-
WSGI_APPLICATION = 'vbos.wsgi.application'
38+
ROOT_URLCONF = "vbos.urls"
39+
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY")
40+
WSGI_APPLICATION = "vbos.wsgi.application"
4341

4442
# Email
45-
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
43+
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
4644

47-
ADMINS = (
48-
('Author', '[email protected]'),
49-
)
45+
ADMINS = (("Author", "[email protected]"),)
5046

5147
# Postgres
5248
DATABASES = {
53-
'default': dj_database_url.config(
54-
default='postgis://postgres:@postgres:5432/vbos',
55-
conn_max_age=int(os.getenv('POSTGRES_CONN_MAX_AGE', 600))
49+
"default": dj_database_url.config(
50+
default="postgis://postgres:@postgres:5432/vbos",
51+
conn_max_age=int(os.getenv("POSTGRES_CONN_MAX_AGE", 600)),
5652
)
5753
}
5854

5955
# General
6056
APPEND_SLASH = False
61-
TIME_ZONE = 'UTC'
62-
LANGUAGE_CODE = 'en-us'
57+
TIME_ZONE = "UTC"
58+
LANGUAGE_CODE = "en-us"
6359
# If you set this to False, Django will make some optimizations so as not
6460
# to load the internationalization machinery.
6561
USE_I18N = False
6662
USE_L10N = True
6763
USE_TZ = True
68-
LOGIN_REDIRECT_URL = '/'
64+
LOGIN_REDIRECT_URL = "/"
6965

7066
# Static files (CSS, JavaScript, Images)
7167
# https://docs.djangoproject.com/en/2.0/howto/static-files/
72-
STATIC_ROOT = os.path.normpath(join(os.path.dirname(BASE_DIR), 'static'))
68+
STATIC_ROOT = os.path.normpath(join(os.path.dirname(BASE_DIR), "static"))
7369
STATICFILES_DIRS = []
74-
STATIC_URL = '/static/'
70+
STATIC_URL = "/static/"
7571
STATICFILES_FINDERS = (
76-
'django.contrib.staticfiles.finders.FileSystemFinder',
77-
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
72+
"django.contrib.staticfiles.finders.FileSystemFinder",
73+
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
7874
)
7975

8076
# Media files
81-
MEDIA_ROOT = join(os.path.dirname(BASE_DIR), 'media')
82-
MEDIA_URL = '/media/'
77+
MEDIA_ROOT = join(os.path.dirname(BASE_DIR), "media")
78+
MEDIA_URL = "/media/"
8379

8480
TEMPLATES = [
8581
{
86-
'BACKEND': 'django.template.backends.django.DjangoTemplates',
87-
'DIRS': STATICFILES_DIRS,
88-
'APP_DIRS': True,
89-
'OPTIONS': {
90-
'context_processors': [
91-
'django.template.context_processors.debug',
92-
'django.template.context_processors.request',
93-
'django.contrib.auth.context_processors.auth',
94-
'django.contrib.messages.context_processors.messages',
82+
"BACKEND": "django.template.backends.django.DjangoTemplates",
83+
"DIRS": STATICFILES_DIRS,
84+
"APP_DIRS": True,
85+
"OPTIONS": {
86+
"context_processors": [
87+
"django.template.context_processors.debug",
88+
"django.template.context_processors.request",
89+
"django.contrib.auth.context_processors.auth",
90+
"django.contrib.messages.context_processors.messages",
9591
],
9692
},
9793
},
9894
]
9995

10096
# Set DEBUG to False as a default for safety
10197
# https://docs.djangoproject.com/en/dev/ref/settings/#debug
102-
DEBUG = os.getenv('DJANGO_DEBUG', 'no').lower() in ('true', '1', 'yes')
98+
DEBUG = os.getenv("DJANGO_DEBUG", "no").lower() in ("true", "1", "yes")
10399

104100
# Password Validation
105101
# https://docs.djangoproject.com/en/2.0/topics/auth/passwords/#module-django.contrib.auth.password_validation
106102
AUTH_PASSWORD_VALIDATORS = [
107103
{
108-
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
104+
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
109105
},
110106
{
111-
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
107+
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
112108
},
113109
{
114-
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
110+
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
115111
},
116112
{
117-
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
113+
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
118114
},
119115
]
120116

121117
# Logging
122118
LOGGING = {
123-
'version': 1,
124-
'disable_existing_loggers': False,
125-
'formatters': {
126-
'django.server': {
127-
'()': 'django.utils.log.ServerFormatter',
128-
'format': '[%(server_time)s] %(message)s',
129-
},
130-
'verbose': {
131-
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
119+
"version": 1,
120+
"disable_existing_loggers": False,
121+
"formatters": {
122+
"django.server": {
123+
"()": "django.utils.log.ServerFormatter",
124+
"format": "[%(server_time)s] %(message)s",
132125
},
133-
'simple': {
134-
'format': '%(levelname)s %(message)s'
126+
"verbose": {
127+
"format": "%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s"
135128
},
129+
"simple": {"format": "%(levelname)s %(message)s"},
136130
},
137-
'filters': {
138-
'require_debug_true': {
139-
'()': 'django.utils.log.RequireDebugTrue',
131+
"filters": {
132+
"require_debug_true": {
133+
"()": "django.utils.log.RequireDebugTrue",
140134
},
141135
},
142-
'handlers': {
143-
'django.server': {
144-
'level': 'INFO',
145-
'class': 'logging.StreamHandler',
146-
'formatter': 'django.server',
136+
"handlers": {
137+
"django.server": {
138+
"level": "INFO",
139+
"class": "logging.StreamHandler",
140+
"formatter": "django.server",
147141
},
148-
'console': {
149-
'level': 'DEBUG',
150-
'class': 'logging.StreamHandler',
151-
'formatter': 'simple'
142+
"console": {
143+
"level": "DEBUG",
144+
"class": "logging.StreamHandler",
145+
"formatter": "simple",
152146
},
153-
'mail_admins': {
154-
'level': 'ERROR',
155-
'class': 'django.utils.log.AdminEmailHandler'
156-
}
157-
},
158-
'loggers': {
159-
'django': {
160-
'handlers': ['console'],
161-
'propagate': True,
147+
"mail_admins": {
148+
"level": "ERROR",
149+
"class": "django.utils.log.AdminEmailHandler",
162150
},
163-
'django.server': {
164-
'handlers': ['django.server'],
165-
'level': 'INFO',
166-
'propagate': False,
151+
},
152+
"loggers": {
153+
"django": {
154+
"handlers": ["console"],
155+
"propagate": True,
167156
},
168-
'django.request': {
169-
'handlers': ['mail_admins', 'console'],
170-
'level': 'ERROR',
171-
'propagate': False,
157+
"django.server": {
158+
"handlers": ["django.server"],
159+
"level": "INFO",
160+
"propagate": False,
172161
},
173-
'django.db.backends': {
174-
'handlers': ['console'],
175-
'level': 'INFO'
162+
"django.request": {
163+
"handlers": ["mail_admins", "console"],
164+
"level": "ERROR",
165+
"propagate": False,
176166
},
177-
}
167+
"django.db.backends": {"handlers": ["console"], "level": "INFO"},
168+
},
178169
}
179170

180171
# Custom user app
181-
AUTH_USER_MODEL = 'users.User'
172+
AUTH_USER_MODEL = "users.User"
182173

183174
# Django Rest Framework
184175
REST_FRAMEWORK = {
185-
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
186-
'PAGE_SIZE': int(os.getenv('DJANGO_PAGINATION_LIMIT', 10)),
187-
'DATETIME_FORMAT': '%Y-%m-%dT%H:%M:%S%z',
188-
'DEFAULT_RENDERER_CLASSES': (
189-
'rest_framework.renderers.JSONRenderer',
190-
'rest_framework.renderers.BrowsableAPIRenderer',
176+
"DEFAULT_PAGINATION_CLASS": "rest_framework.pagination.PageNumberPagination",
177+
"PAGE_SIZE": int(os.getenv("DJANGO_PAGINATION_LIMIT", 10)),
178+
"DATETIME_FORMAT": "%Y-%m-%dT%H:%M:%S%z",
179+
"DEFAULT_RENDERER_CLASSES": (
180+
"rest_framework.renderers.JSONRenderer",
181+
"rest_framework.renderers.BrowsableAPIRenderer",
191182
),
192-
'DEFAULT_PERMISSION_CLASSES': [
193-
'rest_framework.permissions.IsAuthenticated',
183+
"DEFAULT_PERMISSION_CLASSES": [
184+
"rest_framework.permissions.IsAuthenticated",
194185
],
195-
'DEFAULT_AUTHENTICATION_CLASSES': (
196-
'rest_framework.authentication.SessionAuthentication',
197-
'rest_framework.authentication.TokenAuthentication',
198-
)
186+
"DEFAULT_AUTHENTICATION_CLASSES": (
187+
"rest_framework.authentication.SessionAuthentication",
188+
"rest_framework.authentication.TokenAuthentication",
189+
),
199190
}

vbos/config/local.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
from .common import Common
3+
34
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
45

56

@@ -10,6 +11,6 @@ class Local(Common):
1011
INSTALLED_APPS = Common.INSTALLED_APPS
1112

1213
# Mail
13-
EMAIL_HOST = 'localhost'
14+
EMAIL_HOST = "localhost"
1415
EMAIL_PORT = 1025
15-
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
16+
EMAIL_BACKEND = "django.core.mail.backends.console.EmailBackend"

vbos/config/production.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,26 @@
44

55
class Production(Common):
66
INSTALLED_APPS = Common.INSTALLED_APPS
7-
SECRET_KEY = os.getenv('DJANGO_SECRET_KEY')
7+
SECRET_KEY = os.getenv("DJANGO_SECRET_KEY")
88
# Site
99
# https://docs.djangoproject.com/en/2.0/ref/settings/#allowed-hosts
1010
ALLOWED_HOSTS = ["*"]
11-
INSTALLED_APPS += ("gunicorn", )
11+
INSTALLED_APPS += ("gunicorn",)
1212

1313
# Static files (CSS, JavaScript, Images)
1414
# https://docs.djangoproject.com/en/2.0/howto/static-files/
1515
# http://django-storages.readthedocs.org/en/latest/index.html
16-
AWS_ACCESS_KEY_ID = os.getenv('DJANGO_AWS_ACCESS_KEY_ID')
17-
AWS_SECRET_ACCESS_KEY = os.getenv('DJANGO_AWS_SECRET_ACCESS_KEY')
18-
AWS_STORAGE_BUCKET_NAME = os.getenv('DJANGO_AWS_STORAGE_BUCKET_NAME')
19-
AWS_DEFAULT_ACL = 'public-read'
16+
AWS_ACCESS_KEY_ID = os.getenv("DJANGO_AWS_ACCESS_KEY_ID")
17+
AWS_SECRET_ACCESS_KEY = os.getenv("DJANGO_AWS_SECRET_ACCESS_KEY")
18+
AWS_STORAGE_BUCKET_NAME = os.getenv("DJANGO_AWS_STORAGE_BUCKET_NAME")
19+
AWS_DEFAULT_ACL = "public-read"
2020
AWS_AUTO_CREATE_BUCKET = True
2121
AWS_QUERYSTRING_AUTH = False
22-
MEDIA_URL = f'https://s3.amazonaws.com/{AWS_STORAGE_BUCKET_NAME}/'
22+
MEDIA_URL = f"https://s3.amazonaws.com/{AWS_STORAGE_BUCKET_NAME}/"
2323

2424
# https://developers.google.com/web/fundamentals/performance/optimizing-content-efficiency/http-caching#cache-control
2525
# Response can be cached by browser and any intermediary caches (i.e. it is "public") for up to 1 day
2626
# 86400 = (60 seconds x 60 minutes x 24 hours)
2727
AWS_HEADERS = {
28-
'Cache-Control': 'max-age=86400, s-maxage=86400, must-revalidate',
28+
"Cache-Control": "max-age=86400, s-maxage=86400, must-revalidate",
2929
}

vbos/urls.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,14 @@
88
from .users.views import UserViewSet
99

1010
router = DefaultRouter()
11-
router.register(r'users', UserViewSet)
11+
router.register(r"users", UserViewSet)
1212

1313
urlpatterns = [
14-
path('admin/', admin.site.urls),
15-
path('api/v1/', include(router.urls)),
16-
path('api-token-auth/', views.obtain_auth_token),
17-
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
18-
14+
path("admin/", admin.site.urls),
15+
path("api/v1/", include(router.urls)),
16+
path("api-token-auth/", views.obtain_auth_token),
17+
path("api-auth/", include("rest_framework.urls", namespace="rest_framework")),
1918
# the 'api-root' from django rest-frameworks default router
2019
# http://www.django-rest-framework.org/api-guide/routers/#defaultrouter
21-
re_path(r'^$', RedirectView.as_view(url=reverse_lazy('api-root'), permanent=False)),
22-
20+
re_path(r"^$", RedirectView.as_view(url=reverse_lazy("api-root"), permanent=False)),
2321
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

0 commit comments

Comments
 (0)