
    vg                     :   d 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)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y
)AuditTagz
    HistoryTag model
       )
max_lengthFdefaultreturnc                 ,    t        | j                        S )N)strtitle)selfs    (/var/www/horilla/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&   N)r    r!   r"   r#   r   	CharFieldr   BooleanField	highlightr   r   r&   r%   r   r   r   r      sC     F+E###E2I $ $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&   r/   8   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+   .   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   r8   r8   A   s     	r   r8   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_instancer1   r3   r4   onTFN)	r   threadrequestPOSTgetr1   r3   r4   skip_history)senderinstanceargskwargsr:   s        r   pre_create_horilla_audit_logrE   O   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
    r:   r6   z
Demo Title)pkN)r6   setr   r<   r=   r>   getlist
isinstancer8   r1   r   r@   history_setfilterrG   delete)rA   rB   _argsrD   r:   s        r   post_create_horilla_audit_logrO   f   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,   r-   editabler   N)r    r!   r"   r   	JSONFieldtracking_fieldsr(   work_info_trackr%   r   r   rQ   rQ   z   s*    &f&&DuMO)f))$7Or   rQ   c                   X    e Zd Z ej                  ddd      Z ej                         Zy)AccountBlockUnblockFT)r   r,   r-   N)r    r!   r"   r   r(   
is_enabledManagerobjectsr%   r   r   rW   rW      s&    $$$UTJJfnnGr   rW   N)r#   collections.abcr   	django.dbr   django.dispatchr   simple_history.modelsr   r   r   r	   simple_history.signalsr
   r   horilla.modelsr   horilla_audit.methodsr   Modelr   r+   r8   rE   rO   rQ   rW   r%   r   r   <module>rc      s    %  $  ( :
$v|| $&v|| &		' 		 

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

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