B
    bE                 @   sX   d dl Z d dlmZ d dlmZ d dlmZ d dlm	Z	 e
eG dd dejZdS )    N)gettext_lazy)admin)	BreakTime)BreakTimeFormc                   sB   e Zd Zdd Zede_dZdZeZ	 fddZ
dd	 Z  ZS )
BreakTimeAdminc             C   sj   t j dj|jdd}|t j|jd }| |  j}|dkrXdj|d|dS d	j|dd
S )Nz2000-01-01 {time})timez%Y-%m-%d %H:%M:%S)Zminutesr   z{out}+{days}z%H:%M:%S)outdaysz{out})r   )	datetimestrptimeformatperiod_startZ	timedeltaZ
end_margindater	   strftime)selfobjZ	break_outZbreak_inr	    r   9G:\easytimepro\master/mysite/att\admin\breaktime_admin.pybreak_in_time   s    zBreakTimeAdmin.break_in_timeZbreakTime_field_endTime)idaliasr   r   Zduration	calc_type)r   r   Zearly_inZlate_inc                s    t t| |j|jjd}|S )N)
company_id)superr   get_querysetfilteruserZcurrent_company)r   ZrequestZ	query_set)	__class__r   r   r      s    zBreakTimeAdmin.get_querysetc             C   sP   ddl m} |jd}tjj||jjdj	|jj
d}| rL|tdd S )Nr   )AdminRuntimeWarningr   )r   r   )r   z'BreakTime with this name already exist.)Zmysite.admin.exceptionsr   Zcleaned_datagetr   Zobjectsr   instancer   Zexcluder   exists_)r   Z
model_formr   r   Zbkr   r   r   check_domain_rules   s    z!BreakTimeAdmin.check_domain_rules)__name__
__module____qualname__r   r"   Zshort_descriptionZlist_displayZlist_filterr   Zformr   r#   __classcell__r   r   )r   r   r   	   s   
r   )r
   Zdjango.utils.translationr   r"   mysiter   Zmysite.att.modelsr   Zmysite.att.formsr   registerZZKModelAdminr   r   r   r   r   <module>   s   