Skip to content

Commit 46fdaf3

Browse files
committed
Improve error handling, update style, update deps
1 parent d14a8e6 commit 46fdaf3

File tree

20 files changed

+410
-255
lines changed

20 files changed

+410
-255
lines changed

.flake8

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
[flake8]
2-
max-line-length = 119
3-
exclude =
4-
.git,
2+
extend-exclude =
53
migrations,
64
static,
75
staticfiles,
86
templates,
7+
max-line-length = 79

Pipfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ url = "https://pypi.org/simple"
44
verify_ssl = true
55

66
[dev-packages]
7-
black = "==19.10b0"
7+
black = "==20.8b1"
88
flake8 = "*"
99
factory-boy = "*"
10+
isort = "*"
1011

1112
[packages]
1213
django = "~=3.0"

Pipfile.lock

Lines changed: 238 additions & 176 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,9 @@ After made code changes and before commit, check code style from main directory
140140

141141
After making changes in code and before commit, check code style.
142142
```shell
143+
pipenv run isort .
143144
pipenv run black .
144-
pipenv run flake8
145+
pipenv run flake8 .
145146
```
146147

147148

caselaw/asgi.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
88
"""
99

10+
# Standard library
1011
import os
1112

13+
# Third-party
1214
from django.core.asgi import get_asgi_application
1315

1416
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "caselaw.settings")

caselaw/settings.py

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
https://docs.djangoproject.com/en/3.0/ref/settings/
1111
"""
1212

13+
# Standard library
1314
import os
14-
import django_heroku
1515
from distutils.util import strtobool
1616

17+
# Third-party
18+
import django_heroku
19+
1720
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
1821
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
1922

@@ -25,7 +28,9 @@
2528
SECRET_KEY = os.environ.get("DJANGO_SECRET_KEY")
2629

2730
# SECURITY WARNING: don't run with debug turned on in production!
28-
DEBUG = bool(strtobool(str(os.environ.get("DJANGO_DEBUG_ENABLED", default=False))))
31+
DEBUG = bool(
32+
strtobool(str(os.environ.get("DJANGO_DEBUG_ENABLED", default=False)))
33+
)
2934

3035
ALLOWED_HOSTS = ["localhost", "127.0.0.1"]
3136

@@ -95,7 +100,7 @@
95100
}
96101
}
97102

98-
# See https://docs.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables
103+
# See https://docs.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables # noqa: E501
99104

100105
if "GITHUB_WORKFLOW" in os.environ:
101106
SECRET_KEY = "cbo9e7%1c^ijxoit37^!kbfyikaet%z&*pm&4k(3#h*k%irylt"
@@ -115,13 +120,12 @@
115120
# Password validation
116121
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
117122

123+
_auth_pass_valid = "django.contrib.auth.password_validation"
118124
AUTH_PASSWORD_VALIDATORS = [
119-
{
120-
"NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator"
121-
},
122-
{"NAME": "django.contrib.auth.password_validation.MinimumLengthValidator"},
123-
{"NAME": "django.contrib.auth.password_validation.CommonPasswordValidator"},
124-
{"NAME": "django.contrib.auth.password_validation.NumericPasswordValidator"},
125+
{"NAME": f"{_auth_pass_valid}.UserAttributeSimilarityValidator"},
126+
{"NAME": f"{_auth_pass_valid}.MinimumLengthValidator"},
127+
{"NAME": f"{_auth_pass_valid}.CommonPasswordValidator"},
128+
{"NAME": f"{_auth_pass_valid}.NumericPasswordValidator"},
125129
]
126130

127131

@@ -149,7 +153,11 @@
149153
},
150154
},
151155
"loggers": {
152-
"django": {"handlers": ["console"], "level": "DEBUG", "propagate": True},
156+
"django": {
157+
"handlers": ["console"],
158+
"level": "DEBUG",
159+
"propagate": True,
160+
},
153161
"django.request": {
154162
"handlers": ["console"],
155163
"level": "DEBUG",
@@ -190,9 +198,13 @@
190198

191199
COMPRESS_PRECOMPILERS = (("text/x-scss", "django_libsass.SassCompiler"),)
192200

193-
COMPRESS_ENABLED = bool(strtobool(str(os.environ.get("DJANGO_COMPRESS_ENABLED", True))))
201+
COMPRESS_ENABLED = bool(
202+
strtobool(str(os.environ.get("DJANGO_COMPRESS_ENABLED", True)))
203+
)
194204

195-
COMPRESS_OFFLINE = bool(strtobool(str(os.environ.get("DJANGO_COMPRESS_OFFLINE", True))))
205+
COMPRESS_OFFLINE = bool(
206+
strtobool(str(os.environ.get("DJANGO_COMPRESS_OFFLINE", True)))
207+
)
196208

197209
LIBSASS_OUTPUT_STYLE = os.environ.get("DJANGO_LIBSASS_STYLE", "compressed")
198210

caselaw/urls.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
1. Import the include() function: from django.urls import include, path
1414
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
1515
"""
16+
# Third-party
1617
from django.conf.urls import url
1718
from django.contrib import admin
1819
from django.urls import include, path

caselaw/wsgi.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
88
"""
99

10+
# Standard library
1011
import os
1112

13+
# Third-party
1214
from django.core.wsgi import get_wsgi_application
1315

1416
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "caselaw.settings")

legal_db/admin.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
# Third-party
12
from django.contrib import admin
2-
33
from ordered_model.admin import OrderedModelAdmin
44

5-
from .models import Case, FAQ, Link, Scholarship
5+
from .models import FAQ, Case, Link, Scholarship
66

77

88
class CaseAdmin(admin.ModelAdmin):
@@ -27,7 +27,13 @@ class CaseAdmin(admin.ModelAdmin):
2727
# Customize the list
2828
list_display = ("name", "license", "status", "updated_at")
2929
list_filter = ["status", "license"]
30-
search_fields = ("name", "courts", "related_cases", "background", "summary")
30+
search_fields = (
31+
"name",
32+
"courts",
33+
"related_cases",
34+
"background",
35+
"summary",
36+
)
3137

3238

3339
class LinkAdmin(admin.ModelAdmin):

legal_db/apps.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# Third-party
12
from django.apps import AppConfig
23

34

0 commit comments

Comments
 (0)