
    si                     F   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
mZmZmZ ddlmZmZ ddlmZ dd	lmZ  G d
 dej*                        Z G d dej*                        Z G d de
      Z ee      d        Z ee      d        Z G d de      Z G d de      Zy)z
models.py
    )Iterable)models)receiver)reverse_lazy)HistoricalRecords_default_get_user_history_user_getter_history_user_setter)post_create_historical_recordpre_create_historical_record)HorillaModel)remove_duplicate_historyc                       e Zd ZdZ ej
                  d      Z ej                  d      Zde	fdZ
 G d d	      Zd
 Zd Zd Zd Zy)AuditTagz
    HistoryTag model
       )
max_lengthFdefaultreturnc                 ,    t        | j                        S )N)strtitleselfs    8/var/www/python-projects/worksol/horilla_audit/models.py__str__zAuditTag.__str__$   s    4::    c                       e Zd ZdZdZy)AuditTag.Meta/
        Meta class for aditional info
        horilla_auditN)__name__
__module____qualname____doc__	app_label r   r   Metar   '   s    	 $	r   r(   c                 "    | j                   rdS dS )zC
        return yes or no based on highlight true or false
        YesNo)	highlightr   s    r   custom_highlight_colzAuditTag.custom_highlight_col.   s     u0D0r   c                 8    t        dd| j                  i      }|S )z/
        This method to get update url
        zsettings-audit-tag-updatepkkwargsr   r/   r   urls     r   get_update_urlzAuditTag.get_update_url4   s     6dggO
r   c                 8    t        dd| j                  i      }|S )z/
        This method to get delete url
        zaudit-tag-deleteobj_idr0   r2   r3   s     r   get_delete_urlzAuditTag.get_delete_url;   s     -x6IJ
r   c                     | j                   S )z,
        to get instance for delete
        r/   r   s    r   get_delete_instancezAuditTag.get_delete_instanceB   s    
 wwr   N)r"   r#   r$   r%   r   	CharFieldr   BooleanFieldr,   r   r   r(   r-   r5   r8   r;   r'   r   r   r   r      sW     F+E###E2I $ $1r   r   c                       e Zd ZdZ ej
                  ddd      Z ej                  d      Z ej                  dd      Z
 ej                  e      Z G d d	      Zy
)HorillaAuditInfoz9
    HorillaAuditInfo model to store additional info
    r   T)r   nullblank)r@   F)r   r@   c                       e Zd ZdZdZdZy)HorillaAuditInfo.Metar    r!   TN)r"   r#   r$   r%   r&   abstractr'   r   r   r(   rC   T   s    	 $	r   r(   N)r"   r#   r$   r%   r   r<   history_title	TextFieldhistory_descriptionr=   history_highlightManyToManyFieldr   history_tagsr(   r'   r   r   r?   r?   J   sc     %F$$TJM*&**5+++EE)6))(3L r   r?   c                       e Zd ZdZy)HorillaAuditLogzG
    Model to store additional information for historical records.
    N)r"   r#   r$   r%   r'   r   r   rL   rL   ]   s     	r   rL   c                    	 |d   }t         j                  j                  j                  j	                  d      |_        t         j                  j                  j                  j	                  d      |_        t         j                  j                  j                  j	                  d      dk(  rdnd|_        d|_        y#  Y yxY w)	z,
    Pre create horill audit log method
    history_instancerE   rG   rH   onTFN)	r   threadrequestPOSTgetrE   rG   rH   skip_history)senderinstanceargsr1   rN   s        r   pre_create_horilla_audit_logrX   k   s    
!"45):)A)A)I)I)N)N)R)R*
& $$,,11556KL 	,
 !''//44889LMQUU  	*
 !%s   B;B> >Cc                    	 |d   }|j                   j                  t        j                  j                  j
                  j                  d             t        |t              rXd|_	        t        |       |j                  r4|j                  j                  |j                        j                          d|d<   yy#  Y yxY w)z-
    Post create horill audit log method
    rN   rJ   z
Demo Titler:   N)rJ   setr   rP   rQ   rR   getlist
isinstancerL   rE   r   rT   history_setfilterr/   delete)rU   rV   _argsr1   rN   s        r   post_create_horilla_audit_logra      s    
!"45%%))$$,,1199.I	
 &8-9*$X.$$$$++/?/B/B+CJJL)-F%& 9s   B8B< <C c                   \    e Zd Z ej                  ddd      Z ej                  d      Zy)HistoryTrackingFieldsTF)r@   rA   editabler   N)r"   r#   r$   r   	JSONFieldtracking_fieldsr=   work_info_trackr'   r   r   rc   rc      s*    &f&&DuMO)f))$7Or   rc   c                   X    e Zd Z ej                  ddd      Z ej                         Zy)AccountBlockUnblockFT)r   r@   rA   N)r"   r#   r$   r   r=   
is_enabledManagerobjectsr'   r   r   ri   ri      s&    $$$UTJJfnnGr   ri   N)r%   collections.abcr   	django.dbr   django.dispatchr   django.urlsr   simple_history.modelsr   r   r	   r
   simple_history.signalsr   r   horilla.modelsr   horilla_audit.methodsr   Modelr   r?   rL   rX   ra   rc   ri   r'   r   r   <module>rv      s    %  $ $  ( :
+v|| +\v|| &		' 		 

&' (, 

'( )&8L 8
, r   