Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
Django LDP
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
20
Issues
20
List
Boards
Labels
Milestones
Merge Requests
5
Merge Requests
5
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Startin blox
djangoldp-packages
Django LDP
Commits
d42a03db
Commit
d42a03db
authored
Sep 17, 2019
by
Jean-Baptiste
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update: fix @id on custom container views
parent
22f6cb72
Pipeline
#5412
passed with stage
in 1 minute and 25 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
1 deletion
+12
-1
djangoldp/serializers.py
djangoldp/serializers.py
+2
-1
djangoldp/tests/tests_sources.py
djangoldp/tests/tests_sources.py
+6
-0
djangoldp/tests/tests_temp.py
djangoldp/tests/tests_temp.py
+4
-0
No files found.
djangoldp/serializers.py
View file @
d42a03db
...
...
@@ -241,7 +241,6 @@ class JsonLdIdentityField(JsonLdField):
return
super
()
.
get_attribute
(
instance
)
class
LDPSerializer
(
HyperlinkedModelSerializer
):
url_field_name
=
"@id"
serializer_related_field
=
JsonLdRelatedField
...
...
@@ -461,6 +460,8 @@ class LDPSerializer(HyperlinkedModelSerializer):
serializer
=
ContainerSerializer
(
*
args
,
**
kwargs
)
if
'context'
in
kwargs
and
getattr
(
kwargs
[
'context'
][
'view'
],
'nested_field'
,
None
)
is
not
None
:
serializer
.
id
=
'{}{}/'
.
format
(
serializer
.
id
,
kwargs
[
'context'
][
'view'
]
.
nested_field
)
elif
'context'
in
kwargs
:
serializer
.
id
=
'{}{}'
.
format
(
settings
.
BASE_URL
,
kwargs
[
'context'
][
'view'
]
.
request
.
path
)
return
serializer
def
to_internal_value
(
self
,
data
):
...
...
djangoldp/tests/tests_sources.py
View file @
d42a03db
...
...
@@ -16,3 +16,9 @@ class TestSource(APITestCase):
source
=
LDPSource
.
objects
.
create
(
federation
=
"source_name"
,
urlid
=
"http://bar.foo/"
)
response
=
self
.
client
.
get
(
'/sources/{}/'
.
format
(
source
.
federation
),
content_type
=
'application/ld+json'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
data
[
'@id'
],
'http://happy-dev.fr/sources/source_name/'
)
def
test_get_empty_resource
(
self
):
response
=
self
.
client
.
get
(
'/sources/{}/'
.
format
(
'unknown'
),
content_type
=
'application/ld+json'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
data
[
'@id'
],
'http://happy-dev.fr/sources/unknown/'
)
djangoldp/tests/tests_temp.py
View file @
d42a03db
...
...
@@ -2,6 +2,9 @@ from django.contrib.auth.models import User
from
django.test
import
TestCase
from
rest_framework.test
import
APIRequestFactory
,
APIClient
from
djangoldp.models
import
LDPSource
class
TestTemp
(
TestCase
):
def
setUp
(
self
):
...
...
@@ -12,3 +15,4 @@ class TestTemp(TestCase):
def
tearDown
(
self
):
pass
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment