Ë
    ”2ÚiÖ  ã                   óF   — d dl mZ ddlmZ d ZdZ G d„ de«      Zd„ Zd„ Zy)	é    )Úsignalsé   )Úpost_changec                   ól   ‡ — e Zd ZdZˆ fd„Zdd„Zd„ Zd„ Zd„ Zd„ Z	d„ Z
d	„ Zd
„ Zd„ Zd„ Zd„ Zd„ Zˆ xZS )ÚChangesMixinaE	  
    ChangesMixin keeps track of changes for model instances.

    It allows you to retrieve the following states from an instance:

    1. current_state()
        The current state of the instance.
    2. previous_state()
        The state of the instance **after** it was created, saved
        or deleted the last time.
    3. old_state()
        The previous previous_state(), i.e. the state of the
        instance **before** it was created, saved or deleted the
        last time.

    It also provides convenience methods to get changes between states:

    1. changes()
        Changes from previous_state to current_state.
    2. previous_changes()
        Changes from old_state to previous_state.
    3. old_changes()
        Changes from old_state to current_state.

    And the following methods to determine if an instance was/is persisted in
    the database:

    1. was_persisted()
        Was the instance persisted in its old state.
    2. is_persisted()
        Is the instance is_persisted in its current state.

    This schematic tries to illustrate how these methods relate to
    each other::


        after create/save/delete            after save/delete                  now
        |                                   |                                  |
        .-----------------------------------.----------------------------------.
        |\                                  |\                                 |        | \                                 | \                                |         |  old_state()                      |  previous_state()                |  current_state()
        |                                   |                                  |
        |-----------------------------------|----------------------------------|
        |  previous_changes() (prev - old)  |  changes() (cur - prev)          |
        |-----------------------------------|----------------------------------|
        |                      old_changes()  (cur - old)                      |
        .----------------------------------------------------------------------.
         \                                                                                \                                                                                 was_persisted()                                                        is_persisted()

    c                 óz  •— t        t        | �
  |i |¤Ž g | _        | j	                  d¬«       t
        j                  j                  t        | j                  d| j                  j                  z  ¬«       t
        j                  j                  t        | j                  d| j                  j                  z  ¬«       y )NT)Únew_instancezdjango-changes-%s)ÚsenderÚdispatch_uid)Úsuperr   Ú__init__Ú_statesÚ_save_stater   Ú	post_saveÚconnectÚ
_post_saveÚ	__class__Ú__name__Úpost_deleteÚ_post_delete)ÚselfÚargsÚkwargsr   s      €úS/var/www/html/acx/venv/lib/python3.12/site-packages/django_model_changes/changes.pyr   zChangesMixin.__init__@   s™   ø€ ÜŒl˜DÑ*¨DÐ;°FÒ;àˆŒØ×Ñ dÐÔ+ä×Ñ×!Ñ!Ü˜tŸ~™~Ø,¨t¯~©~×/FÑ/FÑFð 	"ô 	
ô 	×Ñ×#Ñ#Ü §¡Ø,¨t¯~©~×/FÑ/FÑFð 	$õ 	
ó    c                 ó$  — |t         k(  rd | _        | j                  j                  | j	                  «       «       t        | j                  «      dkD  r| j                  j                  d«       |s"t        j                  | j                  | ¬«       y y )Né   r   )r
   Úinstance)
ÚDELETEÚpkr   ÚappendÚcurrent_stateÚlenÚpopr   Úsendr   )r   r	   Ú
event_types      r   r   zChangesMixin._save_stateO   ss   € ð œÒØˆDŒGð 	�‰×Ñ˜D×.Ñ.Ó0Ô1ô
 ˆt�|‰|Ó˜qÒ Ø�L‰L×Ñ˜QÔñ Ü×Ñ D§N¡N¸TÖBð r   c                 ót  — t        «       }| j                  j                  D �cg c]  }|j                  |j                  «      ‘Œ c} | j                  j                  D �cg c]  }|j                  |j
                  «      ‘Œ c} t        |D �cg c]  }|t        | |d«      f‘Œ c}«      S c c}w c c}w c c}w )zY
        Returns a ``field -> value`` dict of the current state of the instance.
        N)ÚsetÚ_metaÚlocal_fieldsÚaddÚnameÚattnameÚdictÚgetattr)r   Úfield_namesÚfÚ
