
    vg                     6    d Z ddlmZ ddlmZ  G d de      Zy)za
This module defines the configuration for the 'attendance' app within the Horilla HRMS project.
    )	AppConfig)APP_URLSc                   0     e Zd ZdZdZdZ fdZd Z xZS )AttendanceConfiga3  
    Configures the 'attendance' app and performs additional setup during the app's
    initialization. This includes appending the 'attendance' URL patterns to the
    project's main urlpatterns and dynamically adding the 'AttendanceMiddleware'
    to the middleware stack if it's not already present.
    zdjango.db.models.BigAutoField
attendancec                    ddl m}m} ddlm} ddlm} |j                   |d |d                   d}||vr|j                  |       t        j                  d       	 | j                          t        | -          y #  Y xY w)Nr   )includepath)
MIDDLEWARE)urlpatternszattendance/zattendance.urlsz*attendance.middleware.AttendanceMiddleware)django.urlsr	   r
   horilla.settingsr   horilla.urlsr   appendr   create_enable_disable_check_insuperready)selfr	   r
   r   r   middleware_path	__class__s         #/var/www/horilla/attendance/apps.pyr   zAttendanceConfig.ready   s{    -/,(9 :;	
 G*,o.)*	//1 		s   !B   Bc                 4   ddl m} ddlm} |j                  j                         }|D ]J  }|j                  j                  |      j                         r.	 |j                  j                  |       L |j                  j                  d       y#  Y nxY w)z
        Checks if an AttendanceGeneralSetting object exists for each company.
        If it doesn't exist, creates one.
        r   )AttendanceGeneralSetting)Company)
company_idN)
attendance.modelsr   base.modelsr   objectsallfilterexistscreateget_or_create)r   r   r   	companiescompanys        r   r   z/AttendanceConfig.create_enable_disable_check_in)   s    
 	?'OO'')	  	G+33::g:NUUW,44;;w;O	 	!((66$6Gs   BB)	__name__
__module____qualname____doc__default_auto_fieldnamer   r   __classcell__)r   s   @r   r   r   
   s      9D(H    r   N)r)   django.appsr   horilla.horilla_settingsr   r    r-   r   <module>r1      s     " -.Hy .Hr-   