Commit 91f0df80 authored by Matheus Miranda's avatar Matheus Miranda
Browse files

Add ct_id to course serializer

parent ede1052b
......@@ -13,6 +13,7 @@ from .models import (
Unit,
Lesson
)
from .certification.models import CertificateTemplate
User = get_user_model()
......@@ -37,6 +38,7 @@ class CourseSerializer(serializers.ModelSerializer):
is_user_coordinator = serializers.SerializerMethodField()
is_assistant_or_coordinator = serializers.SerializerMethodField()
track = serializers.SerializerMethodField()
ct_id = serializers.SerializerMethodField()
class Meta:
model = Course
......@@ -46,7 +48,7 @@ class CourseSerializer(serializers.ModelSerializer):
'start_date', 'home_published', 'authors_names', 'has_started',
'min_percent_to_complete', 'is_user_assistant', 'is_user_coordinator',
'is_assistant_or_coordinator', 'professors', 'track', 'forum_id',
'informations', 'description', 'lang', 'course_load')
'informations', 'description', 'lang', 'course_load', 'ct_id',)
@staticmethod
def get_home_thumbnail_url(obj):
......@@ -69,6 +71,12 @@ class CourseSerializer(serializers.ModelSerializer):
return {'name': course_track.first().name, 'home_position': course_track.first().home_position }
return {}
def get_ct_id(self, obj):
ct = CertificateTemplate.objects.filter(course=obj).first()
if ct:
return ct.id
return None
def update(self, instance, validated_data):
intro_video_data = validated_data.pop('intro_video', None)
......
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