Files
ihrm/facedetection/models.py

29 lines
815 B
Python
Raw Normal View History

import os
from django.db import models
from django.db.models.signals import post_delete
from django.dispatch import receiver
# Create your models here.
2025-04-30 14:55:35 +05:30
class FaceDetection(models.Model):
2025-04-30 14:55:35 +05:30
company_id = models.OneToOneField(
"base.Company", related_name="face_detection", on_delete=models.CASCADE
)
start = models.BooleanField(default=False)
2025-04-30 14:55:35 +05:30
class EmployeeFaceDetection(models.Model):
2025-04-30 14:55:35 +05:30
employee_id = models.OneToOneField(
"employee.Employee", related_name="face_detection", on_delete=models.CASCADE
)
image = models.ImageField()
@receiver(post_delete, sender=EmployeeFaceDetection)
def delete_image_file(sender, instance, **kwargs):
if instance.image and instance.image.path:
if os.path.isfile(instance.image.path):
os.remove(instance.image.path)