|
|
|
|
@ -150,8 +150,8 @@ class CourseCreateSerializer(DispatchContentMixin, |
|
|
|
|
self.dispatch_gallery(course, gallery) |
|
|
|
|
return course |
|
|
|
|
|
|
|
|
|
def to_representation(self, instance): |
|
|
|
|
return CourseSerializer(instance, context=self.context).to_representation(instance) |
|
|
|
|
def to_representation(self, instance): |
|
|
|
|
return CourseSerializer(instance=instance, context=self.context).to_representation(instance) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LessonCreateSerializer(serializers.ModelSerializer): |
|
|
|
|
@ -318,7 +318,7 @@ class LessonSerializer(serializers.ModelSerializer): |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class CourseSerializer(CourseCreateSerializer): |
|
|
|
|
class CourseSerializer(serializers.ModelSerializer): |
|
|
|
|
author = UserSerializer() |
|
|
|
|
category = CategorySerializer() |
|
|
|
|
materials = MaterialSerializer(many=True) |
|
|
|
|
@ -326,3 +326,40 @@ class CourseSerializer(CourseCreateSerializer): |
|
|
|
|
gallery = GallerySerializer() |
|
|
|
|
content = ContentSerializer(many=True) |
|
|
|
|
lessons = LessonSerializer(many=True) |
|
|
|
|
|
|
|
|
|
class Meta: |
|
|
|
|
model = Course |
|
|
|
|
fields = ( |
|
|
|
|
'id', |
|
|
|
|
'slug', |
|
|
|
|
'author', |
|
|
|
|
'title', |
|
|
|
|
'short_description', |
|
|
|
|
'from_author', |
|
|
|
|
'cover', |
|
|
|
|
'price', |
|
|
|
|
'is_infinite', |
|
|
|
|
'deferred_start_at', |
|
|
|
|
'category', |
|
|
|
|
'duration', |
|
|
|
|
'is_featured', |
|
|
|
|
'url', |
|
|
|
|
'status', |
|
|
|
|
'likes', |
|
|
|
|
'materials', |
|
|
|
|
'created_at', |
|
|
|
|
'update_at', |
|
|
|
|
'deactivated_at', |
|
|
|
|
'content', |
|
|
|
|
'gallery', |
|
|
|
|
'lessons', |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
read_only_fields = ( |
|
|
|
|
'id', |
|
|
|
|
'url', |
|
|
|
|
'lessons', |
|
|
|
|
'created_at', |
|
|
|
|
'update_at', |
|
|
|
|
'deactivated_at', |
|
|
|
|
) |
|
|
|
|
|