Skip to content
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

48 django 1.10 compatibility #61

Merged
merged 5 commits into from
Sep 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions runtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,27 @@
"django.core.context_processors.request",
"treenav.context_processors.treenav_active",
),
TEMPLATES=[
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
"django.template.context_processors.request",
"treenav.context_processors.treenav_active",
],
},
},
],

SECRET_KEY='this-is-just-for-tests-so-not-that-secret',
ROOT_URLCONF='treenav.tests.urls',
)
Expand Down
1 change: 0 additions & 1 deletion treenav/templates/admin/treenav/menuitem/change_list.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{% extends "admin/mptt_change_list.html" %}
{% load i18n %}
{% load url from future %}

{% block object-tools-items %}
<li>
Expand Down
1 change: 0 additions & 1 deletion treenav/templates/treenav/menucrumbs.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{% load i18n %}
{% load url from future %}
{% if active_menu_items %}
<ul>
{% for item in active_menu_items %}
Expand Down
5 changes: 2 additions & 3 deletions treenav/templatetags/treenav_tags.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from django import template
from django.core.cache import cache
from django.template.loader import render_to_string
from django.template import RequestContext, Context

from treenav.models import MenuItem
from treenav.templatetags import CaktNode, parse_args_kwargs
Expand All @@ -25,9 +24,9 @@ def get_menu_item(slug):
def new_context(parent_context):
""" Create new context rather than modifying parent context """
if 'request' in parent_context:
return RequestContext(parent_context['request'])
return {'request': parent_context['request']}
else:
return Context()
return {}


class SingleLevelMenuNode(CaktNode):
Expand Down
16 changes: 6 additions & 10 deletions treenav/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.http import HttpRequest
from django.template.context import Context
from django.template import Template
from django.test import override_settings

from .base import TreeNavTestCase as TestCase
from treenav.context_processors import treenav_active
Expand All @@ -13,10 +14,9 @@
from treenav.tests import Team


@override_settings(ROOT_URLCONF='treenav.tests.urls')
class TreeNavTestCase(TestCase):

urls = 'treenav.tests.urls'

def setUp(self):
self.root = self.create_menu_item(**{
'label': 'Primary Navigation',
Expand Down Expand Up @@ -177,10 +177,9 @@ def test_active_url(self):
self.assertEqual(active_item.node, self.child)


@override_settings(ROOT_URLCONF='treenav.tests.urls')
class TreeNavViewTestCase(TestCase):

urls = 'treenav.tests.urls'

def setUp(self):
self.root = self.create_menu_item(
label='Primary Navigation',
Expand Down Expand Up @@ -251,11 +250,10 @@ def test_undefined_url(self):
self.assertEqual(response.status_code, 404)


@override_settings(ROOT_URLCONF='treenav.tests.urls')
class RefreshViewTestCase(TestCase):
"Admin view to trigger refresh of hrefs."

urls = 'treenav.tests.urls'

def setUp(self):
self.superuser = User.objects.create_user('test', '', 'test')
self.superuser.is_staff = True
Expand Down Expand Up @@ -298,11 +296,10 @@ def test_no_permission(self):
self.assertEqual(len(response.context['messages']), 0)


@override_settings(ROOT_URLCONF='treenav.tests.urls')
class ClearCacheViewTestCase(TestCase):
"Admin view to clear menu cache."

urls = 'treenav.tests.urls'

def setUp(self):
self.superuser = User.objects.create_user('test', '', 'test')
self.superuser.is_staff = True
Expand Down Expand Up @@ -341,10 +338,9 @@ def test_no_permission(self):
self.assertEqual(len(response.context['messages']), 0)


@override_settings(ROOT_URLCONF='treenav.tests.urls')
class SimultaneousReorderTestCase(TestCase):

urls = 'treenav.tests.urls'

def setUp(self):
self.root = self.create_menu_item(
label='Primary Navigation',
Expand Down