B
    b                 @   s   d dl Z d dlmZ d dlmZmZ d dlmZ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 G dd deZG dd deZG dd deZG dd deZeee dS )    N)gettext_lazy)	ModelFormValidationError)MinValueValidatorMaxValueValidator)ClientDetails)ZKModelAdmin)ZKModelAction)zk_site)AdminRuntimeWarning)formsc                   s  e Zd ZejedddZejeddZejeddZ	ejeddZ
ejeddZejed	d
dZejjddi ejeddZejedejjddiddZejedejjddiddZejededgdZejdddZ fddZG dd dZ  ZS )ClientDetailsChangeFormclientDetails_field_clientIdT)labelZdisabledclientDetails_field_companyName)r   clientDetails_field_addressclientDetails_field_branch!clientDetails_field_contactPersonclientDetails_field_mobilez^\+?1?\d{9,15}$)r   regexclasszlayui-inputclientDetails_field_locationclientDetails_field_longitudereadonly)attrs)r   widgetclientDetails_field_latitude'clientDetails_field_punchLocationRadiusg      ?)r   
validatorsF )requiredinitialc                s(   t t| j|| d| jd jjd< d S )NT	client_idr   )superr   __init__fieldsr   r   )selfargskwargs)	__class__ =G:\easytimepro\master/mysite/att\admin\clientdetails_admin.pyr$   !   s    z ClientDetailsChangeForm.__init__c               @   s   e Zd ZeZdZdS )zClientDetailsChangeForm.Meta)
r"   company_nameaddressbranchcontact_personmobiledistance	longitudelatitudepunch_location_radiusN)__name__
__module____qualname__r   modelr%   r*   r*   r*   r+   Meta%   s   r9   )r5   r6   r7   r   	CharField_r"   r,   	TextFieldr-   r.   r/   
RegexFieldr0   r   r   updateIntegerFieldr1   
FloatFieldwidgetsZKNumberInputr2   r3   r   r4   	FileFieldlogor$   r9   __classcell__r*   r*   )r)   r+   r      s"   


r   c               @   s
  e Zd ZejeddZejeddZejeddZ	ejeddZ
ejeddZejeddd	Zejjd
di ejedddZejeddejjddiddZejeddejjddiddZejededgdZejdddZG dd dZdS )AddClientDetailsFormr   )r   r   r   r   r   r   z^\+?1?\d{9,15}$)r   r   r   zlayui-inputr   2   )r   r!   r   g\lS@r   )r   )r   r!   r   r   g_7s)@r   g      ?)r   r   Fr   )r    r!   c               @   s   e Zd ZeZdZdS )zAddClientDetailsForm.Meta__all__N)r5   r6   r7   r   r8   r%   r*   r*   r*   r+   r9   <   s   r9   N)r5   r6   r7   r   r:   r;   r"   r,   r<   r-   r.   r/   r=   r0   r   r   r>   r?   r1   r@   rA   rB   r2   r3   r   r4   rC   rD   r9   r*   r*   r*   r+   rF   +   s    
rF   c               @   s0   e Zd ZedZedZedZeZdd Z	dS )AddClientDetailsZ%clientDetails_action_addClientDetailsZ,clientDetails_action_addClientDetailsHelpTxtZ0clientDetails_action_addClientDetailsDescriptionc             O   sv   | j jj}t| j j}| rr| j jd|d< tj	j
| j jd|d}|rZttd|d= tf |}|  d S )NrD   r"   )r"   companyZatt_outDoorManagement_client_idrJ   )requestusercurrent_companyrF   ZPOSTZis_validZFILESgetr   Zobjectsfilterr   r;   Zsave)r&   r'   r(   Z
company_idformr"   objr*   r*   r+   actionG   s    

zAddClientDetails.actionN)
r5   r6   r7   r;   Zverbose_nameZhelp_txtZshort_descriptionrF   Zaction_formrR   r*   r*   r*   r+   rI   A   s
   rI   c                   s.   e Zd ZdZdZefZeZ fddZ	  Z
S )ClientDetailsAdmin)	r"   r,   r-   r.   r/   r0   r2   r3   r4   )r"   r,   r-   r.   r/   r0   c                s    t t| |j|jjd}|S )N)Zcompany__id)r#   rS   get_querysetrO   rL   rM   )r&   rK   Z	query_set)r)   r*   r+   rT   \   s    zClientDetailsAdmin.get_queryset)r5   r6   r7   Zlist_displayZlist_filterrI   Zactionsr   rP   rT   rE   r*   r*   )r)   r+   rS   T   s
   rS   )ZsixZdjango.utils.translationr   r;   Zdjango.formsr   r   Zdjango.core.validatorsr   r   Zmysite.att.modelsr   Zmysite.adminr   r	   Zmysite.admin.sitesr
   Zmysite.admin.exceptionsr   r   r   rF   rI   rS   registerr*   r*   r*   r+   <module>   s   