
    si                        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 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 ddlmZmZmZ  eed       e ed      d       G d de                    Z eed       e ed      d       G d de                    Z eed       e ed      d       G d de                    Z y)zN
this page is handling the cbv methods for Break point conditions in settings
    )Any)messages)HttpResponse)render)reverse)method_decorator)gettext_lazy)AttendanceBreakpointFilter)!AttendanceValidationConditionForm)AttendanceValidationCondition)permission_required)login_required)HorillaFormViewHorillaListViewHorillaNavViewdispatch)namez-attendance.view_attendancevalidationconditionc                   l    e Zd ZdZeZeZ ed      df ed      df ed      df ed      d	fgZ	dd
iZ
y)BreakPointListz=
    list view of the Break point conditions in settings
    zAuto Validate Tillvalidation_at_workzMin Hour To Approve OTminimum_overtime_to_approvezOT Cut-Off/Dayovertime_cutoffActionsbreak_point_actionsz  style="width:200px !important" N)__name__
__module____qualname____doc__r   modelr
   filter_class_columnsheader_attrs     >/var/www/python-projects/worksol/attendance/cbv/break_point.pyr   r      se     *E-L 
	 "67	
#	$&CD	
	/0	
9,-	G 	DLr%   r   c                   N     e Zd ZdZdeddf fdZ ed      ZdZ e	       Z
 xZS )BreakPointNavViewz.
    navbar of attendance breakpoint view
    kwargsreturnNc                     t        |   di | t        j                  j	                         }|s;| j
                  j                  j                  d      rdt        d       d| _	        y y y )Nz,attendance.add_attendancevalidationconditiona&  
                                onclick = "event.stopPropagation();"
                                data-toggle="oh-modal-toggle"
                                data-target="#genericModal"
                                hx-target="#genericModalBody"
                                hx-get="zbreak-point-create-formz""
                                r$   )
super__init__r   objectsfirstrequestuserhas_permr   create_attrs)selfr)   	condition	__class__s      r&   r-   zBreakPointNavView.__init__<   sn    "6"199??A	T\\..77:
%)
 *11J)K(L M!!$D
yr%   zBreak Point Conditionz#listContainer)r   r   r   r   r   r-   r!   	nav_titlesearch_swap_targetr
   filter_instance__classcell__r6   s   @r&   r(   r(   2   s6    $ $ $ )*I)02Or%   r(   c                   b     e Zd ZdZeZeZ ed      Z	 fdZ
dedef fdZdedef fdZ xZS )BreakPointCreateFormz?
    form view for create and edit Break Point in settings
    zCreate Attendance conditionc                    t        |   di |}| j                  j                  j                  r@| j                  | j                  j                        }t        d      | j
                  _        | j                  |<   |S )N)instanceUpdate Attendance conditionr$   )r,   get_context_dataformr?   pk
form_classr!   verbose_name)r4   r)   contextrB   r6   s       r&   rA   z%BreakPointCreateForm.get_context_data]   sf    '*4V499  ??DII,>,>??D+,-J+KDOO(		r%   rB   r*   c                 2   | j                   j                  j                  rt        d      | j                  _        |j                         s>|j                  j                         }t        | j                  | j                  ||d      S t        | 5  |      S )Nr@   )rB   errors)rB   r?   rC   r!   rD   rE   is_validrH   as_datar   r0   template_namer,   form_invalid)r4   rB   rH   r6   s      r&   rL   z!BreakPointCreateForm.form_invalidf   sx    99  +,-J+KDOO(}}[[((*Fd00462R  w#D))r%   c                 V   |j                         r|j                  j                  r*t        j                  | j
                  t        d             n)t        j                  | j
                  t        d             |j                          | j                  d      S t        | )  |      S )Nz(Attendance Break-point settings updated.z(Attendance Break-point settings created.z#<script>location.reload();</script>)rI   r?   rC   r   successr0   r!   saver   r,   
form_valid)r4   rB   r6   s     r&   rP   zBreakPointCreateForm.form_validp   s    ==?}}  LL!$N"O   LL!$N"O IIK$$%JKKw!$''r%   )r   r   r   r   r   r   r   rD   r!   new_display_titlerA   r   r   rL   rP   r:   r;   s   @r&   r=   r=   O   sQ     *E2J78* * *(@ (\ ( (r%   r=   N)!r   typingr   django.contribr   django.httpr   django.shortcutsr   django.urlsr   django.utils.decoratorsr   django.utils.translationr	   r!   attendance.filtersr
   attendance.formsr   attendance.modelsr   horilla.decoratorsr   horilla_views.cbv_methodsr   horilla_views.generic.cbv.viewsr   r   r   r   r(   r=   r$   r%   r&   <module>r_      s     # $ #  4 6 9 > ; 2 4  .z2GH	_ 	 3
& .z2GH	3 3	 3
30 .z2GH	((? ((	 3
((r%   