New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug 1401246: Use relative URIs for redirects in Django 1.9 and later #4807

Merged
merged 3 commits into from May 22, 2018
Jump to file or symbol
Failed to load files and symbols.
+9 −8
Diff settings

Always

Just for now

Next

bug 1401246: Determine Django version in settings

Determine the Django version for feature update purposes once in
settings, so that we don't duplicate the same version check with two
imports everywhere.
  • Loading branch information...
jwhitlock committed May 22, 2018
commit 067382bc01c44627256fd1648ff4526ee196d870
View
@@ -31,6 +31,12 @@ def __call__(self, value):
return tuple((value, value) for value in split_values)
# For the Django 1.11 update effort - Are we at least at this version?
_dj_version = LooseVersion(get_version())
DJANGO_1_9 = _dj_version >= LooseVersion('1.9')
DJANGO_1_10 = _dj_version >= LooseVersion('1.10')
DJANGO_1_11 = _dj_version >= LooseVersion('1.11')

This comment has been minimized.

@escattone

escattone May 22, 2018

Member

❤️ These are nice to have!

DEBUG = config('DEBUG', default=False, cast=bool)
ROOT = dirname(dirname(dirname(os.path.abspath(__file__))))
@@ -447,7 +453,7 @@ def _get_locales():
# Django 1.9 and lower need protection from BREACH attacks
# Django 1.10 include BREACH protection in CsrfViewMiddleware
_NEED_DEBREACH = LooseVersion(get_version()) < LooseVersion('1.10')
_NEED_DEBREACH = not DJANGO_1_10
if _NEED_DEBREACH:
_CSRF_CONTEXT_PROCESSOR = 'debreach.context_processors.csrf'
else:
View
@@ -1,7 +1,4 @@
from distutils.version import LooseVersion
from decorator_include import decorator_include
from django import get_version
from django.conf import settings
from django.conf.urls import include, url
from django.contrib import admin
@@ -73,7 +70,7 @@ def serve_from_media_root(request, path):
url(r'^admin/wiki/document/purge/',
purge_view,
name='wiki.admin_bulk_purge')]
if LooseVersion(get_version()) >= LooseVersion('1.9'):
if settings.DJANGO_1_9:
# We don't worry about decorating the views within django.contrib.admin
# with "never_cache", since most have already been decorated, and the
# remaining can be safely cached.
View
@@ -1,9 +1,7 @@
"""Feeds for documents"""
import datetime
import json
from distutils.version import LooseVersion
from django import get_version
from django.conf import settings
from django.contrib.syndication.views import Feed
from django.db.models import F
@@ -110,7 +108,7 @@ def item_categories(self, document):
class DocumentJSONFeedGenerator(SyndicationFeed):
"""JSON feed generator for Documents
TODO: Someday maybe make this into a JSON Activity Stream?"""
if LooseVersion(get_version()) >= LooseVersion('1.9'):
if settings.DJANGO_1_9:
content_type = 'application/json'
else:
mime_type = 'application/json'
ProTip! Use n and p to navigate between commits in a pull request.