Skip to content

Commit

Permalink
Version "0.3-caktus" changes: Django 1.11 support
Browse files Browse the repository at this point in the history
  • Loading branch information
kmtracey committed Oct 29, 2020
2 parents d8d23c1 + dca0238 commit f191d2d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 12 deletions.
4 changes: 2 additions & 2 deletions requirements/tests.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
docutils
milkman
model_mommy
django-ttag>=2.3
django-discover-runner
coverage
flake8
flake8
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion sorter/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2"
__version__ = "0.3-caktus"
3 changes: 2 additions & 1 deletion sorter/templatetags/sorter_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
16 changes: 15 additions & 1 deletion sorter/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
10 changes: 3 additions & 7 deletions sorter/tests.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
from django import template
from django.contrib.auth.models import User
from django.contrib.admin.models import LogEntry
from django.http import HttpResponse
from django.template import Library, Template, Context, TemplateSyntaxError
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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit f191d2d

Please sign in to comment.