unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob bb51f072cf868f053704a032b03007a5adea1870 3740 bytes (raw)
name: gnu/packages/patches/python-django-tagging-django-4-support.patch 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
 
From ee42fd962c5abc7ed18f729ded42ee1f56397678 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bartolom=C3=A9=20S=C3=A1nchez=20Salado?=
 <bartolome.salado@kiwi.com>
Date: Sun, 12 Dec 2021 18:13:23 +0100
Subject: [PATCH 2/4] Use smart_str instead of deprecated smart_text Django
 function

---
 tagging/models.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tagging/models.py b/tagging/models.py
index 02550eec..d16a61ec 100644
--- a/tagging/models.py
+++ b/tagging/models.py
@@ -5,7 +5,7 @@
 from django.contrib.contenttypes.models import ContentType
 from django.db import connection
 from django.db import models
-from django.utils.encoding import smart_text
+from django.utils.encoding import smart_str
 from django.utils.translation import gettext_lazy as _
 
 from tagging import settings
@@ -519,4 +519,4 @@ class Meta:
         verbose_name_plural = _('tagged items')
 
     def __str__(self):
-        return '%s [%s]' % (smart_text(self.object), smart_text(self.tag))
+        return '%s [%s]' % (smart_str(self.object), smart_str(self.tag))

From 9c47683ec67ad2fbf82f1dce6384b156f64f55bc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bartolom=C3=A9=20S=C3=A1nchez=20Salado?=
 <bartolome.salado@kiwi.com>
Date: Sun, 12 Dec 2021 18:14:35 +0100
Subject: [PATCH 3/4] Use re_path instead of deprecated url Django function

---
 tagging/tests/urls.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tagging/tests/urls.py b/tagging/tests/urls.py
index aa127d5f..7db3e7e1 100644
--- a/tagging/tests/urls.py
+++ b/tagging/tests/urls.py
@@ -1,5 +1,5 @@
 """Test urls for tagging."""
-from django.conf.urls import url
+from django.urls import re_path
 
 from tagging.tests.models import Article
 from tagging.views import TaggedObjectList
@@ -11,10 +11,10 @@ class StaticTaggedObjectList(TaggedObjectList):
 
 
 urlpatterns = [
-    url(r'^static/$', StaticTaggedObjectList.as_view()),
-    url(r'^static/related/$', StaticTaggedObjectList.as_view(
+    re_path(r'^static/$', StaticTaggedObjectList.as_view()),
+    re_path(r'^static/related/$', StaticTaggedObjectList.as_view(
         related_tags=True)),
-    url(r'^no-tag/$', TaggedObjectList.as_view(model=Article)),
-    url(r'^no-query-no-model/$', TaggedObjectList.as_view()),
-    url(r'^(?P<tag>[^/]+(?u))/$', TaggedObjectList.as_view(model=Article)),
+    re_path(r'^no-tag/$', TaggedObjectList.as_view(model=Article)),
+    re_path(r'^no-query-no-model/$', TaggedObjectList.as_view()),
+    re_path(r'^(?P<tag>[^/]+(?u))/$', TaggedObjectList.as_view(model=Article)),
 ]

From 6550f6c04c0d2d67049e8cc3263623811207c66d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bartolom=C3=A9=20S=C3=A1nchez=20Salado?=
 <bartolome.salado@kiwi.com>
Date: Sun, 12 Dec 2021 18:26:03 +0100
Subject: [PATCH 4/4] Add support for Django 4 compatibility

---
 tagging/models.py | 6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

--- a/tagging/models.py
+++ b/tagging/models.py
@@ -5,6 +5,7 @@
 from django.contrib.contenttypes.models import ContentType
 from django.db import connection
 from django.db import models
+from django.db.models.query_utils import Q
 from django.utils.encoding import smart_str
 from django.utils.translation import gettext_lazy as _
 
@@ -155,8 +156,9 @@ def usage_for_model(self, model, counts=False, min_count=None,
             filters = {}
 
         queryset = model._default_manager.filter()
-        for f in filters.items():
-            queryset.query.add_filter(f)
+        for k, v in filters.items():
+            # Add support for both Django 4 and inferior versions
+            queryset.query.add_q(Q((k, v)))
         usage = self.usage_for_queryset(queryset, counts, min_count)
 
         return usage

debug log:

solving bb51f072cf ...
found bb51f072cf in https://yhetil.org/guix-patches/56003ceeb386b752ae9ee10f78b0675bdb484705.1693991781.git.ngraves@ngraves.fr/ ||
	https://yhetil.org/guix-patches/8d4edd2715e9bba1ec6bc4620e0c7f99bb81dcb5.1687712245.git.ngraves@ngraves.fr/ ||
	https://yhetil.org/guix-patches/ba25a1cebdd908a6e921e8850c7eb1d81e78598f.1693931491.git.ngraves@ngraves.fr/

applying [1/1] https://yhetil.org/guix-patches/56003ceeb386b752ae9ee10f78b0675bdb484705.1693991781.git.ngraves@ngraves.fr/
diff --git a/gnu/packages/patches/python-django-tagging-django-4-support.patch b/gnu/packages/patches/python-django-tagging-django-4-support.patch
new file mode 100644
index 0000000000..bb51f072cf

1:29: trailing whitespace.
 
1:33: trailing whitespace.
 
1:56: trailing whitespace.
 
1:60: trailing whitespace.
 
1:61: trailing whitespace.
 
Checking patch gnu/packages/patches/python-django-tagging-django-4-support.patch...
Applied patch gnu/packages/patches/python-django-tagging-django-4-support.patch cleanly.
warning: squelched 3 whitespace errors
warning: 8 lines add whitespace errors.

skipping https://yhetil.org/guix-patches/8d4edd2715e9bba1ec6bc4620e0c7f99bb81dcb5.1687712245.git.ngraves@ngraves.fr/ for bb51f072cf
skipping https://yhetil.org/guix-patches/ba25a1cebdd908a6e921e8850c7eb1d81e78598f.1693931491.git.ngraves@ngraves.fr/ for bb51f072cf
index at:
100644 bb51f072cf868f053704a032b03007a5adea1870	gnu/packages/patches/python-django-tagging-django-4-support.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).