a
    Dg                     @   sd   d dl mZ d dlmZ d dlmZmZ d dlmZm	Z	 d dl
mZ ddlmZ G dd	 d	eZd
S )    )get_user_model) get_serializable_data_for_fields)CommentFormCommentFormSet)
avatar_urluser_display_name)COMMENTS_RELATION_NAME   )Panelc                       s:   e Zd Zdd Ze fddZG dd dejZ  ZS )CommentPanelc                 C   s"   dgt ttg dddgdidS )NZcomment_notifications)textZcontentpathpositioncommentsZfor_user)ZformsetformfieldsZformset_nameZinherit_kwargs)r   formsets)r   r   r   self r   a/var/www/lab.imftr.de/x/nb_venv/lib/python3.9/site-packages/wagtail/admin/panels/comment_panel.pyget_form_options   s    zCommentPanel.get_form_optionsc                    s   t  jp
dS )Nr   )super
clean_namer   	__class__r   r   r      s    zCommentPanel.clean_namec                       s*   e Zd ZdZd fdd	Zdd Z  ZS )zCommentPanel.BoundPanelz/wagtailadmin/panels/comments/comment_panel.htmlNc                    sR  t  |}dd  t| jdd }|jh}g }| jj}| jjd}|rN|j	ng }|D ]}	g }
|	jd j	D ]@}|
|jj t|j}|r|jddnd|d< |
| qj|
|	jj t|	j}|r|	jddnd|d< |r|	jd	dn
|	jjd u|d	< |
|d< || qV fd
dt jj|ddD }||j|d}||d< |S )Nc                 S   s   t | t| dS )N)namer   )r   r   )userr   r   r   	user_data'   s    z;CommentPanel.BoundPanel.get_context_data.<locals>.user_datar   r   repliesDELETEFZdeletedZresolvedc                    s   i | ]}t |j |qS r   )strpk).0r   r   r   r   
<dictcomp>G   s   z<CommentPanel.BoundPanel.get_context_data.<locals>.<dictcomp>)Zpk__inZwagtail_userprofile)r   r   authorscomments_data)r   get_context_datagetattrrequestr!   r   Zis_boundr   getZformsaddinstanceZuser_idr   Zcleaned_dataappendZresolved_atr   ZobjectsfilterZselect_related)r   Zparent_contextcontextr   Zuser_pksZserialized_commentsboundZcomment_formsetZcomment_formsr   r   Z
reply_formZ
reply_datadatar%   r&   r   r#   r   r'   $   sN    



z(CommentPanel.BoundPanel.get_context_datac                 C   s   dS )NFr   r   r   r   r   show_panel_furnitureW   s    z,CommentPanel.BoundPanel.show_panel_furniture)N)__name__
__module____qualname__Ztemplate_namer'   r2   __classcell__r   r   r   r   
BoundPanel!   s   3r7   )	r3   r4   r5   r   propertyr   r
   r7   r6   r   r   r   r   r      s   r   N)Zdjango.contrib.authr   Zmodelcluster.modelsr   Zwagtail.admin.forms.commentsr   r   Z,wagtail.admin.templatetags.wagtailadmin_tagsr   r   Zwagtail.modelsr   baser
   r   r   r   r   r   <module>   s   