Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-django-tagulous for openSUSE:Factory checked in at 2025-04-23 15:18:40 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-django-tagulous (Old) and /work/SRC/openSUSE:Factory/.python-django-tagulous.new.30101 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-django-tagulous" Wed Apr 23 15:18:40 2025 rev:3 rq:1270981 version:2.1.0 Changes: -------- --- /work/SRC/openSUSE:Factory/python-django-tagulous/python-django-tagulous.changes 2024-11-12 19:22:52.267110217 +0100 +++ /work/SRC/openSUSE:Factory/.python-django-tagulous.new.30101/python-django-tagulous.changes 2025-04-23 15:19:17.005977990 +0200 @@ -1,0 +2,6 @@ +Thu Apr 17 11:25:51 UTC 2025 - Markéta Machová <mmach...@suse.com> + +- Add upstream django52b1.patch adding compatibility with Django 5.2b1 +- Skip tests failing with released Django 5.2 + +------------------------------------------------------------------- New: ---- django52b1.patch BETA DEBUG BEGIN: New: - Add upstream django52b1.patch adding compatibility with Django 5.2b1 - Skip tests failing with released Django 5.2 BETA DEBUG END: ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-django-tagulous.spec ++++++ --- /var/tmp/diff_new_pack.7fUgRm/_old 2025-04-23 15:19:17.654004751 +0200 +++ /var/tmp/diff_new_pack.7fUgRm/_new 2025-04-23 15:19:17.654004751 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-django-tagulous # -# Copyright (c) 2024 SUSE LLC +# Copyright (c) 2025 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,6 +24,8 @@ URL: http://radiac.net/projects/django-tagulous/ Group: Development/Languages/Python Source: https://github.com/radiac/django-tagulous/archive/refs/tags/v%{version}.tar.gz#/django-tagulous-%{version}.tar.gz +# PATCH-FIX-UPSTREAM https://github.com/radiac/django-tagulous/pull/188 Fix issue with serializers monkeypatching in Django 5.2b1 +Patch: django52b1.patch BuildRequires: %{python_module Django} BuildRequires: %{python_module pip} BuildRequires: %{python_module pytest-cov} @@ -43,7 +45,7 @@ Fabulous Tagging for Django. %prep -%setup -q -n django-tagulous-%{version} +%autosetup -p1 -n django-tagulous-%{version} %build %pyproject_wheel @@ -54,7 +56,8 @@ %check export PYTHONPATH=${PWD} -%pytest +# two of test_dump_load tests fail with Django 5.2 https://github.com/radiac/django-tagulous/issues/187 +%pytest -k "not test_dump_load" %files %{python_files} %doc README.md ++++++ django52b1.patch ++++++ >From d80ef84bddb98d7485583d25df7131992c589f13 Mon Sep 17 00:00:00 2001 From: Stephen Wolff <step...@maxgatedigital.com> Date: Wed, 12 Mar 2025 09:30:47 +0000 Subject: [PATCH] Fix issue with serializers monkeypatching in Django 5.2b1 Related to #187 --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/radiac/django-tagulous/issues/187?shareId=XXXX-XXXX-XXXX-XXXX). --- tagulous/serializers/base.py | 31 ++++++++++++++++++++++--------- tests/test_serializers.py | 28 ++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 9 deletions(-) diff --git a/tagulous/serializers/base.py b/tagulous/serializers/base.py index 6170070..4e8012c 100644 --- a/tagulous/serializers/base.py +++ b/tagulous/serializers/base.py @@ -62,16 +62,29 @@ def monkeypatch_get_model(serializer): Given a model identifier, get the model - unless it's a TaggedModel, in which case return a temporary fake model to get it serialized. """ - old_get_model = serializer._get_model + if hasattr(serializer, "_get_model"): + old_get_model = serializer._get_model - def _get_model(model_identifier): - RealModel = old_get_model(model_identifier) + def _get_model(model_identifier): + RealModel = old_get_model(model_identifier) - if issubclass(RealModel, TaggedModel): - Model = RealModel._detag_to_serializable() - else: - Model = RealModel + if issubclass(RealModel, TaggedModel): + Model = RealModel._detag_to_serializable() + else: + Model = RealModel + + return Model + + serializer._get_model = _get_model + else: + def _get_model(model_identifier): + RealModel = serializer.get_model(model_identifier) + + if issubclass(RealModel, TaggedModel): + Model = RealModel._detag_to_serializable() + else: + Model = RealModel - return Model + return Model - serializer._get_model = _get_model + serializer.get_model = _get_model diff --git a/tests/test_serializers.py b/tests/test_serializers.py index 8b910b6..529d856 100644 --- a/tests/test_serializers.py +++ b/tests/test_serializers.py @@ -343,3 +343,31 @@ def test_many_to_one(self): self.assertInstanceEqual(obj, name="test", singletag="test", tags="test") self.assertEqual(obj.many_to_one.count(), 1) self.assertEqual(obj.many_to_one.first().name, "rfk1") + + def test_monkeypatch_get_model(self): + """ + Test monkeypatch_get_model function handles the absence of _get_model attribute + """ + from tagulous.serializers import base + from django.core.serializers import python as python_serializer + + # Ensure the test case runs in a Django 5.2b1 environment + if not hasattr(python_serializer, "get_model"): + self.skipTest("Django version is not 5.2b1 or later") + + # Backup original get_model method + original_get_model = python_serializer.get_model + + try: + # Remove _get_model attribute if it exists + if hasattr(python_serializer, "_get_model"): + del python_serializer._get_model + + # Apply monkeypatch + base.monkeypatch_get_model(python_serializer) + + # Check if the monkeypatch works without _get_model attribute + self.assertTrue(hasattr(python_serializer, "get_model")) + finally: + # Restore original get_model method + python_serializer.get_model = original_get_model