Skip to content

Commit

Permalink
Merge pull request #70 from maykinmedia/feature/update-black
Browse files Browse the repository at this point in the history
Feature/update black
  • Loading branch information
annashamray committed Sep 21, 2020
2 parents c807bd0 + 28d0555 commit 935b39f
Show file tree
Hide file tree
Showing 15 changed files with 103 additions and 29 deletions.
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ appdirs==1.4.3 # via black
attrs==19.3.0 # via -r requirements/ci.txt, black, jsonschema
babel==2.8.0 # via sphinx
beautifulsoup4==4.9.0 # via -r requirements/ci.txt, webtest
black==19.10b0 # via -r requirements/dev.in
black==20.8b0 # via -r requirements/dev.in
certifi==2020.4.5.1 # via -r requirements/ci.txt, elastic-apm, requests, sentry-sdk
chardet==3.0.4 # via -r requirements/ci.txt, requests
click==7.1.1 # via black, pip-tools
Expand Down
9 changes: 7 additions & 2 deletions src/objects/accounts/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,12 @@ class Migration(migrations.Migration):
),
),
],
options={"verbose_name": "user", "verbose_name_plural": "users",},
managers=[("objects", objects.accounts.managers.UserManager()),],
options={
"verbose_name": "user",
"verbose_name_plural": "users",
},
managers=[
("objects", objects.accounts.managers.UserManager()),
],
),
]
4 changes: 3 additions & 1 deletion src/objects/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class User(AbstractBaseUser, PermissionsMixin):
max_length=150,
unique=True,
help_text=_("Required. 150 characters or fewer."),
error_messages={"unique": _("A user with that username already exists."),},
error_messages={
"unique": _("A user with that username already exists."),
},
)
first_name = models.CharField(_("first name"), max_length=255, blank=True)
last_name = models.CharField(_("last name"), max_length=255, blank=True)
Expand Down
4 changes: 3 additions & 1 deletion src/objects/api/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@

