Commit 16e1e916 authored by Matheus Miranda's avatar Matheus Miranda
Browse files

Add VideoFile model

parent f32ecf0e
...@@ -15,6 +15,7 @@ from .views import ( ...@@ -15,6 +15,7 @@ from .views import (
CoursePictureUploadViewSet, CoursePictureUploadViewSet,
) )
from .videos.views import VideoFileViewSet
from .course_material.views import CourseMaterialViewSet, CourseMaterialFileViewSet from .course_material.views import CourseMaterialViewSet, CourseMaterialFileViewSet
from .import_export.views import ExportCourseView, ImportCourseView from .import_export.views import ExportCourseView, ImportCourseView
from courses.workspaces.views import ( from courses.workspaces.views import (
...@@ -54,6 +55,7 @@ router.register(r'my-courses', MyCoursesViewSet, base_name='my-courses') ...@@ -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', CourseMaterialViewSet, base_name='course_material')
router.register(r'course_material_file', CourseMaterialFileViewSet, base_name='course_material_file') 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'course-by-slug', CourseBySlugViewSet, base_name='course_by_slug'),
router.register(r'videos', VideoFileViewSet, base_name='course_by_slug'),
# Lessons # Lessons
router.register(r'course-lessons/(?P<course_id>[1-9][0-9]*)', LessonViewSet, base_name='lessons') router.register(r'course-lessons/(?P<course_id>[1-9][0-9]*)', LessonViewSet, base_name='lessons')
......
from django.db import models from django.db import models
from django.utils.translation import ugettext_lazy as _ 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): class Video(models.Model):
name = models.CharField( name = models.CharField(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment