[UPDT] FACEDETECTION: Employee face detect image delete
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
from base.forms import ModelForm
|
||||
from facedetection.models import FaceDetection
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
|
||||
class FaceDetectionSetupForm(ModelForm):
|
||||
verbose_name = "Facedetection Configuration"
|
||||
|
||||
|
||||
class Meta:
|
||||
model = FaceDetection
|
||||
exclude = ["company_id"]
|
||||
@@ -17,4 +18,3 @@ class FaceDetectionSetupForm(ModelForm):
|
||||
context = {"form": self}
|
||||
table_html = render_to_string("common_form.html", context)
|
||||
return table_html
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import os
|
||||
|
||||
from django.db import models
|
||||
from django.db.models.signals import post_delete
|
||||
from django.dispatch import receiver
|
||||
|
||||
# Create your models here.
|
||||
|
||||
@@ -15,3 +19,10 @@ class EmployeeFaceDetection(models.Model):
|
||||
"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)
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<form hx-post="{% url 'face-config' %}" hx-swap="none" hx-on-htmx-after-request="$('#reloadMessagesButton').click();">
|
||||
{% csrf_token %}
|
||||
{{form.as_p}}
|
||||
|
||||
</form>
|
||||
</form>
|
||||
|
||||
@@ -141,7 +141,6 @@ def get_facedetection(request):
|
||||
@permission_required("geofencing.add_localbackup")
|
||||
@hx_request_required
|
||||
def face_detection_config(request):
|
||||
print(">>>>>>>>>>>>>>>>>>>>>")
|
||||
try:
|
||||
form = FaceDetectionSetupForm(instance=get_facedetection(request))
|
||||
except:
|
||||
|
||||
Reference in New Issue
Block a user