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):
def get_course_name(self, obj):
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):
course_certification = serializers.SlugRelatedField(slug_field="link_hash", read_only=True)
......@@ -89,10 +102,3 @@ class EvaluationSerializer(serializers.ModelSerializer):
class Meta:
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 (
CertificationProcessSerializer,
CourseCertificationSerializer,
CertificateTemplateSerializer,
CertificateTemplateCreateSerializer,
CertificateTemplateImageSerializer,
)
......@@ -41,9 +42,13 @@ class CertificateDataMixin(viewsets.ModelViewSet):
class CertificateDataViewSet(CertificateDataMixin, viewsets.ModelViewSet):
model = CertificateTemplate
serializer_class = CertificateTemplateSerializer
permission_classes = (IsProfessorCoordinatorOrAdminPermissionOrReadOnly, )
def get_serializer_class(self):
if self.action == 'create':
return CertificateTemplateCreateSerializer
return CertificateTemplateSerializer
@action(detail=True, methods=['get', 'post'])
def images(self, request, pk=None):
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