From patchwork Wed Sep 6 09:15:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 53540 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id D03A027BBE9; Wed, 6 Sep 2023 10:20:33 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 1642527BBE2 for ; Wed, 6 Sep 2023 10:20:32 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qdogr-00074Z-Om; Wed, 06 Sep 2023 05:19:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qdofv-0004Sd-Ov for guix-patches@gnu.org; Wed, 06 Sep 2023 05:18:16 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qdofp-0005uf-Ve for guix-patches@gnu.org; Wed, 06 Sep 2023 05:18:12 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qdofq-0006Ji-Qg; Wed, 06 Sep 2023 05:18:10 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65758] [PATCH v7 22/57] gnu: python-django-tagging: Add patch for django@4 support. Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: lars@6xq.net, jgart@dismail.de, guix-patches@gnu.org Resent-Date: Wed, 06 Sep 2023 09:18:10 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65758 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 65758@debbugs.gnu.org Cc: ngraves@ngraves.fr, Lars-Dominik Braun , jgart X-Debbugs-Original-Xcc: Lars-Dominik Braun , jgart Received: via spool by 65758-submit@debbugs.gnu.org id=B65758.169399185523843 (code B ref 65758); Wed, 06 Sep 2023 09:18:10 +0000 Received: (at 65758) by debbugs.gnu.org; 6 Sep 2023 09:17:35 +0000 Received: from localhost ([127.0.0.1]:60944 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdofG-0006CK-CI for submit@debbugs.gnu.org; Wed, 06 Sep 2023 05:17:35 -0400 Received: from 12.mo582.mail-out.ovh.net ([178.32.125.228]:46151) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qdofC-0006Bt-Gm for 65758@debbugs.gnu.org; Wed, 06 Sep 2023 05:17:32 -0400 Received: from director5.ghost.mail-out.ovh.net (unknown [10.109.156.215]) by mo582.mail-out.ovh.net (Postfix) with ESMTP id 345B128153 for <65758@debbugs.gnu.org>; Wed, 6 Sep 2023 09:17:28 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-9ztwb (unknown [10.108.16.127]) by director5.ghost.mail-out.ovh.net (Postfix) with ESMTPS id A5E521FEB8; Wed, 6 Sep 2023 09:17:27 +0000 (UTC) Received: from ngraves.fr ([37.59.142.107]) by ghost-submission-6684bf9d7b-9ztwb with ESMTPSA id uzhmI6dD+GSnmAgApfQNQw (envelope-from ); Wed, 06 Sep 2023 09:17:27 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-107S0018a073494-0fa8-4202-bc0d-0e64be832ed7, 8B1004CD708F4A346301A86E579550867B8E22F8) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 81.67.140.142 Date: Wed, 6 Sep 2023 11:15:46 +0200 Message-ID: <56003ceeb386b752ae9ee10f78b0675bdb484705.1693991781.git.ngraves@ngraves.fr> X-Mailer: git-send-email 2.41.0 In-Reply-To: <68f75e9d42cc8c0c8d0fa78cd0817b28dfb774c6.1693991781.git.ngraves@ngraves.fr> References: <68f75e9d42cc8c0c8d0fa78cd0817b28dfb774c6.1693991781.git.ngraves@ngraves.fr> MIME-Version: 1.0 X-Ovh-Tracer-Id: 4875146598371418850 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedviedrudehfedgudefucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefpihgtohhlrghsucfirhgrvhgvshcuoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqnecuggftrfgrthhtvghrnhepvdehleeiffehtedvlefhffffjeefgfduhfetkeevheeiteduiedugfekuedtheejnecuffhomhgrihhnpehgihhthhhusgdrtghomhenucfkphepuddvjedrtddrtddruddpkedurdeijedrudegtddrudegvddpfeejrdehledrudegvddruddtjeenucevlhhushhtvghrufhiiigvpeefnecurfgrrhgrmhepihhnvghtpeduvdejrddtrddtrddupdhmrghilhhfrhhomhepoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqpdhnsggprhgtphhtthhopedupdhrtghpthhtohepieehjeehkeesuggvsggsuhhgshdrghhnuhdrohhrghdpoffvtefjohhsthepmhhoheekvddpmhhouggvpehsmhhtphhouhht X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Nicolas Graves X-ACL-Warn: , Nicolas Graves via Guix-patches X-Patchwork-Original-From: Nicolas Graves via Guix-patches via From: Nicolas Graves Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches * gnu/packages/django.scm (python-django-tagging): Add patch for django@4 support. [source](patches): Add patch for django@4 support. [native-inputs]: Add tzdata-for-tests. * gnu/packages/patches/python-django-tagging-django-4-support.patch --- gnu/packages/django.scm | 7 +- ...thon-django-tagging-django-4-support.patch | 101 ++++++++++++++++++ 2 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 gnu/packages/patches/python-django-tagging-django-4-support.patch diff --git a/gnu/packages/django.scm b/gnu/packages/django.scm index 4978aa07c2..11e4279829 100644 --- a/gnu/packages/django.scm +++ b/gnu/packages/django.scm @@ -1073,8 +1073,9 @@ (define-public python-django-tagging (method url-fetch) (uri (pypi-uri "django-tagging" version)) (sha256 - (base32 - "13afxx30chssclxzd9gqnvwm9qyrdpnlbs6iswdfa18phfj8zmi8")))) + (base32 "13afxx30chssclxzd9gqnvwm9qyrdpnlbs6iswdfa18phfj8zmi8")) + (patches + (search-patches "python-django-tagging-django-4-support.patch")))) (build-system python-build-system) (arguments `(#:phases @@ -1083,6 +1084,8 @@ (define-public python-django-tagging (lambda _ (setenv "DJANGO_SETTINGS_MODULE" "tagging.tests.settings") (invoke "django-admin" "test" "--pythonpath=.")))))) + (native-inputs + (list tzdata-for-tests)) (inputs (list python-django)) (home-page "https://github.com/Fantomas42/django-tagging") 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 --- /dev/null +++ b/gnu/packages/patches/python-django-tagging-django-4-support.patch @@ -0,0 +1,101 @@ +From ee42fd962c5abc7ed18f729ded42ee1f56397678 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Bartolom=C3=A9=20S=C3=A1nchez=20Salado?= + +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?= + +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[^/]+(?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[^/]+(?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?= + +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