a
    Dg                     @   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 )    )warn)Widget)	mark_safe)RemovedInWagtail70Warningc                       sD   e Zd Zededd  fddZdd Zdd	d
Zdd Z  Z	S )WidgetWithScriptzQThe usage of `WidgetWithScript` hook is deprecated. Use external scripts instead.   )category
stacklevelc                    s   t  |||S )z4Render the HTML (non-JS) portion of the field markup)superrender)selfnamevalueattrs	__class__ T/var/www/lab.imftr.de/x/nb_venv/lib/python3.9/site-packages/wagtail/utils/widgets.pyrender_html   s    zWidgetWithScript.render_htmlc                 C   s   |S )Nr   )r   r   r   r   r   get_value_data   s    zWidgetWithScript.get_value_dataNc           
   	   C   sj   z|d }W n t tfy*   tdY n0 | |}| |||}| |||}| d| d}	t|	S )Nidz=WidgetWithScript cannot be rendered without an 'id' attributez<script>z	</script>)KeyError	TypeErrorr   r   render_js_initr   )
r   r   r   r   Zrendererid_Z
value_dataZwidget_htmlZjsoutr   r   r   r      s    

zWidgetWithScript.renderc                 C   s   dS )N r   )r   r   r   r   r   r   r   r   -   s    zWidgetWithScript.render_js_init)NN)
__name__
__module____qualname__r   r   r   r   r   r   __classcell__r   r   r   r   r   	   s   
r   N)	warningsr   Zdjango.forms.widgetsr   Zdjango.utils.safestringr   Zwagtail.utils.deprecationr   r   r   r   r   r   <module>   s   