[Python-modules-commits] [django-taggit] 01/03: Imported Upstream version 0.20.2
Michal Cihar
nijel at moszumanska.debian.org
Sun Jul 24 07:55:28 UTC 2016
This is an automated email from the git hooks/post-receive script.
nijel pushed a commit to branch master
in repository django-taggit.
commit 3beaea0af59abfd8aebe209534502d8e4c346cf2
Author: Michal Čihař <nijel at debian.org>
Date: Sun Jul 24 09:49:20 2016 +0200
Imported Upstream version 0.20.2
---
CHANGELOG.txt | 5 +++++
PKG-INFO | 2 +-
django_taggit.egg-info/PKG-INFO | 2 +-
taggit/__init__.py | 2 +-
taggit/managers.py | 4 ++--
tests/tests.py | 31 +++++++++++++++++++++++++++++++
6 files changed, 41 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 4137646..617f879 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,6 +1,11 @@
Changelog
=========
+0.20.2 (2016-07-11)
+~~~~~~~~~~~~~~~~~~~
+ * Add extra_filters argument to the manager's most_common method
+ * https://github.com/alex/django-taggit/pull/422
+
0.20.1 (2016-06-23)
~~~~~~~~~~~~~~~~~~~
* Specify `app_label` for `Tag` and `TaggedItem`
diff --git a/PKG-INFO b/PKG-INFO
index 3d9f5ca..33aaea8 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: django-taggit
-Version: 0.20.1
+Version: 0.20.2
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 --git a/django_taggit.egg-info/PKG-INFO b/django_taggit.egg-info/PKG-INFO
index 3d9f5ca..33aaea8 100644
--- a/django_taggit.egg-info/PKG-INFO
+++ b/django_taggit.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.1
Name: django-taggit
-Version: 0.20.1
+Version: 0.20.2
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 --git a/taggit/__init__.py b/taggit/__init__.py
index 6fcd25e..ff6c048 100644
--- a/taggit/__init__.py
+++ b/taggit/__init__.py
@@ -1,3 +1,3 @@
-VERSION = (0, 20, 1)
+VERSION = (0, 20, 2)
default_app_config = 'taggit.apps.TaggitAppConfig'
diff --git a/taggit/managers.py b/taggit/managers.py
index eb4bf44..91699a0 100644
--- a/taggit/managers.py
+++ b/taggit/managers.py
@@ -335,8 +335,8 @@ class _TaggableManager(models.Manager):
model=self.through.tag_model(), pk_set=None, using=db,
)
- def most_common(self, min_count=None):
- queryset = self.get_queryset().annotate(
+ def most_common(self, min_count=None, extra_filters=None):
+ queryset = self.get_queryset(extra_filters).annotate(
num_times=models.Count(self.through.tag_relname())
).order_by('-num_times')
if min_count:
diff --git a/tests/tests.py b/tests/tests.py
index ae49d57..4575f51 100644
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -733,6 +733,37 @@ class TaggableManagerOfficialTestCase(TaggableManagerTestCase):
tag_info = self.tag_model.objects.filter(officialfood__in=[apple.id, pear.id], name='green').annotate(models.Count('name'))
self.assertEqual(tag_info[0].name__count, 2)
+ def test_most_common_extra_filters(self):
+ apple = self.food_model.objects.create(name='apple')
+ apple.tags.add('red')
+ apple.tags.add('green')
+
+ orange = self.food_model.objects.create(name='orange')
+ orange.tags.add('orange')
+ orange.tags.add('red')
+
+ pear = self.food_model.objects.create(name='pear')
+ pear.tags.add('green')
+ pear.tags.add('yellow')
+
+ self.assert_tags_equal(
+ self.food_model.tags.most_common(
+ min_count=2, extra_filters={
+ 'officialfood__name__in': ['pear', 'apple']
+ })[:1],
+ ['green'],
+ sort=False
+ )
+
+ self.assert_tags_equal(
+ self.food_model.tags.most_common(
+ min_count=2, extra_filters={
+ 'officialfood__name__in': ['orange', 'apple']
+ })[:1],
+ ['red'],
+ sort=False
+ )
+
class TaggableManagerInitializationTestCase(TaggableManagerTestCase):
"""Make sure manager override defaults and sets correctly."""
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/django-taggit.git
More information about the Python-modules-commits
mailing list