Ë
    ¦#ijõ0  ã                   óœ   — 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
  G d„ d	e
«      Z G d
„ de«      Z G d„ de«      Z G d„ de«      Zy)al  
"Rel objects" for related fields.

"Rel objects" (for lack of a better name) carry information about the relation
modeled by a related field and provide some utility functions. They're stored
in the ``remote_field`` attribute of the field.

They also act as reverse fields for the purposes of the Meta API because
they're the closest concept currently available.
é    )Ú
exceptions)Úcached_property)Úmake_hashableé   )ÚBLANK_CHOICE_DASH)ÚFieldCacheMixinc                   ó|  — e Zd ZdZdZdZdZdZdZdZ		 	 	 	 	 d#d„Z
ed„ «       Zed„ «       Zed„ «       Zed	„ «       Zed
„ «       Zed„ «       Zed„ «       Zed„ «       Zed„ «       Zd„ Zd„ Zd„ Zd„ Zed„ «       Zd„ Zed„ «       Zd„ Zd„ Zd„ Zde ddfd„Z!d„ Z"d„ Z#d„ Z$ed„ «       Z%d$d„Z&d$d „Z'ed!„ «       Z(ed"„ «       Z)y)%ÚForeignObjectRelzº
    Used by ForeignObject to store information about the relation.

    ``_meta.get_fields()`` returns this class to provide access to the field
    flags for the reverse relation.
    TFNc                 óŠ   — || _         || _        || _        || _        |€i n|| _        || _        || _        d| _        d| _        y )NFT)	ÚfieldÚmodelÚrelated_nameÚrelated_query_nameÚlimit_choices_toÚparent_linkÚ	on_deleteÚsymmetricalÚmultiple)Úselfr   Útor   r   r   r   r   s           úa/var/www/html/office/venv/lib/python3.12/site-packages/django/db/models/fields/reverse_related.pyÚ__init__zForeignObjectRel.__init__'   sP   € ð ˆŒ
ØˆŒ
Ø(ˆÔØ"4ˆÔØ&6Ð&>¡ÐDTˆÔØ&ˆÔØ"ˆŒà ˆÔØˆ�ó    c                 óT   — t        | j                  «      xr | j                  d   dk(  S )z$Should the related object be hidden?éÿÿÿÿú+)Úboolr   ©r   s    r   ÚhiddenzForeignObjectRel.hidden@   s*   € ô �D×%Ñ%Ó&ÒG¨4×+<Ñ+<¸RÑ+@ÀCÑ+GÐGr   c                 ó6   — | j                   j                  «       S ©N)r   r   r   s    r   ÚnamezForeignObjectRel.nameE   s   € à�z‰z×,Ñ,Ó.Ð.r   c                 ó   — | j                   S r!   )r   r   s    r   Úremote_fieldzForeignObjectRel.remote_fieldI   s   € à�z‰zÐr   c                 ó„   — | j                   d   j                  }t        |«      dkD  rt        j                  d«      ‚|d   S )z�
        When filtering against this relation, return the field on the remote
        model against which the filtering should happen.
        r   r   z1Can't use target_field for multicolumn relations.r   )Ú
path_infosÚtarget_fieldsÚlenr   Ú
FieldError)r   r'   s     r   Útarget_fieldzForeignObjectRel.target_fieldM   sH   € ð Ÿ™¨Ñ+×9Ñ9ˆÜˆ}Ó Ò!Ü×'Ñ'ØCóð ð ˜QÑÐr   c                 óp   — | j                   j                  st        d«      ‚| j                   j                  S )NzVThis property can't be accessed before self.field.contribute_to_class has been called.)r   r   ÚAttributeErrorr   s    r   Úrelated_modelzForeignObjectRel.related_modelZ   s3   € à�z‰z×ÒÜ ð#óð ð �z‰z×ÑÐr   c                 ó.   — | j                   j                  S r!   )r   Úmany_to_manyr   s    r   r/   zForeignObjectRel.many_to_manyc   s   € à�z‰z×&Ñ&Ð&r   c                 ó.   — | j                   j                  S r!   )r   Úone_to_manyr   s    r   Úmany_to_onezForeignObjectRel.many_to_oneg   ó   € à�z‰z×%Ñ%Ð%r   c                 ó.   — | j                   j                  S r!   )r   r2   r   s    r   r1   zForeignObjectRel.one_to_manyk   r3   r   c                 ó.   — | j                   j                  S r!   )r   Ú
one_to_oner   s    r   r6   zForeignObjectRel.one_to_oneo   s   € à�z‰z×$Ñ$Ð$r   c                 ó8   — | j                   j                  |«      S r!   )r   Ú
get_lookup)r   Úlookup_names     r   r8   zForeignObjectRel.get_lookups   s   € Ø�z‰z×$Ñ$ [Ó1Ð1r   c                 ó6   — | j                   j                  «       S r!   )r   Úget_lookupsr   s    r   r;   zForeignObjectRel.get_lookupsv   s   € Ø�z‰z×%Ñ%Ó'Ð'r   c                 ó8   — | j                   j                  |«      S r!   )r   Úget_transform)r   r"   s     r   r=   zForeignObjectRel.get_transformy   s   € Ø�z‰z×'Ñ'¨Ó-Ð-r   c                 ó6   — | j                   j                  «       S r!   )r   Úget_internal_typer   s    r   r?   z"ForeignObjectRel.get_internal_type|   s   € Ø�z‰z×+Ñ+Ó-Ð-r   c                 ó.   — | j                   j                  S r!   )r   Údb_typer   s    r   rA   zForeignObjectRel.db_type   s   € à�z‰z×!Ñ!Ð!r   c                 ó¸   — dt        | «      j                  ›d| j                  j                  j                  ›d| j                  j                  j
                  ›d�S )Nú<z: ú.ú>)ÚtypeÚ__name__r-   Ú_metaÚ	app_labelÚ
