From 9b0eeff865bb39454f201eb82b460fdc27899a90 Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 29 Nov 2018 12:27:07 -0800 Subject: Django - Add Infractions API (#149) * add Infraction model and serialiser The model in not finalised. * fix mix up of serialiser fields * remove explicit id field and add foreign keys * remove unused import * disallow null for user * add view set and route * fix model and create migration * fix typo choice => choices * specify names for reverse accessors for User FKs * add django-filter * add filters to view set * add string dunder method to model * add list/retrieve tests * make reason nullable * add creation tests * remove support for PUT and DELETE * add support for PATCH * assert timestamps using strings rather than datetimes This is done to keep 3.6 support; datetime.fromisoformat() is 3.7+ * assert inserted_at * add unauthenticated tests * add bad value tests for list filters and retrieve * remove prefetch cache invalidation * make __str__ more descriptive * add field validation & remove note type * add tests for field validation * fix coverage for Infraction string dunder test * fix coverage (for sure this time) * return 400 for partial updates with frozen fields * add expanded serialiser and endpoints * test expanded endpoints * remove extra retrieve call * remove unnecessary try-finally blocks * remove extra blank line * document endpoints (except expanded) * document expanded routes * fix wrong routes in docstring (/infraction -> /infractions) * make merge migration --- pysite/settings.py | 1 + 1 file changed, 1 insertion(+) (limited to 'pysite/settings.py') diff --git a/pysite/settings.py b/pysite/settings.py index c3373250..0175fb46 100644 --- a/pysite/settings.py +++ b/pysite/settings.py @@ -73,6 +73,7 @@ INSTALLED_APPS = [ 'django.contrib.staticfiles', 'django_hosts', + 'django_filters', 'rest_framework', 'rest_framework.authtoken' ] -- cgit v1.2.3 From 262734f65cee0fd615ab93490d62c6d23dfcf533 Mon Sep 17 00:00:00 2001 From: Johannes Christ Date: Sun, 30 Dec 2018 14:35:47 +0100 Subject: Set up `django-crispy-forms`. --- pysite/settings.py | 1 + setup.py | 1 + 2 files changed, 2 insertions(+) (limited to 'pysite/settings.py') diff --git a/pysite/settings.py b/pysite/settings.py index 0175fb46..16473280 100644 --- a/pysite/settings.py +++ b/pysite/settings.py @@ -72,6 +72,7 @@ INSTALLED_APPS = [ 'django.contrib.messages', 'django.contrib.staticfiles', + 'crispy_forms', 'django_hosts', 'django_filters', 'rest_framework', diff --git a/setup.py b/setup.py index e2f03070..a5eb9c38 100644 --- a/setup.py +++ b/setup.py @@ -17,6 +17,7 @@ setup( 'django>=2.1.1', 'djangorestframework>=3.9.0', 'djangorestframework-bulk>=0.2.1', + 'django-crispy-forms>=1.7.2', 'django-hosts>=3.0', 'django-environ>=0.4.5', 'django-filter>=2.0.0', -- cgit v1.2.3 From 76d7e392f8cd56e695c87542176b9f404b369071 Mon Sep 17 00:00:00 2001 From: Johannes Christ Date: Fri, 4 Jan 2019 23:20:00 +0100 Subject: Default to `INFO` log level. --- pysite/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pysite/settings.py') diff --git a/pysite/settings.py b/pysite/settings.py index 16473280..b27e2a41 100644 --- a/pysite/settings.py +++ b/pysite/settings.py @@ -216,7 +216,7 @@ LOGGING = { # use `DEBUG` if we're running in debug mode but not # testing. Use `ERROR` if we're running tests, else # default to using `WARN`. - 'DEBUG' + 'INFO' if DEBUG and 'test' not in sys.argv else ( 'ERROR' -- cgit v1.2.3