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
b0ad5138
Commit
b0ad5138
authored
5 years ago
by
Calum Mackervoy
Committed by
Jean-Baptiste Pasquier
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Minor: updated resolve_fk_instances
parent
259a6c3d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
djangoldp/serializers.py
+18
-9
18 additions, 9 deletions
djangoldp/serializers.py
with
18 additions
and
9 deletions
djangoldp/serializers.py
+
18
−
9
View file @
b0ad5138
...
...
@@ -598,17 +598,26 @@ class LDPSerializer(HyperlinkedModelSerializer):
continue
slug_field
=
Model
.
slug_field
(
field_model
)
sub_inst
=
None
if
slug_field
in
field_dict
:
if
'
urlid
'
in
field_dict
:
# has urlid and is a local resource
if
parse
.
urlparse
(
settings
.
BASE_URL
).
netloc
==
parse
.
urlparse
(
field_dict
[
'
urlid
'
]).
netloc
:
# try slug field if it exists
if
slug_field
in
field_dict
:
kwargs
=
{
slug_field
:
field_dict
[
slug_field
]}
sub_inst
=
field_model
.
objects
.
get
(
**
kwargs
)
else
:
model
,
sub_inst
=
Model
.
resolve
(
field_dict
[
'
urlid
'
])
# remote resource - get backlinked copy
elif
hasattr
(
field_model
,
'
urlid
'
):
kwargs
=
{
'
urlid
'
:
field_dict
[
'
urlid
'
]}
sub_inst
=
field_model
.
objects
.
get
(
**
kwargs
)
elif
issubclass
(
field_model
,
AbstractUser
):
kwargs
=
{
'
username
'
:
field_dict
[
'
urlid
'
]}
sub_inst
=
field_model
.
objects
.
get
(
**
kwargs
)
# try slug field, assuming that this is a local resource
elif
slug_field
in
field_dict
:
kwargs
=
{
slug_field
:
field_dict
[
slug_field
]}
sub_inst
=
field_model
.
objects
.
get
(
**
kwargs
)
elif
'
urlid
'
in
field_dict
and
settings
.
BASE_URL
in
field_dict
[
'
urlid
'
]:
model
,
sub_inst
=
Model
.
resolve
(
field_dict
[
'
urlid
'
])
elif
'
urlid
'
in
field_dict
and
issubclass
(
field_model
,
AbstractUser
):
kwargs
=
{
'
username
'
:
field_dict
[
'
urlid
'
]}
sub_inst
=
field_model
.
objects
.
get
(
**
kwargs
)
elif
'
urlid
'
in
field_dict
:
kwargs
=
{
'
urlid
'
:
field_dict
[
'
urlid
'
]}
sub_inst
=
field_model
.
objects
.
get
(
**
kwargs
)
if
sub_inst
is
None
:
sub_inst
=
self
.
internal_create
(
field_dict
,
field_model
)
validated_data
[
field_name
]
=
sub_inst
...
...
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