Commit 70976c3d authored by Virgilio Santos's avatar Virgilio Santos
Browse files

certificate: update serializer and view for CertificateData

parent a2500762
...@@ -42,6 +42,19 @@ class CertificateTemplateSerializer(serializers.ModelSerializer): ...@@ -42,6 +42,19 @@ class CertificateTemplateSerializer(serializers.ModelSerializer):
def get_course_name(self, obj): def get_course_name(self, obj):
return obj.course.name return obj.course.name
class CertificateTemplateCreateSerializer(serializers.ModelSerializer):
class Meta:
model = CertificateTemplate
fields = ('course', 'document_type', 'workspace')
class CertificateTemplateImageSerializer(serializers.ModelSerializer):
class Meta:
model = CertificateTemplate
fields = ('base_logo', 'cert_logo', 'signature', 'site_logo')
class CertificationProcessSerializer(serializers.ModelSerializer): class CertificationProcessSerializer(serializers.ModelSerializer):
course_certification = serializers.SlugRelatedField(slug_field="link_hash", read_only=True) course_certification = serializers.SlugRelatedField(slug_field="link_hash", read_only=True)
...@@ -89,10 +102,3 @@ class EvaluationSerializer(serializers.ModelSerializer): ...@@ -89,10 +102,3 @@ class EvaluationSerializer(serializers.ModelSerializer):
class Meta: class Meta:
model = Evaluation model = Evaluation
class CertificateTemplateImageSerializer(serializers.ModelSerializer):
class Meta:
model = CertificateTemplate
fields = ('base_logo', 'cert_logo', 'signature', 'site_logo')
...@@ -12,6 +12,7 @@ from courses.certification.serializers import ( ...@@ -12,6 +12,7 @@ from courses.certification.serializers import (
CertificationProcessSerializer, CertificationProcessSerializer,
CourseCertificationSerializer, CourseCertificationSerializer,
CertificateTemplateSerializer, CertificateTemplateSerializer,
CertificateTemplateCreateSerializer,
CertificateTemplateImageSerializer, CertificateTemplateImageSerializer,
) )
...@@ -41,9 +42,13 @@ class CertificateDataMixin(viewsets.ModelViewSet): ...@@ -41,9 +42,13 @@ class CertificateDataMixin(viewsets.ModelViewSet):
class CertificateDataViewSet(CertificateDataMixin, viewsets.ModelViewSet): class CertificateDataViewSet(CertificateDataMixin, viewsets.ModelViewSet):
model = CertificateTemplate model = CertificateTemplate
serializer_class = CertificateTemplateSerializer
permission_classes = (IsProfessorCoordinatorOrAdminPermissionOrReadOnly, ) permission_classes = (IsProfessorCoordinatorOrAdminPermissionOrReadOnly, )
def get_serializer_class(self):
if self.action == 'create':
return CertificateTemplateCreateSerializer
return CertificateTemplateSerializer
@action(detail=True, methods=['get', 'post']) @action(detail=True, methods=['get', 'post'])
def images(self, request, pk=None): def images(self, request, pk=None):
obj = self.get_object() obj = self.get_object()
......
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