Commit 5cc8014f authored by Jean-Baptiste's avatar Jean-Baptiste

update: set default depth to 0

parent 5ce49f46
Pipeline #4683 passed with stage
in 1 minute and 20 seconds
......@@ -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):
......
......@@ -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):
......
......@@ -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:
......
......@@ -18,4 +18,3 @@ class TestTemp(TestCase):
pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment