o
    QDi                     @   s   d dl mZmZmZ d dlmZ d dlmZ d dlm	Z	m
Z
 d dlmZ d dlmZ d dlmZ ee
e	ded	eeB fd
dZee
e	ded	eeB fddZdS )    )HttpRequestHttpResponseBadRequestJsonResponse)render_to_string)login_not_required)render_with_toolbar_languagerequire_show_toolbar)HistoryStoreForm)	get_store)DebugToolbarrequestreturnc                 C   s   t | j}| rD|jd }t|}|jd }i }|du r"t|S |jD ]}|r-|js-q%d|i}t	d|t	d|d||j
< q%t|S td|j S )	z4Returns the selected debug toolbar history snapshot.
request_idexclude_historyNpanelz(debug_toolbar/includes/panel_button.htmlz)debug_toolbar/includes/panel_content.html)buttoncontentzForm errors: )r	   GETis_validcleaned_datar   fetchr   panelsis_historicalr   panel_idr   errors)r   formr   toolbarr   contextr   panel_context r   [/var/www/Datamplify/venv/lib/python3.10/site-packages/debug_toolbar/panels/history/views.pyhistory_sidebar   s*   





r!   c                 C   s|   t | j}| r:g }t  D ]#}t|}||td||j	
|dt |dddddd qtd	|iS td
S )z?Returns the refreshed list of table rows for the History Panel.z$debug_toolbar/panels/history_tr.htmlHistoryPanelT)r   r   )initial)history_statsr   )r   history_context)idr   requestszForm errors)r	   r   r   r
   request_idsr   r   appendr   storer   r   r   )r   r   r'   r   r   r   r   r    history_refresh-   s2   

r+   N)django.httpr   r   r   django.template.loaderr   debug_toolbar._compatr   debug_toolbar.decoratorsr   r   "debug_toolbar.panels.history.formsr	   debug_toolbar.storer
   debug_toolbar.toolbarr   r!   r+   r   r   r   r    <module>   s.    