model_namer   s    r   Ú__repr__zForeignObjectRel.__repr__ƒ   sC   � ä�‹J×ÓØ×Ñ×$Ñ$×.Ó.Ø×Ñ×$Ñ$×/Ó/ð
ð 	
r   c           	      óÞ   — | j                   | j                  | j                  | j                  t	        | j
                  «      | j                  | j                  | j                  | j                  f	S r!   )
r   r   r   r   r   r   r   r   r   r   r   s    r   ÚidentityzForeignObjectRel.identityŠ   s\   € ð �J‰JØ�J‰JØ×ÑØ×#Ñ#Ü˜$×/Ñ/Ó0Ø×ÑØ�N‰NØ×ÑØ�M‰Mð

ð 
	
r   c                 ól   — t        || j                  «      st        S | j                  |j                  k(  S r!   )Ú
isinstanceÚ	__class__ÚNotImplementedrM   )r   Úothers     r   Ú__eq__zForeignObjectRel.__eq__˜   s)   € Ü˜% §¡Ô0Ü!Ð!Ø�}‰} §¡Ñ.Ð.r   c                 ó,   — t        | j                  «      S r!   )ÚhashrM   r   s    r   Ú__hash__zForeignObjectRel.__hash__�   s   € Ü�D—M‘MÓ"Ð"r   c                 ó^   — | j                   j                  «       }|j                  dd «       |S )Nr&   )Ú__dict__ÚcopyÚpop)r   Ústates     r   Ú__getstate__zForeignObjectRel.__getstate__    s)   € Ø—‘×"Ñ"Ó$ˆð 	�	‰	�, Ô%Øˆr   © c                 óð   — |xs | j                   }| j                  j                  j                  |«      }|r |j                  |Ž }|r|ng |D �cg c]  }|j
                  t        |«      f‘Œ c}z   S c c}w )a  
        Return choices with a default blank choices included, for use
        as <select> choices for this field.

        Analog of django.db.models.fields.Field.get_choices(), provided
        initially for utilization by RelatedFieldListFilter.
        )r   r-   Ú_default_managerÚcomplex_filterÚorder_byÚpkÚstr)r   Úinclude_blankÚblank_choicer   ÚorderingÚqsÚxs          r   Úget_choiceszForeignObjectRel.get_choices¬   so   € ð ,ÒD¨t×/DÑ/DÐØ×Ñ×0Ñ0×?Ñ?Ð@PÓQˆÙØ�—‘˜hÐ'ˆBÙ -‘°2ÐRTÖ9UÈQ¸1¿4¹4ÄÀQÃº.Ò9UÑUÐUùÒ9Us   ÁA3c                 ó6   — | j                   j                  «       S r!   )r   Úget_reverse_joining_fieldsr   s    r   Úget_joining_fieldsz#ForeignObjectRel.get_joining_fieldsÀ   s   € Ø�z‰z×4Ñ4Ó6Ð6r   c                 ó:   — | j                   j                  ||«      S r!   )r   Úget_extra_restriction)r   ÚaliasÚrelated_aliass      r   rn   z&ForeignObjectRel.get_extra_restrictionÃ   s   € Ø�z‰z×/Ñ/°¸uÓEÐEr   c                 ó   — d| _         y)z³
        Set the related field's name, this is not available until later stages
        of app loading, so set_field_name is called from
        set_attributes_from_rel()
        N)Ú
field_namer   s    r   Úset_field_namezForeignObjectRel.set_field_nameÆ   s   € ð ˆ�r   c                 ó"   — | j                  «       S r!   )Úget_accessor_namer   s    r   Úaccessor_namezForeignObjectRel.accessor_nameÐ   s   € à×%Ñ%Ó'Ð'r   c                 ó(  — |r|j                   n| j                  j                   }|xs | j                  }| j                  r| j                  r|| j                  k(  ry | j
                  r| j
                  S |j                  | j                  rdz   S dz   S )NÚ_setÚ )rH   r-   r   r   r   r   rJ   )r   r   Úoptss      r   ru   z"ForeignObjectRel.get_accessor_nameÔ   s   € ñ $ˆu�{Š{¨×);Ñ);×)AÑ)AˆØÒ+˜×+Ñ+ˆØ�=Š=ð ×Ò E¨T¯Z©ZÒ$7ØØ×ÒØ×$Ñ$Ð$Ø�‰¨D¯MªM &ÑBÐB¸rÑBÐBr   c                 óh   — |r| j                   j                  |«      S | j                   j                  S r!   )r   Úget_reverse_path_infoÚreverse_path_infos)r   Úfiltered_relations     r   Úget_path_infozForeignObjectRel.get_path_infoæ   s+   € ÙØ—:‘:×3Ñ3Ð4EÓFÐFà—:‘:×0Ñ0Ð0r   c                 ó"   — | j                  «       S r!   )r   r   s    r   r&   zForeignObjectRel.path_infosì   s   € à×!Ñ!Ó#Ð#r   c                 ó   — | j                   S )z„
        Return the name of the cache key to use for storing an instance of the
        forward model on the reverse model.
        )rv   r   s    r   Ú
cache_namezForeignObjectRel.cache_nameð   s   € ð ×!Ñ!Ð!r   ©NNNFNr!   )*rG   Ú
__module__Ú__qualname__Ú__doc__Úauto_createdÚconcreteÚeditableÚis_relationÚnullÚempty_strings_allowedr   r   r   r"   Úpropertyr$   r*   r-   r/   r2   r1   r6   r8   r;   r=   r?   rA   rK   rM   rS   rV   r\   r   ri   rl   rn   rs   rv   ru   r   r&   r‚   r]   r   r   r
   r
      s±  „ ñð €LØ€HØ€HØ€Kð €DØ!Ðð ØØØØóð2 ñHó ðHð ñ/ó ð/ð ñó ðð ñ
 ó ð
 ð ñ ó ð ð ñ'ó ð'ð ñ&ó ð&ð ñ&ó ð&ð ñ%ó ð%ò2ò(ò.ò.ð ñ"ó ð"ò
ð ñ
ó ð
ò/ò
#ò
ð Ø&ØØóVò(7òFòð ñ(ó ð(óCó$1ð ñ$ó ð$ð ñ"ó ñ"r   r
   c                   óX   ‡ — e Zd ZdZ	 	 	 	 	 dˆ fd„	Zˆ fd„Zeˆ fd„«       Zd„ Zd„ Z	ˆ xZ
S )ÚManyToOneRela+  
    Used by the ForeignKey field to store information about the relation.

    ``_meta.get_fields()`` returns this class to provide access to the field
    flags for the reverse relation.

    Note: Because we somewhat abuse the Rel objects by using them as reverse
    fields we get the funny situation where
    ``ManyToOneRel.many_to_one == False`` and
    ``ManyToOneRel.one_to_many == True``. This is unfortunate but the actual
    ManyToOneRel class is a private API and there is work underway to turn
    reverse relations into actual fields.
    c	           	      ó@   •— t         ‰	| �  |||||||¬«       || _        y )N©r   r   r   r   r   )Úsuperr   rr   ©
r   r   r   rr   r   r   r   r   r   rP   s
            €r   r   zManyToOneRel.__init__  s5   ø€ ô 	‰ÑØØØ%Ø1Ø-Ø#Øð 	ô 	
ð %ˆ�r   c                 óH   •— t         ‰| �  «       }|j                  dd «       |S )Nr-   )r’   r\   rZ   )r   r[   rP   s     €r   r\   zManyToOneRel.__getstate__  s#   ø€ Ü‘Ñ$Ó&ˆØ�	‰	�/ 4Ô(Øˆr   c                 ó6   •— g t         ‰| �  ¢| j                  ‘­S r!   )r’   rM   rr   ©r   rP   s    €r   rM   zManyToOneRel.identity$  s   ø€ à3”‘Ñ!Ð3 4§?¡?Ñ3Ð3r   c                 óÀ   — | j                   j                  j                  | j                  «      }|j                  s"t        j                  d| j                  z  «      ‚|S )zY
        Return the Field in the 'to' object to which this relationship is tied.
        zNo related field named '%s')r   rH   Ú	get_fieldrr   rˆ   r   ÚFieldDoesNotExist)r   r   s     r   Úget_related_fieldzManyToOneRel.get_related_field(  sO   € ð —
‘
× Ñ ×*Ñ*¨4¯?©?Ó;ˆØ�~Š~Ü×.Ñ.Ø-°·±Ñ?óð ð ˆr   c                 ó~   — | j                   xs* | j                  j                  j                  j                  | _         y r!   )rr   r   rH   rb   r"   r   s    r   rs   zManyToOneRel.set_field_name3  s(   € ØŸ/™/ÒE¨T¯Z©Z×-=Ñ-=×-@Ñ-@×-EÑ-Eˆ�r   rƒ   )rG   r„   r…   r†   r   r\   r�   rM   rš   rs   Ú__classcell__©rP   s   @r   r�   r�   ù   sB   ø„ ñð& ØØØØõ%ô.ð
 ó4ó ð4ò	öFr   r�   c                   ó.   ‡ — e Zd ZdZ	 	 	 	 	 dˆ fd„	Zˆ xZS )ÚOneToOneRelzº
    Used by OneToOneField to store information about the relation.

    ``_meta.get_fields()`` returns this class to provide access to the field
    flags for the reverse relation.
    c	           
      óB   •— t         ‰	| �  ||||||||¬«       d| _        y )Nr‘   F)r’   r   r   r“   s
            €r   r   zOneToOneRel.__init__?  s8   ø€ ô 	‰ÑØØØØ%Ø1Ø-Ø#Øð 	ô 		
