diff --git a/requirements/tests.txt b/requirements/tests.txt index bb4c15a..522b1b2 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -1,6 +1,6 @@ docutils -milkman +model_mommy django-ttag>=2.3 django-discover-runner coverage -flake8 \ No newline at end of file +flake8 diff --git a/setup.py b/setup.py index 204cc97..fe03807 100644 --- a/setup.py +++ b/setup.py @@ -37,6 +37,9 @@ def find_version(*file_paths): "Development Status :: 4 - Beta", 'Environment :: Web Environment', 'Framework :: Django', + 'Framework :: Django :: 1.9', + 'Framework :: Django :: 1.10', + 'Framework :: Django :: 1.11', 'Intended Audience :: Developers', 'License :: OSI Approved :: BSD License', 'Operating System :: OS Independent', diff --git a/sorter/__init__.py b/sorter/__init__.py index 0988857..1878d2d 100644 --- a/sorter/__init__.py +++ b/sorter/__init__.py @@ -1 +1 @@ -__version__ = "0.2" +__version__ = "0.3-caktus" diff --git a/sorter/templatetags/sorter_tags.py b/sorter/templatetags/sorter_tags.py index 1b4e7bc..19b6642 100644 --- a/sorter/templatetags/sorter_tags.py +++ b/sorter/templatetags/sorter_tags.py @@ -145,7 +145,8 @@ def as_value(self, data, context): {'sort_fields': get_text_list(parts, _('and'))}) extra_context = dict(data, title=title, label=label, url=url, query=query) - return render_to_string(self.using(data), extra_context, context) + extra_context.update(context.flatten()) + return render_to_string(self.using(data), extra_context) def find_query(self, wanted, orderings, default): """ diff --git a/sorter/test_settings.py b/sorter/test_settings.py index ce316ea..2f3a9f8 100644 --- a/sorter/test_settings.py +++ b/sorter/test_settings.py @@ -15,6 +15,20 @@ 'sorter', ] -TEST_RUNNER = 'discover_runner.DiscoverRunner' +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'APP_DIRS': True, + 'OPTIONS': { + 'context_processors': ( + "django.contrib.auth.context_processors.auth", + ), + 'builtins': [ + 'sorter.templatetags.sorter_tags', + 'sorter.tests', + ] + }, + }, +] SECRET_KEY = 'something-something' diff --git a/sorter/tests.py b/sorter/tests.py index 1c193c4..be51550 100644 --- a/sorter/tests.py +++ b/sorter/tests.py @@ -1,4 +1,3 @@ -from django import template from django.contrib.auth.models import User from django.contrib.admin.models import LogEntry from django.http import HttpResponse @@ -6,16 +5,13 @@ from django.test import TestCase from django.test.client import RequestFactory -from milkman.dairy import milkman +from model_mommy import mommy from sorter.conf import settings from sorter.utils import cycle_pairs register = Library() -template.add_to_builtins('sorter.templatetags.sorter_tags') -template.add_to_builtins('sorter.tests') - @register.filter def sorter_tests_pks(value): @@ -44,7 +40,7 @@ def tearDown(self): settings.SORTER_ALLOWED_CRITERIA = self.old_sorter_allowed_criteria def create_entries(self, count, **kwargs): - entries = [milkman.deliver(LogEntry, **kwargs) for i in range(count)] + entries = [mommy.make(LogEntry, **kwargs) for i in range(count)] return LogEntry.objects.filter(pk__in=[entry.pk for entry in entries]) def create_response(self, request, template, context=None): @@ -118,7 +114,7 @@ def test_request_not_in_context(self): def test_multiple_sorting(self): - testuser = milkman.deliver(User) + testuser = mommy.make(User) testuser.set_password("letmein") testuser.save()