mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
Support Django 2.0
This is the final change required for Django 2.0 support. Instead of using MIDDLEWARE_CLASSES use MIDDLEWARE setting. Support for new style middleware was provided in version 0.3.0, so depend on that version. Django built-in middleware already supports new style and plinth middleware will now support new style. The actual semantics of the middleware don't need changes. See: https://docs.djangoproject.com/en/2.0/topics/http/middleware/#upgrading-pre-django-1-10-style-middleware Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
474b363f0b
commit
1da594c32d
2
debian/control
vendored
2
debian/control
vendored
@ -28,7 +28,7 @@ Build-Depends: debhelper (>= 10~)
|
|||||||
, python3-django (>= 1.11)
|
, python3-django (>= 1.11)
|
||||||
, python3-django-axes (>= 3.0.3)
|
, python3-django-axes (>= 3.0.3)
|
||||||
, python3-django-captcha
|
, python3-django-captcha
|
||||||
, python3-django-stronghold
|
, python3-django-stronghold (>= 0.3.0)
|
||||||
, python3-gi
|
, python3-gi
|
||||||
, python3-psutil
|
, python3-psutil
|
||||||
, python3-requests
|
, python3-requests
|
||||||
|
|||||||
@ -277,7 +277,7 @@ def configure_django():
|
|||||||
LOGIN_URL='users:login',
|
LOGIN_URL='users:login',
|
||||||
LOGIN_REDIRECT_URL='index',
|
LOGIN_REDIRECT_URL='index',
|
||||||
MESSAGE_TAGS={message_constants.ERROR: 'danger'},
|
MESSAGE_TAGS={message_constants.ERROR: 'danger'},
|
||||||
MIDDLEWARE_CLASSES=(
|
MIDDLEWARE=(
|
||||||
'django.middleware.security.SecurityMiddleware',
|
'django.middleware.security.SecurityMiddleware',
|
||||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
'django.middleware.locale.LocaleMiddleware',
|
'django.middleware.locale.LocaleMiddleware',
|
||||||
|
|||||||
@ -24,6 +24,7 @@ from django.contrib import messages
|
|||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
from django.core.exceptions import PermissionDenied
|
from django.core.exceptions import PermissionDenied
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
|
from django.utils.deprecation import MiddlewareMixin
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ from . import views
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class SetupMiddleware(object):
|
class SetupMiddleware(MiddlewareMixin):
|
||||||
"""Django middleware to show pre-setup message and setup progress."""
|
"""Django middleware to show pre-setup message and setup progress."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -92,7 +93,7 @@ class SetupMiddleware(object):
|
|||||||
return view(request, setup_helper=module.setup_helper)
|
return view(request, setup_helper=module.setup_helper)
|
||||||
|
|
||||||
|
|
||||||
class AdminRequiredMiddleware(object):
|
class AdminRequiredMiddleware(MiddlewareMixin):
|
||||||
"""Django middleware for authenticating requests for admin areas."""
|
"""Django middleware for authenticating requests for admin areas."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -106,7 +107,7 @@ class AdminRequiredMiddleware(object):
|
|||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
|
|
||||||
|
|
||||||
class FirstSetupMiddleware(object):
|
class FirstSetupMiddleware(MiddlewareMixin):
|
||||||
"""Django middleware to block all interactions before first setup."""
|
"""Django middleware to block all interactions before first setup."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@ -20,17 +20,19 @@ Django middleware to redirect to firstboot wizard if it has not be run
|
|||||||
yet.
|
yet.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import logging
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.http.response import HttpResponseRedirect
|
from django.http.response import HttpResponseRedirect
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from django.conf import settings
|
from django.utils.deprecation import MiddlewareMixin
|
||||||
import logging
|
|
||||||
|
|
||||||
from plinth.modules import first_boot
|
from plinth.modules import first_boot
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class FirstBootMiddleware(object):
|
class FirstBootMiddleware(MiddlewareMixin):
|
||||||
"""Forward to firstboot page if firstboot isn't finished yet."""
|
"""Forward to firstboot page if firstboot isn't finished yet."""
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
2
setup.py
2
setup.py
@ -212,7 +212,7 @@ setuptools.setup(
|
|||||||
'django >= 1.11.0',
|
'django >= 1.11.0',
|
||||||
'django-bootstrap-form',
|
'django-bootstrap-form',
|
||||||
'django-simple-captcha',
|
'django-simple-captcha',
|
||||||
'django-stronghold',
|
'django-stronghold >= 0.3.0',
|
||||||
'psutil',
|
'psutil',
|
||||||
'python-apt',
|
'python-apt',
|
||||||
'python-augeas',
|
'python-augeas',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user