Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
steering
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
AURA
steering
Commits
c186e18c
Verified
Commit
c186e18c
authored
4 months ago
by
Ernesto Rico Schmidt
Browse files
Options
Downloads
Patches
Plain Diff
feat: add update method to PlaylistSerializer
parent
b6c69f79
No related branches found
No related tags found
1 merge request
!59
Add playlists
Pipeline
#8700
passed
4 months ago
Stage: check
Stage: test
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
program/serializers.py
+30
-0
30 additions, 0 deletions
program/serializers.py
with
30 additions
and
0 deletions
program/serializers.py
+
30
−
0
View file @
c186e18c
...
...
@@ -1527,3 +1527,33 @@ class PlaylistSerializer(serializers.ModelSerializer):
PlaylistEntry
.
objects
.
create
(
playlist
=
playlist
,
**
entry_data
)
return
playlist
def
update
(
self
,
instance
,
validated_data
):
"""
Update an existing Playlist instance, given the validated data.
"""
user
=
self
.
context
[
"
request
"
].
user
user_is_owner
=
user
in
instance
.
show
.
owners
.
all
()
# having the update_playlist permission overrules the ownership
if
not
(
user
.
has_perm
(
"
program.update_playlist
"
)
or
user_is_owner
):
raise
exceptions
.
PermissionDenied
(
detail
=
"
You are not allowed to update this playlist.
"
)
if
"
description
"
in
validated_data
:
instance
.
description
=
validated_data
.
pop
(
"
description
"
)
if
"
playout_mode
"
in
validated_data
:
instance
.
playout_mode
=
validated_data
.
pop
(
"
playout_mode
"
)
if
"
entries
"
in
validated_data
:
if
instance
.
entries
.
count
()
>
0
:
for
entry
in
instance
.
entries
.
all
():
entry
.
delete
(
keep_parents
=
True
)
for
entry_data
in
validated_data
.
get
(
"
entries
"
):
PlaylistEntry
.
objects
.
create
(
playlist
=
instance
,
**
entry_data
)
instance
.
save
()
return
instance
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