Ë
    q^ëiÀ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                   óh  — 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$d„ Z%d$d„Z&d$d „Z'ed!„ «       Z(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           úX/var/www/eb/venv/lib/python3.12/site-packages/django/db/models/fields/reverse_related.pyÚ__init__zForeignObjectRel.__init__'   sP   € ð ˆŒ
ØˆŒ
Ø(ˆÔØ"4ˆÔØ&6Ð&>¡ÐDTˆÔØ&ˆÔØ"ˆŒà ˆÔØˆ�ó    c                 ó"   — | j                  «       S ©N)Ú	is_hidden©r   s    r   ÚhiddenzForeignObjectRel.hidden@   s   € à�~‰~ÓÐr   c                 ó6   — | j                   j                  «       S r   )r   r   r   s    r   ÚnamezForeignObjectRel.nameD   s   € à�z‰z×,Ñ,Ó.Ð.r   c                 ó   — | j                   S r   )r   r   s    r   Úremote_fieldzForeignObjectRel.remote_fieldH   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   z1Can't use target_field for multicolumn relations.r   )Ú
path_infosÚtarget_fieldsÚlenr   Ú
FieldError)r   r&   s     r   Útarget_fieldzForeignObjectRel.target_fieldL   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_modelY   s3   € à�z‰z×ÒÜ ð#óð ð �z‰z×ÑÐr   c                 ó.   — | j                   j                  S r   )r   Úmany_to_manyr   s    r   r.   zForeignObjectRel.many_to_manyb   s   € à�z‰z×&Ñ&Ð&r   c                 ó.   — | j                   j                  S r   )r   Úone_to_manyr   s    r   Úmany_to_onezForeignObjectRel.many_to_onef   ó   € à�z‰z×%Ñ%Ð%r   c                 ó.   — | j                   j                  S r   )r   r1   r   s    r   r0   zForeignObjectRel.one_to_manyj   r2   r   c                 ó.   — | j                   j                  S r   )r   Ú
one_to_oner   s    r   r5   zForeignObjectRel.one_to_onen   s   € à�z‰z×$Ñ$Ð$r   c                 ó8   — | j                   j                  |«      S r   )r   Ú
get_lookup)r   Úlookup_names     r   r7   zForeignObjectRel.get_lookupr   s   € Ø�z‰z×$Ñ$ [Ó1Ð1r   c                 ó6   — | j                   j                  «       S r   )r   Úget_lookupsr   s    r   r:   zForeignObjectRel.get_lookupsu   s   € Ø�z‰z×%Ñ%Ó'Ð'r   c                 ó8   — | j                   j                  |«      S r   )r   Úget_transform)r   r    s     r   r<   zForeignObjectRel.get_transformx   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   r@   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__ÚNotImplementedrL   )r   Úothers     r   Ú__eq__zForeignObjectRel.__eq__—   s)   € Ü˜% §¡Ô0Ü!Ð!Ø�}‰} §¡Ñ.Ð.r   c                 ó,   — t        | j                  «      S r   )ÚhashrL   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                 óT   — t        | j                  «      xr | j                  d   dk(  S )z$Should the related object be hidden?r$   ú+)Úboolr   r   s    r   r   zForeignObjectRel.is_hidden¿   s(   € ä�D×%Ñ%Ó&ÒG¨4×+<Ñ+<¸RÑ+@ÀCÑ+GÐGr   c                 ó6   — | j                   j                  «       S r   )r   Úget_reverse_joining_columnsr   s    r   Úget_joining_columnsz$ForeignObjectRel.get_joining_columnsÃ   s   € Ø�z‰z×5Ñ5Ó7Ð7r   c                 ó:   — | j                   j                  ||«      S r   )r   Úget_extra_restriction)r   ÚaliasÚrelated_aliass      r   rp   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                 ó(  — |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Ú )rG   r,   r   r   r   r   rI   )r   r   Úoptss      r   Úget_accessor_namez"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.
        )rz   r   s    r   Úget_cache_namezForeignObjectRel.get_cache_nameï   s   € ð
 ×%Ñ%Ó'Ð'r   ©NNNFNr   )*rF   Ú