field_names       r   r"   zChangesMixin.current_stateb   s”   € ô “eˆØ*.¯*©*×*AÑ*AÖB Qˆ�‰˜Ÿ™Õ	 ÓBà-1¯Z©Z×-DÑ-DÖE¨ˆ�‰˜Ÿ™Õ	#ÓEÜØ'2ö4Ø#ð !¤'¨$°
¸DÓ"AÒBò 4ó 5ð 	5ùò 	CùâEùò4s   £"B+Á "B0ÂB5c                 ón   — t        | j                  «      dkD  r| j                  d   S | j                  d   S )z’
        Returns a ``field -> value`` dict of the state of the instance after it
        was created, saved or deleted the previous time.
        r   r   )r#   r   ©r   s    r   Úprevious_statezChangesMixin.previous_statem   s1   € ô
 ˆt�|‰|Ó˜qÒ Ø—<‘< ‘?Ð"à—<‘< ‘?Ð"r   c                 ó    — | j                   d   S )zæ
        Returns a ``field -> value`` dict of the state of the instance after
        it was created, saved or deleted the previous previous time. Returns
        the previous state if there is no previous previous state.
        r   )r   r4   s    r   Ú	old_statezChangesMixin.old_statew   s   € ð �|‰|˜A‰Ðr   c           
      ó†   — t        |j                  «       D ��cg c]  \  }}|||   k7  sŒ||||   ff‘Œ c}}«      S c c}}w )N)r.   Úitems)r   ÚotherÚcurrentÚkeyÚwass        r   Ú_changeszChangesMixin._changes   sB   € ÜÀÇÁÃ×e±H°C¸ÐQTÐX_Ð`cÑXdÓQd�c˜C ¨¡Ð.Ò/ÓeÓfÐfùÓes   ™=
ª=
c                 ó^   — | j                  | j                  «       | j                  «       «      S )zŽ
        Returns a ``field -> (previous value, current value)`` dict of changes
        from the previous state to the current state.
        )r>   r5   r"   r4   s    r   ÚchangeszChangesMixin.changes‚   s'   € ð
 �}‰}˜T×0Ñ0Ó2°D×4FÑ4FÓ4HÓIÐIr   c                 ó^   — | j                  | j                  «       | j                  «       «      S )z‰
        Returns a ``field -> (previous value, current value)`` dict of changes
        from the old state to the current state.
        )r>   r7   r"   r4   s    r   Úold_changeszChangesMixin.old_changes‰   s%   € ð
 �}‰}˜TŸ^™^Ó-¨t×/AÑ/AÓ/CÓDÐDr   c                 ó^   — | j                  | j                  «       | j                  «       «      S )zŠ
        Returns a ``field -> (previous value, current value)`` dict of changes
        from the old state to the previous state.
        )r>   r7   r5   r4   s    r   Úprevious_changeszChangesMixin.previous_changes�   s%   € ð
 �}‰}˜TŸ^™^Ó-¨t×/BÑ/BÓ/DÓEÐEr   c                 óz   — | j                   j                  j                  }t        | j	                  «       |   «      S )ag  
        Returns true if the instance was persisted (saved) in its old
        state.

        Examples::

            >>> user = User()
            >>> user.save()
            >>> user.was_persisted()
            False

            >>> user = User.objects.get(pk=1)
            >>> user.delete()
            >>> user.was_persisted()
            True
        )r)   r    r,   Úboolr7   )r   Úpk_names     r   Úwas_persistedzChangesMixin.was_persisted—   s.   € ð" —*‘*—-‘-×$Ñ$ˆÜ�D—N‘NÓ$ WÑ-Ó.Ð.r   c                 ó,   — t        | j                  «      S )ag  
        Returns true if the instance is persisted (saved) in its current
        state.

        Examples:

            >>> user = User()
            >>> user.save()
            >>> user.is_persisted()
            True

            >>> user = User.objects.get(pk=1)
            >>> user.delete()
            >>> user.is_persisted()
            False
        )rF   r    r4   s    r   Úis_persistedzChangesMixin.is_persisted«   s   € ô" �D—G‘G‹}Ðr   c                 óB   —  | j                   di | j                  «       ¤ŽS )zE
        Returns an instance of this model in its old state.
        © )r   r7   r4   s    r   Úold_instancezChangesMixin.old_instance¾   s   € ð ˆt�~‰~Ñ1 §¡Ó 0Ñ1Ð1r   c                 óB   —  | j                   di | j                  «       ¤ŽS )zJ
        Returns an instance of this model in its previous state.
        rL   )r   r5   r4   s    r   Úprevious_instancezChangesMixin.previous_instanceÄ   s!   € ð ˆt�~‰~Ñ6 × 3Ñ 3Ó 5Ñ6Ð6r   )FÚsave)r   Ú
__module__Ú__qualname__Ú__doc__r   r   r"   r5   r7   r>   r@   rB   rD   rH   rJ   rM   rO   Ú__classcell__)r   s   @r   r   r   	   sO   ø„ ñ4ôl
óCò&	5ò#òògòJòEòFò/ò(ò&2ö7r   r   c                 ó2   — |j                  dt        ¬«       y ©NF)r	   r&   )r   ÚSAVE©r
   r   r   s      r   r   r   Ë   s   € Ø×Ñ e¼ÐÕ=r   c                 ó2   — |j                  dt        ¬«       y rV   )r   r   rX   s      r   r   r   Ï   s   € Ø×Ñ e¼ÐÕ?r   N)	Údjango.db.modelsr   r   rW   r   Úobjectr   r   r   rL   r   r   ú<module>r\      s/   ðÝ $å  à€Ø	
€ô7�6ô 7òD>ó@r   