diff --git a/requirements.txt b/requirements.txt --- a/requirements.txt +++ b/requirements.txt @@ -4,9 +4,9 @@ # Runtime dependencies beautifulsoup4 -Django >= 1.11.0, < 2.0 +django < 3 django-cors-headers -djangorestframework >= 3.4.0 +djangorestframework django_webpack_loader django_js_reverse docutils diff --git a/swh/web/common/exc.py b/swh/web/common/exc.py --- a/swh/web/common/exc.py +++ b/swh/web/common/exc.py @@ -64,31 +64,31 @@ status=error_code) -def swh_handle400(request): +def swh_handle400(request, exception=None): """ Custom Django HTTP error 400 handler for swh-web. """ - error_description = 'The server cannot process the request to %s due to '\ - 'something that is perceived to be a client error.' %\ - escape(request.META['PATH_INFO']) + error_description = ('The server cannot process the request to %s due to ' + 'something that is perceived to be a client error.' % + escape(request.META['PATH_INFO'])) return _generate_error_page(request, 400, error_description) -def swh_handle403(request): +def swh_handle403(request, exception=None): """ Custom Django HTTP error 403 handler for swh-web. """ - error_description = 'The resource %s requires an authentication.' %\ - escape(request.META['PATH_INFO']) + error_description = ('The resource %s requires an authentication.' % + escape(request.META['PATH_INFO'])) return _generate_error_page(request, 403, error_description) -def swh_handle404(request): +def swh_handle404(request, exception=None): """ Custom Django HTTP error 404 handler for swh-web. """ - error_description = 'The resource %s could not be found on the server.' %\ - escape(request.META['PATH_INFO']) + error_description = ('The resource %s could not be found on the server.' % + escape(request.META['PATH_INFO'])) return _generate_error_page(request, 404, error_description) @@ -96,9 +96,9 @@ """ Custom Django HTTP error 500 handler for swh-web. """ - error_description = 'An unexpected condition was encountered when '\ - 'requesting resource %s.' %\ - escape(request.META['PATH_INFO']) + error_description = ('An unexpected condition was encountered when ' + 'requesting resource %s.' % + escape(request.META['PATH_INFO'])) return _generate_error_page(request, 500, error_description) diff --git a/tox.ini b/tox.ini --- a/tox.ini +++ b/tox.ini @@ -1,11 +1,13 @@ [tox] -envlist=flake8,mypy,py3 +envlist=flake8,mypy,py3-django{1,2} [testenv] extras = testing deps = pytest-cov + django1: django>=1.11,<2 + django2: django>=2,<3 commands = pytest \ slow: --hypothesis-profile=swh-web \