diff options
-rw-r--r-- | debian/.git-dpm | 8 | ||||
-rw-r--r-- | debian/patches/django-1.7-compat.patch | 18 | ||||
-rw-r--r-- | debian/patches/fix-testsuite.patch | 19 | ||||
-rw-r--r-- | debian/patches/fix_calc_tag_weight | 20 | ||||
-rw-r--r-- | tagging/models.py | 15 | ||||
-rw-r--r-- | tagging/tests/settings.py | 22 | ||||
-rw-r--r-- | tagging/utils.py | 2 |
7 files changed, 70 insertions, 34 deletions
diff --git a/debian/.git-dpm b/debian/.git-dpm new file mode 100644 index 0000000..240eef7 --- /dev/null +++ b/debian/.git-dpm @@ -0,0 +1,8 @@ +# see git-dpm(1) from git-dpm package +210bfd7f97afe0162e682cbd2530115cf09fd51d +210bfd7f97afe0162e682cbd2530115cf09fd51d +29425a36c920e9b54e5860429ef3e3ce639fb155 +29425a36c920e9b54e5860429ef3e3ce639fb155 +python-django-tagging_0.3.1.orig.tar.gz +f737bff307a21175b0dbacdb7969cd6bfff6f6ea +31531 diff --git a/debian/patches/django-1.7-compat.patch b/debian/patches/django-1.7-compat.patch index 4e50ffe..3b388e3 100644 --- a/debian/patches/django-1.7-compat.patch +++ b/debian/patches/django-1.7-compat.patch @@ -1,11 +1,21 @@ -Description: Add django 1.7 compatibility -Author: Raphaël Hertzog <hertzog@debian.org> +From 210bfd7f97afe0162e682cbd2530115cf09fd51d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rapha=C3=ABl=20Hertzog?= <hertzog@debian.org> +Date: Thu, 8 Oct 2015 11:51:55 -0700 +Subject: Add django 1.7 compatibility + Bug-Debian: http://bugs.debian.org/755624 Origin: vendor Last-Update: 2014-08-06 ---- python-django-tagging-0.3.1.orig/tagging/models.py -+++ python-django-tagging-0.3.1/tagging/models.py +Patch-Name: django-1.7-compat.patch +--- + tagging/models.py | 15 ++++++++++++--- + 1 file changed, 12 insertions(+), 3 deletions(-) + +diff --git a/tagging/models.py b/tagging/models.py +index 860cf81..e13b077 100644 +--- a/tagging/models.py ++++ b/tagging/models.py @@ -17,6 +17,8 @@ from tagging import settings from tagging.utils import calculate_cloud, get_tag_list, get_queryset_and_model, parse_tag_input from tagging.utils import LOGARITHMIC diff --git a/debian/patches/fix-testsuite.patch b/debian/patches/fix-testsuite.patch index 11de6c2..c1a87fc 100644 --- a/debian/patches/fix-testsuite.patch +++ b/debian/patches/fix-testsuite.patch @@ -1,12 +1,19 @@ -Description: Fix settings for test suite -Author: Raphaël Hertzog <hertzog@debian.org> +From f50f19a1d9495ca98bf0e5de941ab9c21bcdbf91 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Rapha=C3=ABl=20Hertzog?= <hertzog@debian.org> +Date: Thu, 8 Oct 2015 11:51:54 -0700 +Subject: Fix settings for test suite + Origin: vendor +Patch-Name: fix-testsuite.patch --- -The information above should follow the Patch Tagging Guidelines, please -checkout http://dep.debian.net/deps/dep3/ to learn about the format. ---- python-django-tagging-0.3.1.orig/tagging/tests/settings.py -+++ python-django-tagging-0.3.1/tagging/tests/settings.py + tagging/tests/settings.py | 22 +++++++--------------- + 1 file changed, 7 insertions(+), 15 deletions(-) + +diff --git a/tagging/tests/settings.py b/tagging/tests/settings.py +index 74eb909..1985118 100644 +--- a/tagging/tests/settings.py ++++ b/tagging/tests/settings.py @@ -3,22 +3,14 @@ DIRNAME = os.path.dirname(__file__) DEFAULT_CHARSET = 'utf-8' diff --git a/debian/patches/fix_calc_tag_weight b/debian/patches/fix_calc_tag_weight index 1b65164..b7def19 100644 --- a/debian/patches/fix_calc_tag_weight +++ b/debian/patches/fix_calc_tag_weight @@ -1,13 +1,24 @@ -Description: Fix tag_weight when using logarithmic distribution +From e54ad0924908aec2a7970c957551787875317b2b Mon Sep 17 00:00:00 2001 +From: SVN-Git Migration <python-modules-team@lists.alioth.debian.org> +Date: Thu, 8 Oct 2015 11:51:53 -0700 +Subject: Fix tag_weight when using logarithmic distribution + When logarithmic distribution is used _calculate_tag_weight may return weight greater than maximum threshold. Because of this the attribute font_size of the most frequently used tag may be left unset. Upstream: http://code.google.com/p/django-tagging/issues/detail?id=91 Debian: #525770 ---- django-tagging.old/tagging/utils.py (revision 132) -+++ django-tagging/tagging/utils.py (working copy) -@@ -230,7 +230,7 @@ +Patch-Name: fix_calc_tag_weight +--- + tagging/utils.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tagging/utils.py b/tagging/utils.py +index e89bab0..759e8d8 100644 +--- a/tagging/utils.py ++++ b/tagging/utils.py +@@ -232,7 +232,7 @@ def _calculate_tag_weight(weight, max_weight, distribution): if distribution == LINEAR or max_weight == 1: return weight elif distribution == LOGARITHMIC: @@ -16,4 +27,3 @@ Debian: #525770 raise ValueError(_('Invalid distribution algorithm specified: %s.') % distribution) def calculate_cloud(tags, steps=4, distribution=LOGARITHMIC): - diff --git a/tagging/models.py b/tagging/models.py index 860cf81..e13b077 100644 --- a/tagging/models.py +++ b/tagging/models.py @@ -17,6 +17,8 @@ from tagging import settings from tagging.utils import calculate_cloud, get_tag_list, get_queryset_and_model, parse_tag_input from tagging.utils import LOGARITHMIC +import collections + qn = connection.ops.quote_name ############ @@ -166,9 +168,16 @@ class TagManager(models.Manager): # Django 1.2+ compiler = queryset.query.get_compiler(using='default') extra_joins = ' '.join(compiler.get_from_clause()[0][1:]) - where, params = queryset.query.where.as_sql( - compiler.quote_name_unless_alias, compiler.connection - ) + if isinstance(compiler, collections.Callable): + # Django 1.7+ + where, params = queryset.query.where.as_sql( + compiler, compiler.connection + ) + else: + # Django 1.2-1.6 + where, params = queryset.query.where.as_sql( + compiler.quote_name_unless_alias, compiler.connection + ) else: # Django pre-1.2 extra_joins = ' '.join(queryset.query.get_from_clause()[0][1:]) diff --git a/tagging/tests/settings.py b/tagging/tests/settings.py index 74eb909..1985118 100644 --- a/tagging/tests/settings.py +++ b/tagging/tests/settings.py @@ -3,22 +3,14 @@ DIRNAME = os.path.dirname(__file__) DEFAULT_CHARSET = 'utf-8' -test_engine = os.environ.get("TAGGING_TEST_ENGINE", "sqlite3") - -DATABASE_ENGINE = test_engine -DATABASE_NAME = os.environ.get("TAGGING_DATABASE_NAME", "tagging_test") -DATABASE_USER = os.environ.get("TAGGING_DATABASE_USER", "") -DATABASE_PASSWORD = os.environ.get("TAGGING_DATABASE_PASSWORD", "") -DATABASE_HOST = os.environ.get("TAGGING_DATABASE_HOST", "localhost") - -if test_engine == "sqlite": - DATABASE_NAME = os.path.join(DIRNAME, 'tagging_test.db') - DATABASE_HOST = "" -elif test_engine == "mysql": - DATABASE_PORT = os.environ.get("TAGGING_DATABASE_PORT", 3306) -elif test_engine == "postgresql_psycopg2": - DATABASE_PORT = os.environ.get("TAGGING_DATABASE_PORT", 5432) +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': os.path.join(DIRNAME, 'tagging_test.db'), + } +} +SECRET_KEY = 'liewoo1jie7TahTao3ci7xayee8gieg9ukee' INSTALLED_APPS = ( 'django.contrib.contenttypes', diff --git a/tagging/utils.py b/tagging/utils.py index e89bab0..759e8d8 100644 --- a/tagging/utils.py +++ b/tagging/utils.py @@ -232,7 +232,7 @@ def _calculate_tag_weight(weight, max_weight, distribution): if distribution == LINEAR or max_weight == 1: return weight elif distribution == LOGARITHMIC: - return math.log(weight) * max_weight / math.log(max_weight) + return min((max_weight, math.log(weight) * max_weight / math.log(max_weight))) raise ValueError(_('Invalid distribution algorithm specified: %s.') % distribution) def calculate_cloud(tags, steps=4, distribution=LOGARITHMIC): |