a
    ތxd(                     @   s\   d dl mZmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 edd Zedd	 Zd
S )    )HttpResponseBadRequestJsonResponse)render_to_string)require_show_toolbar)HistoryStoreForm)DebugToolbarc                 C   sr   t | j}| rj|jd }t|}i }|jD ]0}|js<q0d|i}td|td|d||j	< q0t
|S tdS )z4Returns the selected debug toolbar history snapshot.store_idpanelz(debug_toolbar/includes/panel_button.htmlz)debug_toolbar/includes/panel_content.html)ZbuttoncontentForm errors)r   GETis_validZcleaned_datar   fetchZpanelsZis_historicalr   Zpanel_idr   r   )requestformr   toolbarcontextr	   Zpanel_context r   Z/var/www/html/Ranjet/env/lib/python3.9/site-packages/debug_toolbar/panels/history/views.pyhistory_sidebar	   s$    



r   c                 C   sn   t | j}| rfg }ttj D ]4\}}||td||t d|i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.htmlr   )initial)r   r   )idZstore_context)r   r
   requestsr   )r   r   r   reversedr   _storeitemsappendr   r   r   )r   r   r   r   r   r   r   r   history_refresh"   s$    
r   N)Zdjango.httpr   r   Zdjango.template.loaderr   Zdebug_toolbar.decoratorsr   Z"debug_toolbar.panels.history.formsr   Zdebug_toolbar.toolbarr   r   r   r   r   r   r   <module>   s   
