Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package python-django-money for 
openSUSE:Factory checked in at 2024-09-01 19:22:35
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-django-money (Old)
 and      /work/SRC/openSUSE:Factory/.python-django-money.new.2698 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-django-money"

Sun Sep  1 19:22:35 2024 rev:10 rq:1198087 version:3.5.3

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-django-money/python-django-money.changes  
2024-07-01 11:20:40.843738935 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-django-money.new.2698/python-django-money.changes
        2024-09-01 19:23:03.468021790 +0200
@@ -1,0 +2,8 @@
+Sat Aug 31 13:46:05 UTC 2024 - Dirk Müller <[email protected]>
+
+- update to 3.5.3:
+  * django-rest-framework: MoneyField does not work anymore with
+    custom serializer fields
+  * Django 5.1 support
+
+-------------------------------------------------------------------

Old:
----
  django-money-3.5.2.tar.gz

New:
----
  django-money-3.5.3.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-django-money.spec ++++++
--- /var/tmp/diff_new_pack.INrToL/_old  2024-09-01 19:23:03.876038496 +0200
+++ /var/tmp/diff_new_pack.INrToL/_new  2024-09-01 19:23:03.880038659 +0200
@@ -19,7 +19,7 @@
 %define skip_python2 1
 %define skip_python36 1
 Name:           python-django-money
-Version:        3.5.2
+Version:        3.5.3
 Release:        0
 Summary:        Django support for using money and currency fields
 License:        BSD-3-Clause

++++++ django-money-3.5.2.tar.gz -> django-money-3.5.3.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/django-money-3.5.2/djmoney/__init__.py 
new/django-money-3.5.3/djmoney/__init__.py
--- old/django-money-3.5.2/djmoney/__init__.py  2024-05-07 23:30:47.000000000 
+0200
+++ new/django-money-3.5.3/djmoney/__init__.py  2024-08-01 23:48:48.000000000 
+0200
@@ -1,4 +1,4 @@
-__version__ = "3.5.2"
+__version__ = "3.5.3"
 
 try:
     import django
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/django-money-3.5.2/djmoney/contrib/django_rest_framework/fields.py 
new/django-money-3.5.3/djmoney/contrib/django_rest_framework/fields.py
--- old/django-money-3.5.2/djmoney/contrib/django_rest_framework/fields.py      
2024-05-07 23:30:47.000000000 +0200
+++ new/django-money-3.5.3/djmoney/contrib/django_rest_framework/fields.py      
2024-08-01 23:48:48.000000000 +0200
@@ -1,3 +1,4 @@
+from django.core.exceptions import FieldDoesNotExist
 from django.core.validators import MaxValueValidator, MinValueValidator
 from django.utils.translation import gettext_lazy as _
 
@@ -65,13 +66,20 @@
         return super().to_internal_value(data)
 
     def get_value(self, data):
-        default_currency = None
         parent_meta = getattr(self.parent, "Meta", None)
 
+        default_currency = self.default_currency
+
         if parent_meta and hasattr(parent_meta, "model"):
-            model_meta = self.parent.Meta.model._meta
-            field = model_meta.get_field(self.source)
-            default_currency = field.default_currency
+            model = self.parent.Meta.model
+            try:
+                field = model._meta.get_field(self.source)
+                default_currency = field.default_currency
+            except FieldDoesNotExist as e:
+                if not hasattr(model, self.source):
+                    raise ValueError(
+                        f"{self.source} is neither a db field nor a property 
on the model {model.__name__}"
+                    ) from e
 
         amount = super().get_value(data)
         currency = data.get(get_currency_field_name(self.field_name), 
self.default_currency or default_currency)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/django-money-3.5.2/docs/changes.rst 
new/django-money-3.5.3/docs/changes.rst
--- old/django-money-3.5.2/docs/changes.rst     2024-05-07 23:30:47.000000000 
+0200
+++ new/django-money-3.5.3/docs/changes.rst     2024-08-01 23:48:48.000000000 
+0200
@@ -1,6 +1,18 @@
 Changelog
 =========
 
+`3.5.3`_ - 2024-08-01
+---------------------
+
+**Fixed**
+
+- django-rest-framework: MoneyField does not work anymore with custom 
serializer fields :github-issue:`768` (:github-user:`apjama`)
+
+**Added**
+
+- Django 5.1 support :github-issue:`767` (:github-user:`benjaoming`)
+
+
 `3.5.2`_ - 2024-05-07
 ---------------------
 
@@ -15,7 +27,7 @@
 **Fixed**
 
 - django-rest-framework: Fix regression from 3.5 :github-issue:`757` 
(:github-user:`phillipuniverse`)
-
+- Add `base` parameter to openexchangerates.org backend :github-issue:`751` 
(:github-user:`foarsitter`)
 
 `3.5`_ - 2024-05-04
 -------------------
@@ -835,6 +847,7 @@
 
 # .. _3.5: https:///github.com/django-money/django-money/compare/3.5...HEAD
 
+.. _3.5.3: https:///github.com/django-money/django-money/compare/3.5.3...3.5.2
 .. _3.5.2: https:///github.com/django-money/django-money/compare/3.5.2...3.5.1
 .. _3.5.1: https:///github.com/django-money/django-money/compare/3.5.1...3.5
 .. _3.5: https:///github.com/django-money/django-money/compare/3.5...3.4.1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/django-money-3.5.2/setup.py 
new/django-money-3.5.3/setup.py
--- old/django-money-3.5.2/setup.py     2024-05-07 23:30:47.000000000 +0200
+++ new/django-money-3.5.3/setup.py     2024-08-01 23:48:48.000000000 +0200
@@ -56,16 +56,16 @@
         "License :: OSI Approved :: BSD License",
         "Operating System :: OS Independent",
         "Framework :: Django",
-        "Framework :: Django :: 2.2",
-        "Framework :: Django :: 3.2",
-        "Framework :: Django :: 4.0",
-        "Framework :: Django :: 4.1",
+        "Framework :: Django :: 4.2",
+        "Framework :: Django :: 5.0",
+        "Framework :: Django :: 5.1",
         "Programming Language :: Python",
         "Programming Language :: Python :: 3",
-        "Programming Language :: Python :: 3.7",
         "Programming Language :: Python :: 3.8",
         "Programming Language :: Python :: 3.9",
         "Programming Language :: Python :: 3.10",
+        "Programming Language :: Python :: 3.11",
+        "Programming Language :: Python :: 3.12",
         "Programming Language :: Python :: Implementation :: CPython",
         "Programming Language :: Python :: Implementation :: PyPy",
     ],
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/django-money-3.5.2/tests/contrib/test_django_rest_framework.py 
new/django-money-3.5.3/tests/contrib/test_django_rest_framework.py
--- old/django-money-3.5.2/tests/contrib/test_django_rest_framework.py  
2024-05-07 23:30:47.000000000 +0200
+++ new/django-money-3.5.3/tests/contrib/test_django_rest_framework.py  
2024-08-01 23:48:48.000000000 +0200
@@ -7,7 +7,12 @@
 
 from djmoney.money import Money
 
-from ..testapp.models import ModelWithVanillaMoneyField, NullMoneyFieldModel, 
ValidatedMoneyModel
+from ..testapp.models import (
+    ModelWithVanillaMoneyField,
+    MoneyFieldModelWithProperty,
+    NullMoneyFieldModel,
+    ValidatedMoneyModel,
+)
 
 
 pytestmark = pytest.mark.django_db
@@ -78,6 +83,31 @@
         instance = serializer.save()
         assert getattr(instance, field) == expected
 
+    def test_to_internal_value_for_property_field(self):
+
+        class PropertyModelSerializer(serializers.ModelSerializer):
+            extra_monies = djmoney_fields.MoneyField(
+                source="ten_extra_monies",
+                max_digits=10,
+                decimal_places=2,
+                min_value=0,
+                default_currency="EUR",
+                required=False,
+                allow_null=True,
+                read_only=True,
+            )
+
+            class Meta:
+                model = MoneyFieldModelWithProperty
+                fields = ("extra_monies", "money")
+
+        serializer = PropertyModelSerializer(data={"money": Money(12, "USD"), 
"ten_extra_monies": Money(100, "USD")})
+        serializer.is_valid()
+        assert serializer.validated_data == {"money": Money("12.00", "USD")}
+        instance = serializer.save()
+        assert instance.ten_extra_monies == Money(22, "USD")
+        assert instance.money == Money(12, "USD")
+
     def test_invalid_value(self):
         serializer = self.get_serializer(ModelWithVanillaMoneyField, 
data={"money": None})
         assert not serializer.is_valid()
@@ -286,3 +316,29 @@
 
         serializer = ModelSerializer(data={"renamed_money_field": "0.01", 
"renamed_money_field_currency": "EUR"})
         assert serializer.is_valid()
+
+    def test_model_serializer_with_nonexistent_property_raises_error(self):
+        class PropertyModelSerializer(serializers.ModelSerializer):
+            nonexistent_field = djmoney_fields.MoneyField(
+                max_digits=10,
+                decimal_places=2,
+                min_value=0,
+                default_currency="EUR",
+                required=False,
+                allow_null=True,
+            )
+
+            class Meta:
+                model = MoneyFieldModelWithProperty
+                fields = ("nonexistent_field", "money")
+
+        data = {"nonexistent_field": "12.00", "money": "10.00"}
+
+        serializer = PropertyModelSerializer(data=data)
+        with pytest.raises(ValueError) as ex:
+            serializer.is_valid()
+
+        expected_error_message = (
+            "nonexistent_field is neither a db field nor a property on the 
model MoneyFieldModelWithProperty"
+        )
+        assert ex.value.args[0] == expected_error_message
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/django-money-3.5.2/tests/testapp/models.py 
new/django-money-3.5.3/tests/testapp/models.py
--- old/django-money-3.5.2/tests/testapp/models.py      2024-05-07 
23:30:47.000000000 +0200
+++ new/django-money-3.5.3/tests/testapp/models.py      2024-08-01 
23:48:48.000000000 +0200
@@ -129,6 +129,14 @@
     pass
 
 
+class MoneyFieldModelWithProperty(models.Model):
+    money = MoneyField(max_digits=10, decimal_places=2, default=0.0, 
default_currency="USD")
+
+    @property
+    def ten_extra_monies(self):
+        return self.money + Money(10, "USD")
+
+
 class NotNullMoneyFieldModel(models.Model):
     money = MoneyField(max_digits=10, decimal_places=2)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/django-money-3.5.2/tox.ini 
new/django-money-3.5.3/tox.ini
--- old/django-money-3.5.2/tox.ini      2024-05-07 23:30:47.000000000 +0200
+++ new/django-money-3.5.3/tox.ini      2024-08-01 23:48:48.000000000 +0200
@@ -1,7 +1,7 @@
 [tox]
 envlist =
     django_main-py{312,311,310}
-    django50-py{312, 311,310}
+    django{50,51}-py{312, 311,310}
     django42-py{311,310,39,38}
     lint
     docs
@@ -16,6 +16,7 @@
     .[test,exchange]
     django42: {[django]42}
     django50: {[django]50}
+    django51: {[django]51}
     django_main: {[django]main}
     # 
https://github.com/django-money/django-money/pull/716#issuecomment-1592594627
     pypy3: asgiref<=3.6
@@ -37,6 +38,10 @@
        Django>=5.0,<5.1
        django-reversion>=4.0.0
        djangorestframework>=3.13.0
+51 =
+       Django>=5.1a,<5.2
+       django-reversion>=4.0.0
+       djangorestframework>=3.13.0
 main =
        https://github.com/django/django/tarball/main
        django-reversion>=4.0.0

Reply via email to