diff -Nru django-taggit-0.21.2/CHANGELOG.txt django-taggit-0.21.3/CHANGELOG.txt --- django-taggit-0.21.2/CHANGELOG.txt 2016-08-31 22:41:40.000000000 +0000 +++ django-taggit-0.21.3/CHANGELOG.txt 2016-10-08 03:22:31.000000000 +0000 @@ -1,6 +1,11 @@ Changelog ========= +0.21.3 (2016-10-07) +~~~~~~~~~~~~~~~~~~~ + * Fix list view + * https://github.com/alex/django-taggit/pull/444 + 0.21.2 (2016-08-31) ~~~~~~~~~~~~~~~~~~~ * Update Python version classifiers in setup.py diff -Nru django-taggit-0.21.2/debian/changelog django-taggit-0.21.3/debian/changelog --- django-taggit-0.21.2/debian/changelog 2016-09-07 11:05:54.000000000 +0000 +++ django-taggit-0.21.3/debian/changelog 2016-11-17 10:20:57.000000000 +0000 @@ -1,3 +1,10 @@ +django-taggit (0.21.3-1) unstable; urgency=medium + + * New upstream release. + * Change VCS-Git URL to https. + + -- Michal Čihař Thu, 17 Nov 2016 11:20:57 +0100 + django-taggit (0.21.2-1) unstable; urgency=medium * New upstream release. diff -Nru django-taggit-0.21.2/debian/control django-taggit-0.21.3/debian/control --- django-taggit-0.21.2/debian/control 2016-09-07 11:04:01.000000000 +0000 +++ django-taggit-0.21.3/debian/control 2016-11-16 12:33:23.000000000 +0000 @@ -19,8 +19,8 @@ python3-django (= 1:1.10-1), python3-django (= 1:1.10-2) Standards-Version: 3.9.8 -Vcs-Browser: http://anonscm.debian.org/gitweb/?p=python-modules/packages/django-taggit.git -Vcs-Git: git://anonscm.debian.org/python-modules/packages/django-taggit.git +Vcs-Browser: https://anonscm.debian.org/git/python-modules/packages/django-taggit.git +Vcs-Git: https://anonscm.debian.org/git/python-modules/packages/django-taggit.git Homepage: https://github.com/alex/django-taggit X-Python-Version: >= 2.6 X-Python3-Version: >= 3.2 diff -Nru django-taggit-0.21.2/debian/patches/0001-Add-missing-TEMPLATES-settings-to-runtests.py.patch django-taggit-0.21.3/debian/patches/0001-Add-missing-TEMPLATES-settings-to-runtests.py.patch --- django-taggit-0.21.2/debian/patches/0001-Add-missing-TEMPLATES-settings-to-runtests.py.patch 1970-01-01 00:00:00.000000000 +0000 +++ django-taggit-0.21.3/debian/patches/0001-Add-missing-TEMPLATES-settings-to-runtests.py.patch 2016-11-17 10:20:57.000000000 +0000 @@ -0,0 +1,29 @@ +From f17b969bfa18ba0335f95352ff301926e0b98535 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= +Date: Thu, 17 Nov 2016 11:32:33 +0100 +Subject: [PATCH 1/1] Add missing TEMPLATES settings to runtests.py + +--- + runtests.py | 6 ++++++ + 1 file changed, 6 insertions(+) + +diff --git a/runtests.py b/runtests.py +index 36a7d4e..731b177 100755 +--- a/runtests.py ++++ b/runtests.py +@@ -18,6 +18,12 @@ if not settings.configured: + 'tests', + ], + MIDDLEWARE_CLASSES=[], ++ TEMPLATES = [ ++ { ++ 'BACKEND': 'django.template.backends.django.DjangoTemplates', ++ 'APP_DIRS': True, ++ } ++ ], + ) + + +-- +2.10.2 + diff -Nru django-taggit-0.21.2/debian/patches/series django-taggit-0.21.3/debian/patches/series --- django-taggit-0.21.2/debian/patches/series 2016-06-21 13:12:15.000000000 +0000 +++ django-taggit-0.21.3/debian/patches/series 2016-11-17 10:20:57.000000000 +0000 @@ -1 +1,2 @@ +0001-Add-missing-TEMPLATES-settings-to-runtests.py.patch remove-isort.patch diff -Nru django-taggit-0.21.2/django_taggit.egg-info/PKG-INFO django-taggit-0.21.3/django_taggit.egg-info/PKG-INFO --- django-taggit-0.21.2/django_taggit.egg-info/PKG-INFO 2016-08-31 22:41:42.000000000 +0000 +++ django-taggit-0.21.3/django_taggit.egg-info/PKG-INFO 2016-10-08 03:24:02.000000000 +0000 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: django-taggit -Version: 0.21.2 +Version: 0.21.3 Summary: django-taggit is a reusable Django application for simple tagging. Home-page: http://github.com/alex/django-taggit/tree/master Author: Alex Gaynor diff -Nru django-taggit-0.21.2/django_taggit.egg-info/SOURCES.txt django-taggit-0.21.3/django_taggit.egg-info/SOURCES.txt --- django-taggit-0.21.2/django_taggit.egg-info/SOURCES.txt 2016-08-31 22:41:42.000000000 +0000 +++ django-taggit-0.21.3/django_taggit.egg-info/SOURCES.txt 2016-10-08 03:24:02.000000000 +0000 @@ -68,5 +68,7 @@ tests/models.py tests/settings.py tests/tests.py +tests/urls.py tests/migrations/0001_initial.py -tests/migrations/__init__.py \ No newline at end of file +tests/migrations/__init__.py +tests/templates/tests/food_tag_list.html \ No newline at end of file diff -Nru django-taggit-0.21.2/PKG-INFO django-taggit-0.21.3/PKG-INFO --- django-taggit-0.21.2/PKG-INFO 2016-08-31 22:41:42.000000000 +0000 +++ django-taggit-0.21.3/PKG-INFO 2016-10-08 03:24:02.000000000 +0000 @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: django-taggit -Version: 0.21.2 +Version: 0.21.3 Summary: django-taggit is a reusable Django application for simple tagging. Home-page: http://github.com/alex/django-taggit/tree/master Author: Alex Gaynor diff -Nru django-taggit-0.21.2/taggit/__init__.py django-taggit-0.21.3/taggit/__init__.py --- django-taggit-0.21.2/taggit/__init__.py 2016-08-31 22:41:40.000000000 +0000 +++ django-taggit-0.21.3/taggit/__init__.py 2016-10-08 03:23:30.000000000 +0000 @@ -1,3 +1,3 @@ -VERSION = (0, 21, 2) +VERSION = (0, 21, 3) default_app_config = 'taggit.apps.TaggitAppConfig' diff -Nru django-taggit-0.21.2/taggit/views.py django-taggit-0.21.3/taggit/views.py --- django-taggit-0.21.2/taggit/views.py 2015-11-25 17:00:51.000000000 +0000 +++ django-taggit-0.21.3/taggit/views.py 2016-10-08 03:21:50.000000000 +0000 @@ -10,11 +10,42 @@ def tagged_object_list(request, slug, queryset, **kwargs): if callable(queryset): queryset = queryset() - tag = get_object_or_404(Tag, slug=slug) - qs = queryset.filter(pk__in=TaggedItem.objects.filter( - tag=tag, content_type=ContentType.objects.get_for_model(queryset.model) - ).values_list("object_id", flat=True)) - if "extra_context" not in kwargs: - kwargs["extra_context"] = {} - kwargs["extra_context"]["tag"] = tag - return ListView.as_view(request, qs, **kwargs) + queryset_model = ContentType.objects.get_for_model(queryset.model) + kwargs["slug"] = slug + tag_list_view = type( + str('TagListView'), + (TagListMixin, ListView), + { + 'model': queryset_model, + 'queryset': queryset + } + ) + return tag_list_view.as_view()(request, **kwargs) + + +class TagListMixin(object): + tag_suffix = '_tag' + + def dispatch(self, request, *args, **kwargs): + slug = kwargs.pop('slug') + self.tag = get_object_or_404(Tag, slug=slug) + return super(TagListMixin, self).dispatch(request, *args, **kwargs) + + def get_queryset(self, **kwargs): + qs = super(TagListMixin, self).get_queryset(**kwargs) + return qs.filter( + pk__in=TaggedItem.objects.filter( + tag=self.tag, content_type=ContentType.objects.get_for_model(qs.model) + ).values_list("object_id", flat=True)) + + def get_template_names(self): + if self.tag_suffix: + self.template_name_suffix = self.tag_suffix + self.template_name_suffix + return super(TagListMixin, self).get_template_names() + + def get_context_data(self, **kwargs): + context = super(TagListMixin, self).get_context_data(**kwargs) + if "extra_context" not in context: + context["extra_context"] = {} + context["extra_context"]["tag"] = self.tag + return context diff -Nru django-taggit-0.21.2/tests/settings.py django-taggit-0.21.3/tests/settings.py --- django-taggit-0.21.2/tests/settings.py 2016-05-23 14:18:35.000000000 +0000 +++ django-taggit-0.21.3/tests/settings.py 2016-10-08 03:21:50.000000000 +0000 @@ -11,6 +11,13 @@ 'tests', ] +TEMPLATES = [ + { + 'BACKEND': 'django.template.backends.django.DjangoTemplates', + 'APP_DIRS': True, + } +] + MIDDLEWARE_CLASSES = [] SECRET_KEY = 'secretkey' diff -Nru django-taggit-0.21.2/tests/templates/tests/food_tag_list.html django-taggit-0.21.3/tests/templates/tests/food_tag_list.html --- django-taggit-0.21.2/tests/templates/tests/food_tag_list.html 1970-01-01 00:00:00.000000000 +0000 +++ django-taggit-0.21.3/tests/templates/tests/food_tag_list.html 2016-10-08 03:21:50.000000000 +0000 @@ -0,0 +1,10 @@ + + + + + Title + + + + + \ No newline at end of file diff -Nru django-taggit-0.21.2/tests/tests.py django-taggit-0.21.3/tests/tests.py --- django-taggit-0.21.2/tests/tests.py 2016-08-26 06:20:33.000000000 +0000 +++ django-taggit-0.21.3/tests/tests.py 2016-10-08 03:21:50.000000000 +0000 @@ -12,7 +12,7 @@ from django.core.exceptions import ImproperlyConfigured, ValidationError from django.core.management import call_command from django.db import connection, models -from django.test import TestCase, TransactionTestCase +from django.test import RequestFactory, TestCase, TransactionTestCase from django.test.utils import override_settings from django.utils.encoding import force_text @@ -28,6 +28,7 @@ from taggit.managers import TaggableManager, _TaggableManager from taggit.models import Tag, TaggedItem +from taggit.views import tagged_object_list, TagListMixin from taggit.utils import (_related_model, _remote_field, edit_string_for_tags, parse_tags) @@ -958,3 +959,42 @@ def test_django_checks(self): call_command('check', tag=['models']) + + +from django.views.generic.list import ListView + + +class FoodTagListView(TagListMixin, ListView): + model = Food + + +@override_settings(ROOT_URLCONF='tests.urls') +class TagListViewTests(BaseTaggingTestCase, TestCase): + model = Food + + def setUp(self): + self.factory = RequestFactory() + self.slug = 'green' + self.apple = self.model.objects.create(name='apple') + self.apple.tags.add(self.slug) + self.strawberry = self.model.objects.create(name='strawberry') + self.strawberry.tags.add('red') + + def test_url_request_returns_view(self): + request = self.factory.get('/food/tags/{}/'.format(self.slug)) + queryset = self.model.objects.all() + response = tagged_object_list(request, self.slug, queryset) + self.assertEqual(response.status_code, 200) + self.assertIn(self.apple, response.context_data['object_list']) + self.assertNotIn(self.strawberry, response.context_data['object_list']) + self.assertEqual( + self.apple.tags.first(), + response.context_data['extra_context']['tag'] + ) + + def test_list_view_returns_single(self): + response = self.client.get('/food/tags/{}/'.format(self.slug)) + self.assertEqual(response.status_code, 200) + self.assertIn(self.apple, response.context_data['object_list']) + self.assertNotIn(self.strawberry, response.context_data['object_list']) + diff -Nru django-taggit-0.21.2/tests/urls.py django-taggit-0.21.3/tests/urls.py --- django-taggit-0.21.2/tests/urls.py 1970-01-01 00:00:00.000000000 +0000 +++ django-taggit-0.21.3/tests/urls.py 2016-10-08 03:21:50.000000000 +0000 @@ -0,0 +1,8 @@ +from django.conf.urls import url + +from .tests import FoodTagListView + +urlpatterns = [ + url(r'^food/tags/(?P[a-z0-9_-]+)/$', FoodTagListView.as_view(), + name='food-tag-list'), +]