
    _}dg                         d Z ddlmZ  edg d          Z edg d          Zd Zd Zd	 Zd
 Zd Z	d Z
d Zd Zd ZdS )z
Helper function for returning the field information that is associated
with a model class. This includes returning all the forward and reverse
relationships and their associated metadata.

Usage: `get_field_info(model)` returns a `FieldInfo` instance.
    )
namedtuple	FieldInfo)pkfieldsforward_relationsreverse_relationsfields_and_pk	relationsRelationInfomodel_fieldrelated_modelto_manyto_fieldhas_through_modelreversec                    | j         j        j         }t          |          }t          |          }t	          |          }t          |          }t          ||          }t          ||          }t          ||||||          S )z
    Given a model class, returns a `FieldInfo` instance, which is a
    `namedtuple`, containing metadata about the various field types on the model
    including information about their relationships.
    )	_metaconcrete_model_get_pk_get_fields_get_forward_relationships_get_reverse_relationships_merge_fields_and_pk_merge_relationshipsr   )modeloptsr   r   r   r   r	   relationshipss           ^/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/rest_framework/utils/model_meta.pyget_field_infor       s     ;%+D	BF24882488(V44M():<MNNMR!24E"M3 3 3    c                     | j         }|j        }|r-|j        r&|j        j        j        j         }|j        }|r|j        &|S N)r   remote_fieldparent_linkr   r   )r   r   rels      r   r   r   0   sR    	B
/C
 #/ _"(+o  #/ 
 Ir!   c                 F    i }d | j         D             D ]}|||j        <   |S )Nc                 .    g | ]}|j         	|j        |S  	serializer$   .0fields     r   
<listcomp>z_get_fields.<locals>.<listcomp>>   s'    ___EEO_EL^_%___r!   )r   name)r   r   r.   s      r   r   r   <   s:    F__T[___ # #"uzMr!   c                 >    t          | dd           o| j        d         S )N	to_fieldsr   )getattrr2   )r.   s    r   _get_to_fieldr4   D   s     5+t,,C1CCr!   c           	      :   i }d | j         D             D ]6}t          ||j        j        dt	          |          dd          ||j        <   7d | j        D             D ]>}t          ||j        j        dd|j        j        j        j	         d          ||j        <   ?|S ):
    Returns a dict of field names to `RelationInfo`.
    c                 .    g | ]}|j         	|j        |S r)   r*   r,   s     r   r/   z._get_forward_relationships.<locals>.<listcomp>M   s'    [[[EEO[HZ[%[[[r!   Fr   c                      g | ]}|j         	|S r)   )r+   r,   s     r   r/   z._get_forward_relationships.<locals>.<listcomp>X   s    JJJE%/J%JJJr!   TN)
r   r   r$   r   r4   r0   many_to_manythroughr   auto_created)r   r   r.   s      r   r   r   H   s     [[T[[[[ 
 
(4,2"5))#)
 )
 )
%*%% KJT%6JJJ 
 
(4,2&.4AA
)
 
)
 
)
%*%% r!   c                    i }d | j         D             }|D ]T}|                                }t          d|j        |j        j        j        t          |j                  dd          ||<   Ud | j         D             }|D ]j}|                                }t          d|j        ddt          |j        j        dd          duo|j        j        j	        j
        j         d          ||<   k|S )r6   c                 *    g | ]}|j         j        |S r)   r.   r9   r-   rs     r   r/   z._get_reverse_relationships.<locals>.<listcomp>m   s"    WWW!'BVW1WWWr!   NFTr   c                 *    g | ]}|j         j        |S r)   r>   r?   s     r   r/   z._get_reverse_relationships.<locals>.<listcomp>z   s"    '`'`'`a17K_'`'`'`'`r!   r:   )related_objectsget_accessor_namer   r   r.   r$   multipler4   r3   r:   r   r;   )r   r   all_related_objectsrelationaccessor_name all_related_many_to_many_objectss         r   r   r   h   s)    WWd&:WWW' 	
 	
 2244+7"0N/8"8>22#,
 ,
 ,
-(( (a'`43G'`'`'`$4 
 
 2244+7"04iFFdR KN/7=JJ,
 ,
 ,
-(( r!   c                 F    d| | j         | i}|                    |           |S )Nr   )r0   update)r   r   r	   s      r   r   r      s,    2rw+M   r!   c                     i | |S r#   r)   )r   r   s     r   r   r      s    55#455r!   c                 d    t          | d          o t          | j        d          o| j        j        S )z_
    Given a model class, returns a boolean True if it is abstract and False if it is not.
    r   abstract)hasattrr   rM   )r   s    r   is_abstract_modelrO      s/     5'""`wu{J'G'G`EKL``r!   N)__doc__collectionsr   r   r   r    r   r   r4   r   r   r   r   rO   r)   r!   r   <module>rR      s    # " " " " "J{ % % %  	 z. + + +  3 3 3&	 	 	  D D D  @" " "J  6 6 6a a a a ar!   