Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
djangoldp-packages
djangoldp
Commits
f03fe13a
Commit
f03fe13a
authored
6 years ago
by
Jean-Baptiste
Browse files
Options
Downloads
Plain Diff
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
!40
bugfix: typo
Pipeline
#809
passed
6 years ago
Stage: test
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
djangoldp/serializers.py
+11
-3
11 additions, 3 deletions
djangoldp/serializers.py
djangoldp/tests/tests_save.py
+1
-1
1 addition, 1 deletion
djangoldp/tests/tests_save.py
with
12 additions
and
4 deletions
djangoldp/serializers.py
+
11
−
3
View file @
f03fe13a
...
...
@@ -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
):
...
...
This diff is collapsed.
Click to expand it.
djangoldp/tests/tests_save.py
+
1
−
1
View file @
f03fe13a
...
...
@@ -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
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment