From 5cc8014fde7577feb5f81de3a6e05ba94f6ea52c Mon Sep 17 00:00:00 2001 From: Jean-Baptiste <bleme@pm.me> Date: Sat, 27 Jul 2019 15:04:23 +0200 Subject: [PATCH] update: set default depth to 0 --- djangoldp/models.py | 2 +- djangoldp/serializers.py | 16 ---------------- djangoldp/tests/runner.py | 2 +- djangoldp/tests/tests_temp.py | 1 - 4 files changed, 2 insertions(+), 19 deletions(-) diff --git a/djangoldp/models.py b/djangoldp/models.py index 7ab277f0..ee4ebe72 100644 --- a/djangoldp/models.py +++ b/djangoldp/models.py @@ -65,7 +65,7 @@ class Model(models.Model): class Meta: default_permissions = ('add', 'change', 'delete', 'view', 'control') abstract = True - depth = 1 + depth = 0 @classonlymethod def resolve_id(cls, id): diff --git a/djangoldp/serializers.py b/djangoldp/serializers.py index 4f806051..620516c0 100644 --- a/djangoldp/serializers.py +++ b/djangoldp/serializers.py @@ -238,8 +238,6 @@ class LDPSerializer(HyperlinkedModelSerializer): return data def build_field(self, field_name, info, model_class, nested_depth): - nested_depth = self.compute_depth(nested_depth, model_class) - return super().build_field(field_name, info, model_class, nested_depth) def build_property_field(self, field_name, model_class): @@ -318,7 +316,6 @@ class LDPSerializer(HyperlinkedModelSerializer): return type(field_class.__name__ + 'Valued', (JSonLDStandardField, field_class), {}), field_kwargs def build_nested_field(self, field_name, relation_info, nested_depth): - nested_depth = self.compute_depth(nested_depth, self.Meta.model) class NestedLDPSerializer(self.__class__): @@ -390,23 +387,10 @@ class LDPSerializer(HyperlinkedModelSerializer): kwargs['required'] = False return NestedLDPSerializer, kwargs - @classmethod - def compute_depth(cls, depth, model_class, name='depth'): - try: - model_depth = getattr(model_class._meta, 'depth', getattr(model_class.Meta, 'depth', 10)) - depth = min(depth, int(model_depth)) - except AttributeError: - depth = min(depth, int(getattr(model_class._meta, 'depth', 1))) - - return depth @classmethod def many_init(cls, *args, **kwargs): kwargs['child'] = cls(**kwargs) - try: - cls.Meta.depth = cls.compute_depth(kwargs['context']['view'].depth, cls.Meta.model, 'depth') - except KeyError: - pass return ContainerSerializer(*args, **kwargs) def get_value(self, dictionary): diff --git a/djangoldp/tests/runner.py b/djangoldp/tests/runner.py index 230740f0..296716a1 100644 --- a/djangoldp/tests/runner.py +++ b/djangoldp/tests/runner.py @@ -63,7 +63,7 @@ failures = test_runner.run_tests([ 'djangoldp.tests.tests_auto_author', 'djangoldp.tests.tests_get', 'djangoldp.tests.tests_delete', - 'djangoldp.tests.tests_temp' + # 'djangoldp.tests.tests_temp' ]) if failures: diff --git a/djangoldp/tests/tests_temp.py b/djangoldp/tests/tests_temp.py index e7a80ca5..1864f386 100644 --- a/djangoldp/tests/tests_temp.py +++ b/djangoldp/tests/tests_temp.py @@ -18,4 +18,3 @@ class TestTemp(TestCase): pass - -- GitLab