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