o
    hi                     @   sD   d dl mZ d dlmZ d dlmZ d dlmZ G dd deZdS )    )ImproperlyConfigured)cached_property)ChooserBlock)resolve_model_stringc                       sH   e Zd ZdgZ fddZedd Zedd ZG dd	 d	Z  Z	S )
SnippetChooserBlockiconc                    s   t  jdi | || _d S )N )super__init___target_model)selftarget_modelkwargs	__class__r   W/var/www/html/ndineBlogger/venv/lib/python3.10/site-packages/wagtail/snippets/blocks.pyr
      s   
zSnippetChooserBlock.__init__c                 C   s
   t | jS )N)r   r   )r   r   r   r   r      s   
z SnippetChooserBlock.target_modelc              
   C   sf   ddl m} z| jjj}W n ty" } z	td| j |d }~ww | d|i || j| jjdS )Nr   )AdminSnippetChooserz6Cannot use SnippetChooserBlock with non-snippet model r   )r   )	wagtail.snippets.widgetsr   r   snippet_viewsetr   AttributeErrorr   set_meta_optionsmeta)r   r   r   er   r   r   widget   s   
zSnippetChooserBlock.widgetc                   @   s   e Zd ZdZdS )zSnippetChooserBlock.MetasnippetN)__name__
__module____qualname__r   r   r   r   r   Meta&   s    r   )
r   r   r   MUTABLE_META_ATTRIBUTESr
   r   r   r   r   __classcell__r   r   r   r   r      s    

r   N)	django.core.exceptionsr   django.utils.functionalr   wagtail.blocksr   wagtail.coreutilsr   r   r   r   r   r   <module>   s
    