51 lines
1.6 KiB
Python
51 lines
1.6 KiB
Python
from rest_framework import routers, serializers, viewsets
|
|
|
|
from .models import Certification, CertificationDefinition, CertificationVersion
|
|
|
|
|
|
class CertificationDefinitionSerializer(serializers.HyperlinkedModelSerializer):
|
|
class Meta:
|
|
model = CertificationDefinition
|
|
fields = ["certification_name", "department", "mailing_list"]
|
|
|
|
|
|
class CertificationDefinitionViewSet(viewsets.ModelViewSet):
|
|
queryset = CertificationDefinition.objects.all()
|
|
serializer_class = CertificationDefinitionSerializer
|
|
|
|
|
|
class CertificationVersionSerializer(serializers.HyperlinkedModelSerializer):
|
|
class Meta:
|
|
model = CertificationVersion
|
|
fields = ["definition", "version"]
|
|
|
|
|
|
class CertificationVersionViewSet(viewsets.ModelViewSet):
|
|
queryset = CertificationVersion.objects.all()
|
|
serializer_class = CertificationVersionSerializer
|
|
|
|
|
|
class CertificationSerializer(serializers.HyperlinkedModelSerializer):
|
|
class Meta:
|
|
model = Certification
|
|
fields = [
|
|
"name",
|
|
"member",
|
|
"certification_version",
|
|
"certified_by",
|
|
"date",
|
|
"shop_lead_notified",
|
|
"notes",
|
|
]
|
|
|
|
|
|
class CertificationViewSet(viewsets.ModelViewSet):
|
|
queryset = Certification.objects.all()
|
|
serializer_class = CertificationSerializer
|
|
|
|
|
|
router = routers.DefaultRouter()
|
|
router.register(r"paperwork/certification_definition", CertificationDefinitionViewSet)
|
|
router.register(r"paperwork/certification_version", CertificationVersionViewSet)
|
|
router.register(r"paperwork/certification", CertificationViewSet)
|