
    EvgR2                         d Z ddl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 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dS )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.
    N)
exceptions)RemovedInDjango60Warning)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$d Z%ed             Z&d%d Z'd%d!Z(ed"             Z)ed#             Z*dS )&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| _        d S )NFT)	fieldmodelrelated_namerelated_query_namelimit_choices_toparent_link	on_deletesymmetricalmultiple)selfr   tor   r   r   r   r   s           d/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/db/models/fields/reverse_related.py__init__zForeignObjectRel.__init__*   sV     

("4&6&>DT&"     c                 L    t          | j                  o| j        d         dk    S )z$Should the related object be hidden?+)boolr   r   s    r   hiddenzForeignObjectRel.hiddenC   s'     D%&&G4+<R+@C+GGr   c                 4    | j                                         S N)r   r   r   s    r   namezForeignObjectRel.nameH   s    z,,...r   c                     | j         S r"   )r   r   s    r   remote_fieldzForeignObjectRel.remote_fieldL   s
    zr   c                     | j         d         j        }t          |          dk    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_fieldP   sK     +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_model]   s3    z 	 #   zr   c                     | j         j        S r"   )r   many_to_manyr   s    r   r0   zForeignObjectRel.many_to_manyf   s    z&&r   c                     | j         j        S r"   )r   one_to_manyr   s    r   many_to_onezForeignObjectRel.many_to_onej       z%%r   c                     | j         j        S r"   )r   r3   r   s    r   r2   zForeignObjectRel.one_to_manyn   r4   r   c                     | j         j        S r"   )r   
one_to_oner   s    r   r7   zForeignObjectRel.one_to_oner   s    z$$r   c                 6    | j                             |          S r"   )r   
get_lookup)r   lookup_names     r   r9   zForeignObjectRel.get_lookupv   s    z$$[111r   c                 4    | j                                         S r"   )r   get_lookupsr   s    r   r<   zForeignObjectRel.get_lookupsy   s    z%%'''r   c                 6    | j                             |          S r"   )r   get_transform)r   r#   s     r   r>   zForeignObjectRel.get_transform|   s    z''---r   c                 4    | j                                         S r"   )r   get_internal_typer   s    r   r@   z"ForeignObjectRel.get_internal_type   s    z++---r   c                     | j         j        S r"   )r   db_typer   s    r   rB   zForeignObjectRel.db_type   s    z!!r   c                 z    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__   sD     JJ$...$///
 	
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   sH     JJ#$/00NM

 
	
