
    vg                         d Z ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZmZ  G d	 d
e      Z G d de      Z G d de	      Z G d de	      Z G d de	      Zy)z
Module containing forms for managing biometric devices and associated data.

This module provides Django forms for creating and managing biometric devices,
employee biometric data, COSEC users, and related configurations.
    )forms)gettext_lazy)	ModelForm)Form)Employee   )BiometricDevicesBiometricEmployeesc                   $    e Zd ZdZ G d d      Zy)BiometricDeviceFormas  
    Form for creating and updating biometric device configurations.

    This form is used to create and update biometric device configurations.
    It includes fields for specifying the device name, IP address, TCP communication port,
    and other relevant settings. Additionally, it excludes fields related to scheduler
    settings and device activation status.
    c                       e Zd ZdZeZdZg dZ ed       ed       ed       ed      dZ	 e
j                  d	d
d       e
j                  ddd      dZy)BiometricDeviceForm.Meta6
        Meta class to add additional options
        __all__)is_schedulerscheduler_duration	is_activezDevice Namez
IP AddresszTCP COMM.PortzHeader Request ID)name
machine_ipportanviz_request_idmachineTypeInputzmachineTypeChange($(this)))idonchangeattrsz!oh-input oh-input--password w-100password)classtype)machine_typecosec_passwordN)__name__
__module____qualname____doc__r	   modelfieldsexclude_labelsr   Select	TextInputwidgets     #/var/www/horilla/biometric/forms.pyMetar      s    	 !
 m$L/o& !"5 6	
 )ELL, < .eoo@&
r/   r1   Nr"   r#   r$   r%   r1   r.   r/   r0   r   r      s    
 
r/   r   c                   $    e Zd ZdZ G d d      Zy)BiometricDeviceSchedulerForma  
    Form for updating the scheduler duration of a biometric device.

    This form is used to update the scheduler duration of a biometric
    device to fetch attendance data.
    It includes a field for entering the scheduler duration in the format HH:MM.
    c                   .    e Zd ZdZeZdgZd ed      iZy)!BiometricDeviceSchedulerForm.Metar   r   z&Enter the duration in the format HH:MMN)	r"   r#   r$   r%   r	   r&   r'   r)   r*   r.   r/   r0   r1   r6   G   s(    	 !&' !$L"M
r/   r1   Nr2   r.   r/   r0   r4   r4   >   s    	
 	
r/   r4   c                        e Zd ZdZ ej
                  ej                  j                          ej                          e
d            Z fdZ xZS )EmployeeBiometricAddFormar  
    Form for adding employees to a biometric device.

    This form allows administrators to add multiple employees to a biometric device
    for biometric authentication. It includes a field for selecting employees from
    a queryset and ensures that only active employees not already associated with
    a 'zk' type biometric device are available for selection.
    	Employeesquerysetwidgetlabelc                 
   t        |   |i | t        j                  j	                  d      j                  dd      }t        j                  j	                  d      j                  |      | j                  d   _	        y )	Nzk)device_id__machine_typeemployee_idTflatr   id__inemployee_ids
super__init__r
   objectsfiltervalues_listr   r(   r'   r;   )selfargskwargszk_employee_ids	__class__s       r0   rJ   z!EmployeeBiometricAddForm.__init__c   s    $)&),44;;$( < 

+m$+
/ 	 08/?/?/F/F 0G 0

''
) 	N#,r/   r"   r#   r$   r%   r   ModelMultipleChoiceFieldr   rK   allSelectMultipler)   rG   rJ   __classcell__rR   s   @r0   r8   r8   S   sM     2511!!%%'#u##%nL* *r/   r8   c                        e Zd ZdZ ej
                  ej                  j                          ej                          e
d            Zdd fd
Z xZS )CosecUserAddFormaq  
    Form for adding users to a COSEC biometric device.

    This form allows administrators to add multiple users to a COSEC biometric device
    for biometric authentication. It includes a field for selecting users from
    a queryset and ensures that only active users not already associated with
    a 'cosec' type biometric device are available for selection.
    r9   r:   N	device_idc                
   t        |   |i | t        j                  j	                  |      j                  dd      }t        j                  j	                  d      j                  |      | j                  d   _	        y )Nr[   rA   TrB   rD   rE   rG   rH   )rN   r\   rO   rP   cosec_employee_idsrR   s        r0   rJ   zCosecUserAddForm.__init__}   s    $)&)/77>> ? 

+m$+
/ 	 08/?/?/F/F 0G 0

'+'
, 	N#,r/   rS   rX   s   @r0   rZ   rZ   m   sR     2511!!%%'#u##%nL )- - -r/   rZ   c                       e Zd ZdZ ej
                   ed       ed       ej                  ddi            Z ej                  dd ej                         	      Z ej                  dd ej                         	      Z ej                  dd ej                         	      Z ej                  d ej                  d
dd            Z ej                  dd ej                         	      Z fdZ xZS )COSECUserForma;  
    Form for adding or updating users in a COSEC biometric device.

    This form allows administrators to add or update users in a COSEC biometric
    device. It includes fields for specifying the user's name, whether the user
    is active, whether the user is a VIP user, whether validity is enabled for
    the user, the validity end date, and whether to bypass finger-based
    authentication for the user. It provides validation to ensure that the
    name does not exceed 15 characters and that the validity end date is
    provided when validity is enabled.
    zEmployee Namez15 characters max.r   zoh-input w-100r   )r=   	help_textr<   F)initialrequiredr<   datezoh-input w-100 form-control)r   r   )rc   r<   c                     t         |          }t        |d         dkD  rt        j                  d      |d   r'|j                  d      t        j                  d      y y )Nr      z@Maximum 15 characters allowed for Name in COSEC Biometric Devicevalidity_enablevalidity_end_datezDWhen the Validity field is enabled, a Validity End Date is required.)rI   cleanlenr   ValidationErrorget)rN   cleaned_datarR   s     r0   ri   zCOSECUserForm.clean   ss    w}|F#$r)''R  )* 34<++Z  = +r/   )r"   r#   r$   r%   r   	CharFieldr)   r,   r   BooleanFieldCheckboxInputuser_activeviprg   	DateField	DateInputrh   by_pass_fingerri   rW   rX   s   @r0   r`   r`      s   
 5?? ()ug/?%@AD
 %%$$"u""$K
 %

"u""$C
 )e(("u""$O
 (u!,IJ
 (U''"u""$N
 
r/   r`   N)r%   djangor   django.utils.translationr   r)   attendance.formsr   
base.formsr   employee.modelsr   modelsr	   r
   r   r4   r8   rZ   r`   r.   r/   r0   <module>r|      s[     6 &  $ 8)
) )
X
9 
**t *4-t -47D 7r/   