Merge pull request #16840 from edx/bmedx/django111_conditional_birdcage

Make all uses of birdcage conditional, should fix 1.11 errors
This commit is contained in:
Brian Mesick
2017-12-11 14:51:48 -05:00
committed by GitHub
5 changed files with 41 additions and 4 deletions

View File

@@ -45,6 +45,9 @@ import imp
import os
import sys
from datetime import timedelta
import django
import lms.envs.common
# Although this module itself may not use these imported variables, other dependent modules may.
from lms.envs.common import (
@@ -433,6 +436,13 @@ simplefilter('ignore')
################################# Middleware ###################################
# TODO: Remove Django 1.11 upgrade shim
# SHIM: Remove birdcage references post-1.11 upgrade as it is only in place to help during that deployment
if django.VERSION < (1, 9):
_csrf_middleware = 'birdcage.v1_11.csrf.CsrfViewMiddleware'
else:
_csrf_middleware = 'django.middleware.csrf.CsrfViewMiddleware'
MIDDLEWARE_CLASSES = [
'crum.CurrentRequestUserMiddleware',
'request_cache.middleware.RequestCache',
@@ -442,7 +452,7 @@ MIDDLEWARE_CLASSES = [
'openedx.core.djangoapps.header_control.middleware.HeaderControlMiddleware',
'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'birdcage.v1_11.csrf.CsrfViewMiddleware',
_csrf_middleware,
'django.contrib.sites.middleware.CurrentSiteMiddleware',
# Instead of SessionMiddleware, we use a more secure version