schema_view = get_schema_view(
openapi.Info(
title="Objects API", default_version="v1", description="OAS for Objects API",
title="Objects API",
default_version="v1",
description="OAS for Objects API",
),
public=True,
permission_classes=(permissions.AllowAny,),
Expand Down
31 changes: 24 additions & 7 deletions src/objects/conf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@
TEMPLATES = [
{
"BACKEND": "django.template.backends.django.DjangoTemplates",
"DIRS": [os.path.join(DJANGO_PROJECT_DIR, "templates"),],
"DIRS": [
os.path.join(DJANGO_PROJECT_DIR, "templates"),
],
"APP_DIRS": False, # conflicts with explicity specifying the loaders
"OPTIONS": {
"context_processors": [
Expand Down Expand Up @@ -127,9 +129,15 @@
{
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator",
},
{"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",},
{"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",},
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",},
{
"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator",
},
{
"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator",
},
{
"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator",
},
]


Expand Down Expand Up @@ -193,14 +201,19 @@
"format": "%(asctime)s %(process)d | %(thread)d | %(message)s",
},
},
"filters": {"require_debug_false": {"()": "django.utils.log.RequireDebugFalse"},},
"filters": {
"require_debug_false": {"()": "django.utils.log.RequireDebugFalse"},
},
"handlers": {
"mail_admins": {
"level": "ERROR",
"filters": ["require_debug_false"],
"class": "django.utils.log.AdminEmailHandler",
},
"null": {"level": "DEBUG", "class": "logging.NullHandler",},
"null": {
"level": "DEBUG",
"class": "logging.NullHandler",
},
"console": {
"level": "DEBUG",
"class": "logging.StreamHandler",
Expand Down Expand Up @@ -232,7 +245,11 @@
},
},
"loggers": {
"objects": {"handlers": ["project"], "level": "INFO", "propagate": True,},
"objects": {
"handlers": ["project"],
"level": "INFO",
"propagate": True,
},
"django.request": {
"handlers": ["django"],
"level": "ERROR",
Expand Down
26 changes: 21 additions & 5 deletions src/objects/conf/dev.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,26 @@

LOGGING["loggers"].update(
{
"objects": {"handlers": ["console"], "level": "DEBUG", "propagate": True,},
"django": {"handlers": ["console"], "level": "DEBUG", "propagate": True,},
"objects": {
"handlers": ["console"],
"level": "DEBUG",
"propagate": True,
},
"django": {
"handlers": ["console"],
"level": "DEBUG",
"propagate": True,
},
"django.db.backends": {
"handlers": ["django"],
"level": "DEBUG",
"propagate": False,
},
"performance": {"handlers": ["console"], "level": "INFO", "propagate": True,},
"performance": {
"handlers": ["console"],
"level": "INFO",
"propagate": True,
},
#
# See: https://code.djangoproject.com/ticket/30554
# Autoreload logs excessively, turn it down a bit.
Expand Down Expand Up @@ -89,8 +101,12 @@
# in memory cache and django-axes don't get along.
# https://django-axes.readthedocs.io/en/latest/configuration.html#known-configuration-problems
CACHES = {
"default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache",},
"axes_cache": {"BACKEND": "django.core.cache.backends.dummy.DummyCache",},
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
},
"axes_cache": {
"BACKEND": "django.core.cache.backends.dummy.DummyCache",
},
}

AXES_CACHE = "axes_cache"
Expand Down
8 changes: 6 additions & 2 deletions src/objects/conf/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,13 @@ def getenv(key, default=None, required=False, split=False):
ALLOWED_HOSTS = getenv("ALLOWED_HOSTS", "*", split=True)

CACHES = {
"default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache",},
"default": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache",
},
# https://github.com/jazzband/django-axes/blob/master/docs/configuration.rst#cache-problems
"axes_cache": {"BACKEND": "django.core.cache.backends.dummy.DummyCache",},
"axes_cache": {
"BACKEND": "django.core.cache.backends.dummy.DummyCache",
},
}

# Deal with being hosted on a subpath
Expand Down
6 changes: 5 additions & 1 deletion src/objects/conf/production.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@
# Production logging facility.
LOGGING["loggers"].update(
{
"django": {"handlers": ["django"], "level": "INFO", "propagate": True,},
"django": {
"handlers": ["django"],
"level": "INFO",
"propagate": True,
},
"django.security.DisallowedHost": {
"handlers": ["django"],
"level": "CRITICAL",
Expand Down
6 changes: 5 additions & 1 deletion src/objects/conf/staging.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@

LOGGING["loggers"].update(
{
"django": {"handlers": ["django"], "level": "INFO", "propagate": True,},
"django": {
"handlers": ["django"],
"level": "INFO",
"propagate": True,
},
"django.security.DisallowedHost": {
"handlers": ["django"],
"level": "CRITICAL",
Expand Down
5 changes: 4 additions & 1 deletion src/objects/core/migrations/0005_remove_object_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ class Migration(migrations.Migration):
]

operations = [
migrations.RemoveField(model_name="object", name="data",),
migrations.RemoveField(
model_name="object",
name="data",
),
]
5 changes: 4 additions & 1 deletion src/objects/core/migrations/0006_auto_20200904_1402.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ class Migration(migrations.Migration):
migrations.RenameField(
model_name="objectrecord", old_name="material_date", new_name="start_date"
),
migrations.RemoveField(model_name="objectrecord", name="record_type",),
migrations.RemoveField(
model_name="objectrecord",
name="record_type",
),
migrations.AddField(
model_name="objectrecord",
name="end_date",
Expand Down
5 changes: 4 additions & 1 deletion src/objects/core/migrations/0011_remove_object_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ class Migration(migrations.Migration):
]

operations = [
migrations.RemoveField(model_name="object", name="version",),
migrations.RemoveField(
model_name="object",
name="version",
),
]
12 changes: 9 additions & 3 deletions src/objects/tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ def test_create_object_invalid_objecttype_url(self, m):
def test_create_object_no_version(self, m):
m.get(
OBJECT_TYPE,
json={"url": OBJECT_TYPE, "name": "boom", "namePlural": "bomen",},
json={
"url": OBJECT_TYPE,
"name": "boom",
"namePlural": "bomen",
},
)

url = reverse("object-list")
Expand Down Expand Up @@ -152,7 +156,8 @@ def test_update_object_type_invalid(self, m):
m.get(OBJECT_TYPE, json=mock_objecttype(OBJECT_TYPE))

initial_record = ObjectRecordFactory.create(
data={"plantDate": "2020-04-12", "diameter": 30}, version=1,
data={"plantDate": "2020-04-12", "diameter": 30},
version=1,
)
object = initial_record.object

Expand All @@ -167,5 +172,6 @@ def test_update_object_type_invalid(self, m):

data = response.json()
self.assertEqual(
data["type"], ["This field can't be changed"],
data["type"],
["This field can't be changed"],
)
5 changes: 4 additions & 1 deletion src/objects/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ def mock_objecttype(url: str) -> dict:
"type": "object",
"required": ["diameter"],
"properties": {
"diameter": {"description": "size in cm.", "type": "integer",},
"diameter": {
"description": "size in cm.",
"type": "integer",
},
"plantDate": {
"type": "string",
"description": "the date the tree was planted.",
Expand Down
4 changes: 3 additions & 1 deletion src/objects/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,6 @@
if settings.DEBUG and apps.is_installed("debug_toolbar"):
import debug_toolbar

urlpatterns = [path("__debug__/", include(debug_toolbar.urls)),] + urlpatterns
urlpatterns = [
path("__debug__/", include(debug_toolbar.urls)),
] + urlpatterns

0 comments on commit 935b39f

Please sign in to comment.