[UPDT] BIOMETRIC: Updated filter functions to include search for last name also
This commit is contained in:
@@ -8,6 +8,7 @@ employee biometric data, COSEC users, and related configurations.
|
||||
|
||||
from django import forms
|
||||
from django.db.models import Q
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
from base.forms import Form, ModelForm
|
||||
@@ -296,6 +297,15 @@ class DahuaUserForm(Form):
|
||||
}
|
||||
)
|
||||
|
||||
def as_p(self):
|
||||
"""
|
||||
Render the form fields as HTML table rows with Bootstrap styling.
|
||||
"""
|
||||
|
||||
context = {"form": self}
|
||||
table_html = render_to_string("normal_form.html", context)
|
||||
return table_html
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super().clean()
|
||||
device = None
|
||||
@@ -357,6 +367,15 @@ class MapBioUsers(ModelForm):
|
||||
)
|
||||
self.fields["user_id"].required = True
|
||||
|
||||
def as_p(self):
|
||||
"""
|
||||
Render the form fields as HTML table rows with Bootstrap styling.
|
||||
"""
|
||||
|
||||
context = {"form": self}
|
||||
table_html = render_to_string("normal_form.html", context)
|
||||
return table_html
|
||||
|
||||
def clean(self):
|
||||
cleaned_data = super().clean()
|
||||
user_id = cleaned_data.get("user_id")
|
||||
|
||||
@@ -202,6 +202,15 @@ class BiometricDevices(HorillaModel):
|
||||
|
||||
return html
|
||||
|
||||
def card_action(self):
|
||||
"""
|
||||
render card data
|
||||
"""
|
||||
return render_template(
|
||||
path="cbv/biometric_card_action.html",
|
||||
context={"device": self},
|
||||
)
|
||||
|
||||
def archive_status(self):
|
||||
"""
|
||||
archive status
|
||||
|
||||
34
biometric/templates/cbv/biometric_card_action.html
Normal file
34
biometric/templates/cbv/biometric_card_action.html
Normal file
@@ -0,0 +1,34 @@
|
||||
{% load static i18n %}
|
||||
<div class="mt-auto" >
|
||||
<div class="oh-kanban-card__biometric-actions flex gap-3" style="{% if device.machine_type == 'anviz' or device.machine_type == 'cosec' %} margin-top: 0px; {% endif %}">
|
||||
<!-- Test Button -->
|
||||
<a href="#" hx-get="{% url 'biometric-device-test' device.id %}" data-toggle="oh-modal-toggle"
|
||||
data-target="#BiometricDeviceTestModal" hx-target="#BiometricDeviceTestFormTarget"
|
||||
class="oh-checkpoint-badge text-success mr-2" style="border: 2px solid #28a745; padding: 5px 10px; border-radius: 4px; display: inline-block; color: #28a745;">
|
||||
{% trans "Test" %}
|
||||
</a>
|
||||
|
||||
<!-- Schedule / Unschedule Button -->
|
||||
{% if is_scheduler %}
|
||||
<a hx-confirm="Do you want to unschedule the device attendance fetching?"
|
||||
hx-post="{% url 'biometric-device-unschedule' device.id %}" hx-target="#biometricDeviceList"
|
||||
class="oh-checkpoint-badge text-info" style="border: 2px solid #17a2b8; padding: 5px 10px; border-radius: 4px; display: inline-block; color: #17a2b8;">
|
||||
{% trans "Unschedule" %}
|
||||
</a>
|
||||
{% else %}
|
||||
<a href="#" hx-get="{% url 'biometric-device-schedule' device.id %}" data-toggle="oh-modal-toggle"
|
||||
data-target="#BiometricDeviceModal" hx-target="#BiometricDeviceFormTarget"
|
||||
class="oh-checkpoint-badge text-info" style="border: 2px solid #17a2b8; padding: 5px 10px; border-radius: 4px; display: inline-block; color: #17a2b8;">
|
||||
{% trans "Schedule" %}
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
<!-- Employee Button (Only for specific machine types) -->
|
||||
{% if device.machine_type == "zk" or device.machine_type == "cosec" or device.machine_type == "dahua" or device.machine_type == "etimeoffice" %}
|
||||
<a href="{% url 'biometric-device-employees' device.id %}" class="oh-checkpoint-badge text-secondary bio-user-list"
|
||||
style="border: 2px solid #6c757d; padding: 5px 10px; border-radius: 4px; display: inline-block; color: #6c757d;">
|
||||
{% trans "Employee" %}
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
15
biometric/templates/cbv/biometric_card_body.html
Normal file
15
biometric/templates/cbv/biometric_card_body.html
Normal file
@@ -0,0 +1,15 @@
|
||||
{% load i18n %}
|
||||
|
||||
<div class="flex flex-col flex-grow h-full">
|
||||
<h5 class="mb-1 font-medium text-sm">
|
||||
{{instance.name}}
|
||||
</h5>
|
||||
|
||||
<div class="text-xs text-[#565E6C] mb-1 flex flex-col gap-2 flex-grow">
|
||||
{% trans "Device:" %} {{instance.get_machine_type}} <br />
|
||||
{% trans "Direction:" %} {{instance.get_device_direction_display}} <br />
|
||||
{{instance.get_card_details|safe}} <br />
|
||||
{{instance.render_live_capture_html|safe}} <br />
|
||||
{{instance.card_action|safe}}
|
||||
</div>
|
||||
</div>
|
||||
@@ -16,6 +16,7 @@ import pytz
|
||||
from apscheduler.schedulers.background import BackgroundScheduler
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.db.models import Q
|
||||
from django.http import HttpResponse, JsonResponse
|
||||
from django.shortcuts import redirect, render
|
||||
from django.template.loader import render_to_string
|
||||
@@ -1314,7 +1315,8 @@ def search_employee_device(request):
|
||||
employees = zk_employees_fetch(device)
|
||||
if search:
|
||||
search_employees = BiometricEmployees.objects.filter(
|
||||
employee_id__employee_first_name__icontains=search
|
||||
Q(employee_id__employee_first_name__icontains=search)
|
||||
| Q(employee_id__employee_last_name__icontains=search)
|
||||
)
|
||||
search_uids = search_employees.values_list("uid", flat=True)
|
||||
employees = [
|
||||
@@ -1330,8 +1332,9 @@ def search_employee_device(request):
|
||||
elif device.machine_type == "dahua" or device.machine_type == "etimeoffice":
|
||||
search_employees = BiometricEmployees.objects.filter(device_id=device)
|
||||
if search:
|
||||
search_employees = BiometricEmployees.objects.filter(
|
||||
employee_id__employee_first_name__icontains=search, device_id=device
|
||||
search_employees = search_employees.filter(
|
||||
Q(employee_id__employee_first_name__icontains=search)
|
||||
| Q(employee_id__employee_last_name__icontains=search)
|
||||
)
|
||||
template = (
|
||||
"biometric_users/dahua/list_dahua_employees.html"
|
||||
@@ -1347,7 +1350,8 @@ def search_employee_device(request):
|
||||
employees = cosec_employee_fetch(device_id)
|
||||
if search:
|
||||
search_employees = BiometricEmployees.objects.filter(
|
||||
employee_id__employee_first_name__icontains=search, device_id=device
|
||||
Q(employee_id__employee_first_name__icontains=search)
|
||||
| Q(employee_id__employee_last_name__icontains=search)
|
||||
)
|
||||
else:
|
||||
search_employees = BiometricEmployees.objects.filter(device_id=device)
|
||||
|
||||
Reference in New Issue
Block a user