mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-01-21 07:55:00 +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-axes (>= 3.0.3)
|
||||
, python3-django-captcha
|
||||
, python3-django-stronghold
|
||||
, python3-django-stronghold (>= 0.3.0)
|
||||
, python3-gi
|
||||
, python3-psutil
|
||||
, python3-requests
|
||||
|
||||
@ -277,7 +277,7 @@ def configure_django():
|
||||
LOGIN_URL='users:login',
|
||||
LOGIN_REDIRECT_URL='index',
|
||||
MESSAGE_TAGS={message_constants.ERROR: 'danger'},
|
||||
MIDDLEWARE_CLASSES=(
|
||||
MIDDLEWARE=(
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.locale.LocaleMiddleware',
|
||||
|
||||
@ -24,6 +24,7 @@ from django.contrib import messages
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.shortcuts import render
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
import logging
|
||||
|
||||
@ -38,7 +39,7 @@ from . import views
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SetupMiddleware(object):
|
||||
class SetupMiddleware(MiddlewareMixin):
|
||||
"""Django middleware to show pre-setup message and setup progress."""
|
||||
|
||||
@staticmethod
|
||||
@ -92,7 +93,7 @@ class SetupMiddleware(object):
|
||||
return view(request, setup_helper=module.setup_helper)
|
||||
|
||||
|
||||
class AdminRequiredMiddleware(object):
|
||||
class AdminRequiredMiddleware(MiddlewareMixin):
|
||||
"""Django middleware for authenticating requests for admin areas."""
|
||||
|
||||
@staticmethod
|
||||
@ -106,7 +107,7 @@ class AdminRequiredMiddleware(object):
|
||||
raise PermissionDenied
|
||||
|
||||
|
||||
class FirstSetupMiddleware(object):
|
||||
class FirstSetupMiddleware(MiddlewareMixin):
|
||||
"""Django middleware to block all interactions before first setup."""
|
||||
|
||||
@staticmethod
|
||||
|
||||
@ -20,17 +20,19 @@ Django middleware to redirect to firstboot wizard if it has not be run
|
||||
yet.
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from django.conf import settings
|
||||
from django.http.response import HttpResponseRedirect
|
||||
from django.urls import reverse
|
||||
from django.conf import settings
|
||||
import logging
|
||||
from django.utils.deprecation import MiddlewareMixin
|
||||
|
||||
from plinth.modules import first_boot
|
||||
|
||||
LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class FirstBootMiddleware(object):
|
||||
class FirstBootMiddleware(MiddlewareMixin):
|
||||
"""Forward to firstboot page if firstboot isn't finished yet."""
|
||||
|
||||
@staticmethod
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user