o
    hN	                     @   s   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 dd	lmZ dd
lmZ dddZe jdd Zdd ZdS )    N)ImproperlyConfigured)ManyToOneRel)fields_for_model)formfield_for_dbfield)PanelPlaceholder   )Panel)
FieldPanel)
ObjectListc           	   	   C   s   t | dr| jS g }g }|r|| t| |td}| D ] \}}z|j }W n ty4   t	}Y nw ||}|
| q|S )Npanels)excludeformfield_callback)hasattrr   extendr   r   itemswidget	get_panelAttributeErrorr	   append)	modelr   r   _excludefields
field_namefieldpanel_classpanel r   `/var/www/html/ndineBlogger/venv/lib/python3.10/site-packages/wagtail/admin/panels/model_utils.py*extract_panel_definitions_from_model_class   s$   

r   c                 C   s,   t | dr	| j}nt| }t|}|| S )zL
    Get the panel to use in the Wagtail admin when editing this model.
    edit_handler)r   r   r   r
   bind_to_model)r   r   r   r   r   r   get_edit_handler)   s
   

r!   c                 C   s   g }|D ]M}t |tr|| qt |tr"|  }r!|| qt |trH| j|}t |tr@ddl	m
} ||| q|t| qtd|t|f |S )z
    Given a list which may be a mixture of Panel instances and strings (representing field/relation names),
    expand it into a flat list of Panel instances
    r   )InlinePanelz>Invalid panel definition %r - expected Panel or string, got %r)
isinstancer   r   r   	constructstr_meta	get_fieldr   inline_panelr"   r	   r   type)r   r   resultr   
real_panelr   r"   r   r   r   expand_panel_list8   s(   





r,   )N)	functoolsdjango.core.exceptionsr   'django.db.models.fields.reverse_relatedr   django.forms.modelsr   wagtail.admin.forms.modelsr   wagtail.modelsr   baser   field_panelr	   groupr
   r   cacher!   r,   r   r   r   r   <module>   s    