ð ˆ�r   rƒ   )rG   r„   r…   r†   r   rœ   r�   s   @r   rŸ   rŸ   7  s#   ø„ ñð ØØØØ÷ñ r   rŸ   c                   óL   ‡ — e Zd ZdZ	 	 	 	 	 	 	 dˆ fd„	Zeˆ fd„«       Zd„ Zˆ xZS )ÚManyToManyRelz¼
    Used by ManyToManyField to store information about the relation.

    ``_meta.get_fields()`` returns this class to provide access to the field
    flags for the reverse relation.
    c
                 ó¢   •— t         ‰
| �  |||||¬«       |r|	st        d«      ‚|| _        |r|st        d«      ‚|| _        || _        |	| _        y )N)r   r   r   z4Can't supply a through model and db_constraint=Falsez5Cannot specify through_fields without a through model)r’   r   Ú
ValueErrorÚthroughÚthrough_fieldsr   Údb_constraint)r   r   r   r   r   r   r   r¥   r¦   r§   rP   s             €r   r   zManyToManyRel.__init__`  si   ø€ ô 	‰ÑØØØ%Ø1Ø-ð 	ô 	
ñ ™=ÜÐSÓTÐTØˆŒá¡'ÜÐTÓUÐUØ,ˆÔà&ˆÔØ*ˆÕr   c                 óx   •— g t         ‰| �  ¢| j                  ‘t        | j                  «      ‘| j
                  ‘­S r!   )r’   rM   r¥   r   r¦   r§   r–   s    €r   rM   zManyToManyRel.identity  sK   ø€ ð
Ü‰WÑð
à�L‰Lð
ô ˜$×-Ñ-Ó.ð
ð ×Ññ	
ð 	
r   c                 ó  — | j                   j                  }| j                  r|j                  | j                  d   «      }n<|j                  D ]-  }t        |dd«      }|sŒ|j                  | j                  k(  sŒ- n j                  d   S )zŠ
        Return the field in the 'to' object to which this relationship is tied.
        Provided for symmetry with ManyToOneRel.
        r   r$   N)r¥   rH   r¦   r˜   ÚfieldsÚgetattrr   Úforeign_related_fields)r   rz   r   Úrels       r   rš   zManyToManyRel.get_related_fieldˆ  s~   € ð
 �|‰|×!Ñ!ˆØ×ÒØ—N‘N 4×#6Ñ#6°qÑ#9Ó:‰EàŸ™ò �Ü˜e ^°TÓ:�Ú˜3Ÿ9™9¨¯
©
Ó2Ùðð ×+Ñ+¨AÑ.Ð.r   )NNNTNNT)	rG   r„   r…   r†   r   r�   rM   rš   rœ   r�   s   @r   r¢   r¢   X  s=   ø„ ñð ØØØØØØõ+ð> ó
ó ð
ö/r   r¢   N)r†   Údjango.corer   Údjango.utils.functionalr   Údjango.utils.hashabler   ry   r   Úmixinsr   r
   r�   rŸ   r¢   r]   r   r   ú<module>r²      sT   ðñ	õ #Ý 3Ý /å Ý #ôb"�ô b"ôJ;FÐ#ô ;Fô|�,ô ôB=/Ð$õ =/r   