|
|
@ -2,7 +2,7 @@ from rest_framework import serializers |
|
|
# from dj_filer.admin import get_thumbs |
|
|
# from dj_filer.admin import get_thumbs |
|
|
from utils import get_thumbs |
|
|
from utils import get_thumbs |
|
|
from apps.course.models import Course, CourseCategory, Attachment, Glossary, LessonCompletion, Participant, Lesson, CourseAttachment, CourseGlossary, CourseLesson |
|
|
from apps.course.models import Course, CourseCategory, Attachment, Glossary, LessonCompletion, Participant, Lesson, CourseAttachment, CourseGlossary, CourseLesson |
|
|
from apps.course.models.course import get_localized_field |
|
|
|
|
|
|
|
|
from apps.course.models.course import get_localized_field, normalize_level, normalize_status |
|
|
from apps.chat.models import RoomMessage |
|
|
from apps.chat.models import RoomMessage |
|
|
from apps.account.serializers import UserProfileSerializer |
|
|
from apps.account.serializers import UserProfileSerializer |
|
|
from decimal import Decimal |
|
|
from decimal import Decimal |
|
|
@ -38,7 +38,7 @@ class CourseCategorySerializer(serializers.ModelSerializer): |
|
|
|
|
|
|
|
|
class Meta: |
|
|
class Meta: |
|
|
model = CourseCategory |
|
|
model = CourseCategory |
|
|
fields = ['id', 'name', 'slug', 'course_count'] |
|
|
|
|
|
|
|
|
fields = ['id', 'name', 'slug', 'icon', 'course_count'] |
|
|
|
|
|
|
|
|
def _lang(self): |
|
|
def _lang(self): |
|
|
request = self.context.get('request') |
|
|
request = self.context.get('request') |
|
|
@ -104,10 +104,10 @@ class CourseListSerializer(serializers.ModelSerializer): |
|
|
return get_localized_field(self._lang(), obj.slug) |
|
|
return get_localized_field(self._lang(), obj.slug) |
|
|
|
|
|
|
|
|
def get_level(self, obj): |
|
|
def get_level(self, obj): |
|
|
return get_localized_field(self._lang(), obj.level) |
|
|
|
|
|
|
|
|
return normalize_level(obj.level) |
|
|
|
|
|
|
|
|
def get_status(self, obj): |
|
|
def get_status(self, obj): |
|
|
return get_localized_field(self._lang(), obj.status) |
|
|
|
|
|
|
|
|
return normalize_status(obj.status) |
|
|
|
|
|
|
|
|
def get_short_description(self, obj): |
|
|
def get_short_description(self, obj): |
|
|
return get_localized_field(self._lang(), obj.short_description) |
|
|
return get_localized_field(self._lang(), obj.short_description) |
|
|
@ -450,10 +450,10 @@ class CourseDetailSerializer(serializers.ModelSerializer): |
|
|
return get_localized_field(self._lang(), obj.slug) |
|
|
return get_localized_field(self._lang(), obj.slug) |
|
|
|
|
|
|
|
|
def get_level(self, obj): |
|
|
def get_level(self, obj): |
|
|
return get_localized_field(self._lang(), obj.level) |
|
|
|
|
|
|
|
|
return normalize_level(obj.level) |
|
|
|
|
|
|
|
|
def get_status(self, obj): |
|
|
def get_status(self, obj): |
|
|
return get_localized_field(self._lang(), obj.status) |
|
|
|
|
|
|
|
|
return normalize_status(obj.status) |
|
|
|
|
|
|
|
|
def get_description(self, obj): |
|
|
def get_description(self, obj): |
|
|
return get_localized_field(self._lang(), obj.description) |
|
|
return get_localized_field(self._lang(), obj.description) |
|
|
@ -617,7 +617,7 @@ class MyCourseListSerializer(serializers.ModelSerializer): |
|
|
return get_localized_field(self._lang(), obj.slug) |
|
|
return get_localized_field(self._lang(), obj.slug) |
|
|
|
|
|
|
|
|
def get_status(self, obj): |
|
|
def get_status(self, obj): |
|
|
return get_localized_field(self._lang(), obj.status) |
|
|
|
|
|
|
|
|
return normalize_status(obj.status) |
|
|
|
|
|
|
|
|
def get_short_description(self, obj): |
|
|
def get_short_description(self, obj): |
|
|
return get_localized_field(self._lang(), obj.short_description) |
|
|
return get_localized_field(self._lang(), obj.short_description) |
|
|
|