diff --git a/facedetection/models.py b/facedetection/models.py index 25272e471..065ef3901 100644 --- a/facedetection/models.py +++ b/facedetection/models.py @@ -5,6 +5,9 @@ from django.db import models from django.db.models.signals import post_delete from django.dispatch import receiver +from employee.models import Employee +from horilla.models import HorillaModel, upload_path + # Create your models here. @@ -44,9 +47,13 @@ class FaceDetection(models.Model): class EmployeeFaceDetection(models.Model): employee_id = models.OneToOneField( - "employee.Employee", related_name="face_detection", on_delete=models.CASCADE + Employee, related_name="face_detection", on_delete=models.CASCADE + ) + image = models.ImageField( + null=True, + blank=True, + upload_to=upload_path, ) - image = models.ImageField() @receiver(post_delete, sender=EmployeeFaceDetection) diff --git a/facedetection/views.py b/facedetection/views.py index df56d40bd..5bf859627 100644 --- a/facedetection/views.py +++ b/facedetection/views.py @@ -101,6 +101,11 @@ class EmployeeFaceDetectionGetPostAPIView(APIView): except Exception as e: raise serializers.ValidationError(e) + def get(self, request): + facedetection = self.get_facedetection(request) + serializer = EmployeeFaceDetectionSerializer(facedetection) + return Response(serializer.data, status=status.HTTP_200_OK) + def post(self, request): if self.get_facedetection(request).start: employee_id = request.user.employee_get.id