
    R1i}                     z    d Z ddlmZ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y)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.
    )OrderedDict
namedtupleFieldResult)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_relationships	FieldInfo)modeloptsr   r   r   r	   r
   relationshipss           c/home/cursorai/projects/iching/venv/lib/python3.12/site-packages/rest_framework/utils/model_meta.pyget_field_infor"      sx     ;;%%++D	BF248248(V4M():<MNMR!24E"M3 3    c                     | j                   }|j                  }|rQ|j                  rE|j                  j                  j                  j                   }|j                  }|r|j                  rE|S N)r   remote_fieldparent_linkr   r   )r   r   rels      r!   r   r   0   sS    	B
//C
#//__""((++oo #//
 Ir#   c                     t               }| j                  D cg c]  }|j                  s|j                  r|  c}D ]  }|||j                  <    |S c c}w r%   )r   r   	serializer&   name)r   r   fields      r!   r   r   <   sP    ]F%)[[_[EEOOEL^L^%[_"uzz ` M `s   AAAc                 >    t        | dd       xr | j                  d   S )N	to_fieldsr   )getattrr.   )r,   s    r!   _get_to_fieldr0   D   s    5+t,C1CCr#   c           	      $   t               }| j                  D cg c]  }|j                  s|j                  s|  c}D ]=  }t	        ||j                  j
                  dt        |      dd      ||j                  <   ? | j                  D cg c]  }|j                  s| c}D ]]  }t	        ||j                  j
                  dd|j                  j                  j                  j                   d      ||j                  <   _ |S c c}w c c}w )D
    Returns an `OrderedDict` of field names to `RelationInfo`.
    Fr   TN)r   r   r*   r&   r   r   r0   r+   many_to_manythroughr   auto_created)r   r   r,   s      r!   r   r   H   s     $%)[[[[EEOOHZHZ%[[(4,,22"5)#)
%**% \ &*%6%6J%6E%//%%6J(4,,22&&..44AAA
)
%**% K 1 \ Ks   DDDDDc                    t               }| j                  D cg c]  }|j                  j                  r| }}|D ]a  }|j	                         }t        d|j                  |j                  j                  j                  t        |j                        dd      ||<   c | j                  D cg c]  }|j                  j                  s| }}|D ]  }|j	                         }t        d|j                  ddt        |j                  j                  dd      duxr5 |j                  j                  j                  j                  j                   d      ||<    |S c c}w c c}w )r2   NFTr   r4   )r   related_objectsr,   r3   get_accessor_namer   r   r&   multipler0   r/   r4   r   r5   )r   r	   rall_related_objectsrelationaccessor_name all_related_many_to_many_objectss          r!   r   r   h   sM    $&*&:&:W&:!''BVBV1&:W' 224+7"00NN//88"8>>2#,
-( ( 483G3G'`3Ga177K_K_3G$'`4 224+7"0044iFdR KNN//77==JJJ,
-( 5 ; X (as   E E /E%E%c                 d    t               }| |d<   | || j                  <   |j                  |       |S )Nr   )r   r+   update)r   r   r
   s      r!   r   r      s5    MMM$M"'' r#   c                 z    t        t        | j                               t        |j                               z         S r%   )r   listitems)r   r	   s     r!   r   r      s8    $$&'$$&'	( r#   c                 z    t        | d      xr. t        | j                  d      xr | 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   rE   )r   s    r!   is_abstract_modelrG      s0     5'"`wu{{J'G`EKKL`L``r#   N)__doc__collectionsr   r   r   r   r"   r   r   r0   r   r   r   r   rG    r#   r!   <module>rK      sd    0} ' 	 . + 3&	D@"Jar#   