Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
C
cp_video_dokku
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alexandr Dzehil
cp_video_dokku
Commits
3075ad49
Commit
3075ad49
authored
Mar 24, 2023
by
Ilya Simonov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add retrieve endpoint for playlyst by id
parent
0f8b071a
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
31 additions
and
3 deletions
+31
-3
serializers.cpython-39.pyc
apps/core/__pycache__/serializers.cpython-39.pyc
+0
-0
urls.cpython-39.pyc
apps/core/__pycache__/urls.cpython-39.pyc
+0
-0
views.cpython-39.pyc
apps/core/__pycache__/views.cpython-39.pyc
+0
-0
serializers.py
apps/core/serializers.py
+20
-1
signals.py
apps/core/signals.py
+2
-1
urls.py
apps/core/urls.py
+1
-0
views.py
apps/core/views.py
+8
-1
No files found.
apps/core/__pycache__/serializers.cpython-39.pyc
View file @
3075ad49
No preview for this file type
apps/core/__pycache__/urls.cpython-39.pyc
View file @
3075ad49
No preview for this file type
apps/core/__pycache__/views.cpython-39.pyc
View file @
3075ad49
No preview for this file type
apps/core/serializers.py
View file @
3075ad49
from
rest_framework
import
serializers
from
.models
import
Video
,
Category
,
Tag
,
TagToObject
from
.models
import
Video
,
Playlist
,
Category
,
TagToObject
class
TagToObjectSerializer
(
serializers
.
ModelSerializer
):
...
...
@@ -34,3 +34,22 @@ class VideoSerializer(serializers.ModelSerializer):
'categories'
,
'tags'
,
]
class
PlaylistSerializer
(
serializers
.
ModelSerializer
):
videos
=
VideoSerializer
(
many
=
True
)
tags
=
TagToObjectSerializer
(
many
=
True
)
class
Meta
:
model
=
Playlist
fields
=
[
'id'
,
'title'
,
'description'
,
'sort'
,
'type'
,
'mrss'
,
'json'
,
'videos'
,
'tags'
,
]
apps/core/signals.py
View file @
3075ad49
...
...
@@ -6,7 +6,8 @@ from . import models
@
receiver
(
post_save
,
sender
=
models
.
Playlist
)
def
save_playlist_
mrs
s
(
sender
,
instance
,
created
,
**
kwargs
):
def
save_playlist_
link
s
(
sender
,
instance
,
created
,
**
kwargs
):
if
created
:
instance
.
json
=
f
'{settings.DOMAIN_NAME}/api/playlist/{instance.id}/'
instance
.
mrss
=
f
'{settings.DOMAIN_NAME}/api/playlist/{instance.id}/mrss'
instance
.
save
()
apps/core/urls.py
View file @
3075ad49
...
...
@@ -5,5 +5,6 @@ from . import views
urlpatterns
=
[
path
(
'video/'
,
views
.
VideoAPIView
.
as_view
({
'get'
:
'list'
})),
path
(
'playlist/<int:pk>/'
,
views
.
VideoRetrieveAPIView
.
as_view
()),
path
(
'playlist/<int:pk>/mrss'
,
views
.
playlist_mrss_view
),
]
apps/core/views.py
View file @
3075ad49
from
rest_framework
import
permissions
,
viewsets
from
rest_framework
import
permissions
,
viewsets
,
generics
from
django.http
import
HttpResponse
from
django.shortcuts
import
get_object_or_404
...
...
@@ -22,6 +22,13 @@ class VideoAPIView(viewsets.ModelViewSet):
return
queryset
class
VideoRetrieveAPIView
(
generics
.
RetrieveAPIView
):
queryset
=
models
.
Playlist
.
objects
.
all
()
serializer_class
=
serializers
.
PlaylistSerializer
permission_classes
=
[
permissions
.
AllowAny
]
lookup_field
=
'pk'
def
playlist_mrss_view
(
request
,
pk
):
mrss_items
=
[]
playlist
=
get_object_or_404
(
models
.
Playlist
,
pk
=
pk
)
...
...
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