Skip to content
Snippets Groups Projects
Commit f03fe13a authored by Jean-Baptiste's avatar Jean-Baptiste
Browse files

Merge branch 'typeError_fix' into 'master'

bugfix: typo

See merge request startinblox/djangoldp-packages/djangoldp!40
parents a6d05406 fc485f09
No related branches found
No related tags found
1 merge request!40bugfix: typo
Pipeline #809 passed
......@@ -30,7 +30,7 @@ class LDListMixin:
pass
if isinstance(data, dict):
data = [data]
if isinstance(data, str) and str.startswith("http"):
if isinstance(data, str) and data.startswith("http"):
data = [{'@id': data}]
return [self.child.to_internal_value(item) for item in data]
......@@ -46,7 +46,8 @@ class LDListMixin:
def get_value(self, dictionary):
try:
object_list = dictionary["@graph"]
object_list = dictionary['@graph']
if self.parent.instance is None:
obj = next(filter(
lambda o: not hasattr(o, self.parent.url_field_name) or "./" in o[self.parent.url_field_name],
......@@ -88,7 +89,14 @@ class LDListMixin:
return ret
except KeyError:
return super().get_value(dictionary)
obj = super().get_value(dictionary)
if isinstance(obj, dict) and self.parent.url_field_name in obj:
resource_id = obj[self.parent.url_field_name]
if isinstance(resource_id, str) and resource_id.startswith("_:"):
object_list = self.root.initial_data['@graph']
obj = [next(filter(lambda o: resource_id in o[self.parent.url_field_name], object_list))]
return obj
class ContainerSerializer(LDListMixin, ListSerializer):
......
......@@ -38,7 +38,7 @@ class Save(TestCase):
self.assertIs(result.batches.count(), 1)
self.assertEquals(result.batches.all()[0].title, "Batch 1")
self.assertIs(result.batches.all()[0].tasks.count(), 1)
#self.assertEquals(result.batches.all()[0].tasks.all()[0].title, "Tache 1")
self.assertEquals(result.batches.all()[0].tasks.all()[0].title, "Tache 1")
def test_save_m2m(self):
skill1 = Skill.objects.create(title="skill1", obligatoire="obligatoire")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment