Skip to content

Commit

Permalink
prpare 0.2.4
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed Jul 14, 2017
1 parent 3fc089b commit 753e0d1
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 13 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -15,6 +15,13 @@ are used for versioning (schema follows below):
0.3.4 to 0.4).
- All backwards incompatible changes are mentioned in this document.


0.2.4
-----
2017-07-14

- Fix issue #1 with non-required nested serializer fields.

0.2.3
-----
2017-07-13
Expand Down
2 changes: 1 addition & 1 deletion TODOS.rst
Expand Up @@ -12,7 +12,7 @@ Must haves
.. code-block:: text
- Test with various versions of Django REST framework.
- Try to reproduce the "missing fields in the validated data" problem.
+ Try to reproduce the "missing fields in the validated data" problem.
+ Handle unlimited nesting depth.
Should haves
Expand Down
5 changes: 5 additions & 0 deletions examples/simple/books/serializers.py
Expand Up @@ -96,6 +96,11 @@ class Meta(object):
class AddressInformationSerializer(serializers.ModelSerializer):
"""Address information serializer."""

address = serializers.CharField(required=False, allow_null=True)
city = serializers.CharField(required=False, allow_null=True)
state_province = serializers.CharField(required=False, allow_null=True)
country = serializers.CharField(required=False, allow_null=True)

class Meta(object):
"""Meta options."""

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -7,7 +7,7 @@
except:
readme = ''

version = '0.2.3'
version = '0.2.4'

install_requires = [
'six>=1.9',
Expand Down
2 changes: 1 addition & 1 deletion src/rest_framework_tricks/__init__.py
Expand Up @@ -3,7 +3,7 @@
"""

__title__ = 'django-rest-framework-tricks'
__version__ = '0.2.3'
__version__ = '0.2.4'
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
__copyright__ = '2017 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
Expand Down
2 changes: 1 addition & 1 deletion src/rest_framework_tricks/serializers/nested_proxy.py
Expand Up @@ -98,7 +98,7 @@ def extract_nested_serializers(serializer,
nested_serializers_data = {}

for __field_name, __field in serializer.fields.items():
if is_nested_proxy_field(__field):
if is_nested_proxy_field(__field) and __field_name in validated_data:
__serializer_data = validated_data.pop(
__field_name
)
Expand Down
13 changes: 4 additions & 9 deletions src/rest_framework_tricks/tests/test_nested_proxy_field.py
Expand Up @@ -127,10 +127,11 @@ def _nested_proxy_field_model_serializer_missing_all_nested_fields(
"""Test NestedProxyField and ModelSerializer.
All nested fields are missing.
Note, that the `address_information` which contains the `address`,
`city`, `state_province` and `country` fields is completely missing
in the payload.
"""
# TODO: At the moment, if `address_information` is totally missing,
# it fails. Adding even empty `address_information` helps.
# This needs to be solved.
data = {
'name': self.faker.text(max_nb_chars=30),
'info': self.faker.text(),
Expand All @@ -149,12 +150,6 @@ def _nested_proxy_field_model_serializer_missing_all_nested_fields(
for __key in ('name', 'info', 'website'):
self.assertEqual(response.data.get(__key), data.get(__key))

# for __key in ('address', 'city', 'state_province', 'country'):
# self.assertEqual(
# response.data['address_information'].get(__key),
# data['address_information'].get(__key)
# )

def _nested_proxy_field_model_serializer_depth(self, url=None):
"""Test NestedProxyField and ModelSerializer with more depth."""
data = {
Expand Down

0 comments on commit 753e0d1

Please sign in to comment.