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
677caf21
Commit
677caf21
authored
4 years ago
by
Calum Mackervoy
Committed by
Jean-Baptiste Pasquier
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
update: changed build_serializer to allow for easier overriding of serializer_class
parent
6567909e
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/views.py
+7
-7
7 additions, 7 deletions
djangoldp/views.py
with
7 additions
and
7 deletions
djangoldp/views.py
+
7
−
7
View file @
677caf21
...
...
@@ -358,7 +358,6 @@ class LDPViewSet(LDPViewSetGenerator):
parser_classes
=
(
JSONLDParser
,)
authentication_classes
=
(
NoCSRFAuthentication
,)
filter_backends
=
[
LocalObjectOnContainerPathBackend
]
write_serializer_class
=
None
def
__init__
(
self
,
**
kwargs
):
super
().
__init__
(
**
kwargs
)
...
...
@@ -369,10 +368,8 @@ class LDPViewSet(LDPViewSetGenerator):
if
hasattr
(
p
,
'
filter_class
'
)
and
p
.
filter_class
:
self
.
filter_backends
.
append
(
p
.
filter_class
)
if
self
.
serializer_class
is
None
:
self
.
serializer_class
=
self
.
build_read_serializer
()
if
self
.
write_serializer_class
is
None
:
self
.
write_serializer_class
=
self
.
build_write_serializer
()
self
.
serializer_class
=
self
.
build_read_serializer
()
self
.
write_serializer_class
=
self
.
build_write_serializer
()
def
build_read_serializer
(
self
):
model_name
=
self
.
model
.
_meta
.
object_name
.
lower
()
...
...
@@ -402,11 +399,14 @@ class LDPViewSet(LDPViewSetGenerator):
def
build_serializer
(
self
,
meta_args
,
name_prefix
):
# create the Meta class to associate to LDPSerializer, using meta_args param
meta_class
=
type
(
'
Meta
'
,
(),
meta_args
)
from
djangoldp.serializers
import
LDPSerializer
return
type
(
LDPSerializer
)(
self
.
model
.
_meta
.
object_name
.
lower
()
+
name_prefix
+
'
Serializer
'
,
(
LDPSerializer
,),
if
self
.
serializer_class
is
None
:
self
.
serializer_class
=
LDPSerializer
return
type
(
LDPSerializer
)(
self
.
model
.
_meta
.
object_name
.
lower
()
+
name_prefix
+
'
Serializer
'
,
(
self
.
serializer_class
,),
{
'
Meta
'
:
meta_class
})
def
is_safe_create
(
self
,
user
,
validated_data
,
*
args
,
**
kwargs
):
...
...
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