Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
MOOC packages by hacklab
django-courses
Commits
16e1e916
Commit
16e1e916
authored
Jul 26, 2021
by
Matheus Miranda
Browse files
Add VideoFile model
parent
f32ecf0e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
courses/urls.py
courses/urls.py
+2
-0
courses/videos/models.py
courses/videos/models.py
+26
-0
No files found.
courses/urls.py
View file @
16e1e916
...
...
@@ -15,6 +15,7 @@ from .views import (
CoursePictureUploadViewSet
,
)
from
.videos.views
import
VideoFileViewSet
from
.course_material.views
import
CourseMaterialViewSet
,
CourseMaterialFileViewSet
from
.import_export.views
import
ExportCourseView
,
ImportCourseView
from
courses.workspaces.views
import
(
...
...
@@ -54,6 +55,7 @@ router.register(r'my-courses', MyCoursesViewSet, base_name='my-courses')
router
.
register
(
r
'course_material'
,
CourseMaterialViewSet
,
base_name
=
'course_material'
)
router
.
register
(
r
'course_material_file'
,
CourseMaterialFileViewSet
,
base_name
=
'course_material_file'
)
router
.
register
(
r
'course-by-slug'
,
CourseBySlugViewSet
,
base_name
=
'course_by_slug'
),
router
.
register
(
r
'videos'
,
VideoFileViewSet
,
base_name
=
'course_by_slug'
),
# Lessons
router
.
register
(
r
'course-lessons/(?P<course_id>[1-9][0-9]*)'
,
LessonViewSet
,
base_name
=
'lessons'
)
...
...
courses/videos/models.py
View file @
16e1e916
from
django.db
import
models
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.text
import
slugify
def
get_upload_path
(
instance
,
filename
):
filename
,
fileextension
=
filename
.
split
(
"."
,
2
)
filename
=
slugify
(
filename
.
split
(
"/"
,
2
)[
-
1
])
return
'course_videos/{0}.{1}'
.
format
(
filename
,
fileextension
)
class
VideoFile
(
models
.
Model
):
name
=
models
.
CharField
(
max_length
=
255
,
)
file
=
models
.
FileField
(
upload_to
=
get_upload_path
,
default
=
None
,
null
=
True
)
video
=
models
.
OneToOneField
(
'Video'
,
models
.
CASCADE
,
related_name
=
'file'
,
verbose_name
=
_
(
'file'
),
null
=
True
,
blank
=
True
,
)
class
Video
(
models
.
Model
):
name
=
models
.
CharField
(
...
...
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