Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
djangoldp
Manage
Activity
Members
Labels
Plan
Issues
99
Issue boards
Milestones
Wiki
Code
Merge requests
5
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
d42a03db
Commit
d42a03db
authored
5 years ago
by
Jean-Baptiste
Browse files
Options
Downloads
Patches
Plain Diff
update: fix @id on custom container views
parent
22f6cb72
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!104
Resolve "Bad ID on custom LDPViewSet"
Pipeline
#1172
passed with stage
Stage: test
in 1 minute and 25 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
djangoldp/serializers.py
+2
-1
2 additions, 1 deletion
djangoldp/serializers.py
djangoldp/tests/tests_sources.py
+6
-0
6 additions, 0 deletions
djangoldp/tests/tests_sources.py
djangoldp/tests/tests_temp.py
+4
-0
4 additions, 0 deletions
djangoldp/tests/tests_temp.py
with
12 additions
and
1 deletion
djangoldp/serializers.py
+
2
−
1
View file @
d42a03db
...
@@ -241,7 +241,6 @@ class JsonLdIdentityField(JsonLdField):
...
@@ -241,7 +241,6 @@ class JsonLdIdentityField(JsonLdField):
return
super
().
get_attribute
(
instance
)
return
super
().
get_attribute
(
instance
)
class
LDPSerializer
(
HyperlinkedModelSerializer
):
class
LDPSerializer
(
HyperlinkedModelSerializer
):
url_field_name
=
"
@id
"
url_field_name
=
"
@id
"
serializer_related_field
=
JsonLdRelatedField
serializer_related_field
=
JsonLdRelatedField
...
@@ -461,6 +460,8 @@ class LDPSerializer(HyperlinkedModelSerializer):
...
@@ -461,6 +460,8 @@ class LDPSerializer(HyperlinkedModelSerializer):
serializer
=
ContainerSerializer
(
*
args
,
**
kwargs
)
serializer
=
ContainerSerializer
(
*
args
,
**
kwargs
)
if
'
context
'
in
kwargs
and
getattr
(
kwargs
[
'
context
'
][
'
view
'
],
'
nested_field
'
,
None
)
is
not
None
:
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
)
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
return
serializer
def
to_internal_value
(
self
,
data
):
def
to_internal_value
(
self
,
data
):
...
...
This diff is collapsed.
Click to expand it.
djangoldp/tests/tests_sources.py
+
6
−
0
View file @
d42a03db
...
@@ -16,3 +16,9 @@ class TestSource(APITestCase):
...
@@ -16,3 +16,9 @@ class TestSource(APITestCase):
source
=
LDPSource
.
objects
.
create
(
federation
=
"
source_name
"
,
urlid
=
"
http://bar.foo/
"
)
source
=
LDPSource
.
objects
.
create
(
federation
=
"
source_name
"
,
urlid
=
"
http://bar.foo/
"
)
response
=
self
.
client
.
get
(
'
/sources/{}/
'
.
format
(
source
.
federation
),
content_type
=
'
application/ld+json
'
)
response
=
self
.
client
.
get
(
'
/sources/{}/
'
.
format
(
source
.
federation
),
content_type
=
'
application/ld+json
'
)
self
.
assertEqual
(
response
.
status_code
,
200
)
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/
'
)
This diff is collapsed.
Click to expand it.
djangoldp/tests/tests_temp.py
+
4
−
0
View file @
d42a03db
...
@@ -2,6 +2,9 @@ from django.contrib.auth.models import User
...
@@ -2,6 +2,9 @@ from django.contrib.auth.models import User
from
django.test
import
TestCase
from
django.test
import
TestCase
from
rest_framework.test
import
APIRequestFactory
,
APIClient
from
rest_framework.test
import
APIRequestFactory
,
APIClient
from
djangoldp.models
import
LDPSource
class
TestTemp
(
TestCase
):
class
TestTemp
(
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
...
@@ -12,3 +15,4 @@ class TestTemp(TestCase):
...
@@ -12,3 +15,4 @@ class TestTemp(TestCase):
def
tearDown
(
self
):
def
tearDown
(
self
):
pass
pass
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