a
    DgE                     @   sV   d dl mZ d dlmZ d dlmZmZ d dlmZ dddZ	ddd	Z
dd
dZdS )    )GenericRelation)models)ParentalKeyParentalManyToManyField)ClusterableModelNc                 C   s   |pg }i }| j  D ]}|j|v r&q|jr.qt|tr:q|jrxt|trt| |j}t	|dr|
 }|r|||j< qt|tjr|jjrqt|tjrd||j< t| |j||j< qt| |j||j< q|S )z
    Get dictionaries representing the model's field data.

    This excludes many to many fields (which are handled by _copy_m2m_relations)'
    allN)_meta
get_fieldsnameauto_created
isinstancer   many_to_manyr   getattrhasattrr   r   ZOneToOneFieldZremote_fieldZparent_linkZ
ForeignKeyZattname)sourceexclude_fields	data_dictfieldZparental_fieldvalues r   U/var/www/lab.imftr.de/x/nb_venv/lib/python3.9/site-packages/wagtail/models/copying.py_extract_field_data   s0    





r   c              	      s   |pi }|pg } j  D ]}|jr|j|vr|jst|tsz& fdd|jj  D }|rbW qW n tyv   Y n0 |j|v r||j }nt	 |j
 }t	||j| qdS )z5
    Copies non-ParentalManyToMany m2m relations
    c                    s(   g | ] }t |trt j|jr|qS r   )r   r   
issubclass	__class__Zrelated_model).0r   r   r   r   
<listcomp>L   s   
z'_copy_m2m_relations.<locals>.<listcomp>N)r   r	   r   r
   r   r   r   ZthroughAttributeErrorr   r   set)r   targetr   update_attrsr   Zthrough_model_parental_linksvaluer   r   r   _copy_m2m_relations;   s.    


r"   c                 C   sn   t | |d}| jf i |}|rH| D ]\}}||vr:q(t||| q(t| trb| j||d}ni }||fS )N)r   )exclude)r   r   itemssetattrr   r   Zcopy_all_child_relations)r   r   r    r   r   r   r!   Zchild_object_mapr   r   r   _copy`   s    
r&   )N)NN)NN)Z"django.contrib.contenttypes.fieldsr   Z	django.dbr   Zmodelcluster.fieldsr   r   Zmodelcluster.modelsr   r   r"   r&   r   r   r   r   <module>   s   
4
%