r   c                 Z    t          || j                  st          S | j        |j        k    S r"   )
isinstance	__class__NotImplementedrN   )r   others     r   __eq__zForeignObjectRel.__eq__   s+    %00 	"!!}..r   c                 *    t          | j                  S r"   )hashrN   r   s    r   __hash__zForeignObjectRel.__hash__   s    DM"""r   c                 d    | j                                         }|                    dd            |S )Nr'   )__dict__copypop)r   states     r   __getstate__zForeignObjectRel.__getstate__   s0    ""$$ 			,%%%r    c                     |p| j         }| j        j                            |          }|r
 |j        | }|r|ng d |D             z   S )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.
        c                 :    g | ]}|j         t          |          fS r^   )pkstr).0xs     r   
<listcomp>z0ForeignObjectRel.get_choices.<locals>.<listcomp>   s$    9U9U9UQ14Q.9U9U9Ur   )r   r.   _default_managercomplex_filterorder_by)r   include_blankblank_choicer   orderingqss         r   get_choiceszForeignObjectRel.get_choices   sf     ,Dt/D0??@PQQ 	(h'B -529U9URT9U9U9UUUr   c                 h    t          j        dt                     | j                                        S )NzWForeignObjectRel.get_joining_columns() is deprecated. Use get_joining_fields() instead.)warningswarnr   r   get_reverse_joining_columnsr   s    r   get_joining_columnsz$ForeignObjectRel.get_joining_columns   s4    ,$	
 	
 	

 z55777r   c                 4    | j                                         S r"   )r   get_reverse_joining_fieldsr   s    r   get_joining_fieldsz#ForeignObjectRel.get_joining_fields   s    z44666r   c                 8    | j                             ||          S r"   )r   get_extra_restriction)r   aliasrelated_aliass      r   rw   z&ForeignObjectRel.get_extra_restriction   s    z//uEEEr   c                     d| _         dS )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                 *    |                                  S r"   )get_accessor_namer   s    r   accessor_namezForeignObjectRel.accessor_name   s    %%'''r   c                     |r|j         n| j        j         }|p| j        }| j        r| j        r|| j        k    rd S | j        r| j        S |j        | j        rdndz   S )N_set )rI   r.   r   r   r   r   rK   )r   r   optss      r   r~   z"ForeignObjectRel.get_accessor_name   s{     $Au{{);)A++= 	  ETZ$7$7t 	%$$DM"A&&rBBr   c                 R    |r| 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,     	1:334EFFF:00r   c                 *    |                                  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.
        )r   r   s    r   
cache_namezForeignObjectRel.cache_name   s     !!r   NNNFNr"   )+rH   
__module____qualname____doc__auto_createdconcreteeditableis_relationnullempty_strings_allowedr   r   r    r#   propertyr%   r+   r.   r0   r3   r2   r7   r9   r<   r>   r@   rB   rL   rN   rT   rW   r]   r   rm   rr   ru   rw   r|   r   r~   r   r'   r   r^   r   r   r   r      s         LHHK D!    2 H H _H / / _/   X 
  
  X
      _  ' ' _' & & _& & & _& % % _%2 2 2( ( (. . .. . . " " X"
 
 
 
 
 X
/ / /
# # #
 
 
 &V V V V(8 8 87 7 7F F F   ( ( _(C C C C$1 1 1 1 $ $ _$ " " _" " "r   r   c                   ^     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.
    NFc	           	      f    t                                          |||||||           || _        d S )Nr   r   r   r   r   )superr   r{   
r   r   r   r{   r   r   r   r   r   rQ   s
            r   r   zManyToOneRel.__init__  sH     	%1-# 	 	
 	
 	
 %r   c                 t    t                                                      }|                    dd            |S )Nr.   )r   r]   r[   )r   r\   rQ   s     r   r]   zManyToOneRel.__getstate__*  s1    $$&&		/4(((r   c                 <    t                      j        | j        fz   S r"   )r   rN   r{   r   rQ   s    r   rN   zManyToOneRel.identity/  s    ww4?"444r   c                     | 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   rI   	get_fieldr{   r   r   FieldDoesNotExist)r   r   s     r   get_related_fieldzManyToOneRel.get_related_field3  sN     
 **4?;;~ 	.-?   r   c                 J    | j         p| j        j        j        j        | _         d S r"   )r{   r   rI   ra   r#   r   s    r   r|   zManyToOneRel.set_field_name>  s    /ETZ-=-@-Er   r   )rH   r   r   r   r   r]   r   rN   r   r|   __classcell__rQ   s   @r   r   r     s         & % % % % % %.    
 5 5 5 5 X5	 	 	F F F F F F 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.
    NFc	           
      h    t                                          ||||||||           d| _        d S )Nr   F)r   r   r   r   s
            r   r   zOneToOneRel.__init__J  sK     	%1-# 	 		
 		
 		
 r   r   )rH   r   r   r   r   r   r   s   @r   r   r   B  sX                   r   r   c                   R     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.
    NTc
                     t                                          |||||           |r|	st          d          || _        |r|st          d          || _        || _        |	| _        d S )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   rQ   s             r   r   zManyToManyRel.__init__k  s     	%1- 	 	
 	
 	
  	U= 	USTTT 	V' 	VTUUU,&*r   c                 n    t                      j        | j        t          | j                  | j        fz   S r"   )r   rN   r   r   r   r   r   s    r   rN   zManyToManyRel.identity  s5    wwL$-..#
 
 	
r   c                     | j         j        }| j        r!|                    | j        d                   }n/|j        D ]'}t          |dd          }|r|j        | j        k    r 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   rI   r   r   fieldsgetattrr   foreign_related_fields)r   r   r   rels       r   r   zManyToManyRel.get_related_field  s    
 |! 	NN4#6q#9::EE  e^T:: 39
22E+A..r   )NNNTNNT)	rH   r   r   r   r   r   rN   r   r   r   s   @r   r   r   c  s          + + + + + +> 
 
 
 
 X
/ / / / / / /r   r   )r   ro   django.corer   django.utils.deprecationr   django.utils.functionalr   django.utils.hashabler   r   r   mixinsr	   r   r   r   r   r^   r   r   <module>r      sM  	 	  " " " " " " = = = = = = 3 3 3 3 3 3 / / / / / /       # # # # # #j" j" j" j" j" j" j" j"Z;F ;F ;F ;F ;F# ;F ;F ;F|    ,   B</ </ </ </ </$ </ </ </ </ </r   