__module__Ú__qualname__Ú__doc__Úauto_createdÚconcreteÚeditableÚis_relationÚnullÚempty_strings_allowedr   r   r   r    Úpropertyr"   r)   r,   r.   r1   r0   r5   r7   r:   r<   r>   r@   rJ   rL   rR   rU   r[   r   rh   r   rn   rp   ru   rz   r   r%   r‚   r\   r   r   r
   r
      s’  „ ñð €LØ€HØ€HØ€Kð €DØ!Ðð ØØØØóð2 ñ ó ð ð ñ/ó ð/ð ñó ðð ñ
 ó ð
 ð ñ ó ð ð ñ'ó ð'ð ñ&ó ð&ð ñ&ó ð&ð ñ%ó ð%ò2ò(ò.ò.ð ñ"ó ð"ò
ð ñ
ó ð
ò/ò
#ò
ð Ø&ØØóVò(Hò8ò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   rt   ©
r   r   r   rt   r   r   r   r   r   rO   s
            €r   r   zManyToOneRel.__init__  s5   ø€ ô 	‰ÑØØØ%Ø1Ø-Ø#Øð 	ô 	
ð %ˆ�r   c                 óH   •— t         ‰| �  «       }|j                  dd «       |S )Nr,   )r’   r[   rY   )r   rZ   rO   s     €r   r[   zManyToOneRel.__getstate__  s#   ø€ Ü‘Ñ$Ó&ˆØ�	‰	�/ 4Ô(Øˆr   c                 ó4   •— t         ‰| �  | j                  fz   S r   )r’   rL   rt   ©r   rO   s    €r   rL   zManyToOneRel.identity"  s   ø€ ä‰wÑ 4§?¡?Ð"4Ñ4Ð4r   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   rG   Ú	get_fieldrt   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   )rt   r   rG   ra   r    r   s    r   ru   zManyToOneRel.set_field_name1  s(   € ØŸ/™/ÒE¨T¯Z©Z×-=Ñ-=×-@Ñ-@×-EÑ-Eˆ�r   rƒ   )rF   r„   r…   r†   r   r[   r�   rL   rš   ru   Ú__classcell__©rO   s   @r   r�   r�   ÷   sB   ø„ ñð& ØØØØõ%ô.ð
 ó5ó ð5ò	ö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ƒ   )rF   r„   r…   r†   r   rœ   r�   s   @r   rŸ   rŸ   5  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§   rO   s             €r   r   zManyToManyRel.__init__^  si   ø€ ô 	‰ÑØØØ%Ø1Ø-ð 	ô 	
ñ ™=ÜÐSÓTÐTØˆŒá¡'ÜÐTÓUÐUØ,ˆÔà&ˆÔØ*ˆÕr   c                 ór   •— t         ‰| �  | j                  t        | j                  «      | j
                  fz   S r   )r’   rL   r¥   r   r¦   r§   r–   s    €r   rL   zManyToManyRel.identity}  s8   ø€ ä‰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¥   rG   r¦   r˜   ÚfieldsÚgetattrr   Úforeign_related_fields)r   ry   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)	rF   r„   r…   r†   r   r�   rL   rš   rœ   r�   s   @r   r¢   r¢   V  s=   ø„ ñð ØØØØØØõ+ð> ó
ó ð
ö/r   r¢   N)r†   Údjango.corer   Údjango.utils.functionalr   Údjango.utils.hashabler   rx   r   Úmixinsr   r
   r�   rŸ   r¢   r\   r   r   ú<module>r²      sT   ðñ	õ #Ý 3Ý /å Ý #ô`(�ô `(ôF;FÐ#ô ;Fô|�,ô ôB</Ð$õ </r   