o
    Mf                     @   s   d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 d dlmZ d dlmZ 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 )    N)OrderedDict)RawPostDataException)render_to_string)static)path)timezone)gettext_lazy)SignedDataForm)Panel)views)HistoryStoreFormc                       sp   e Zd ZdZedZedZdZedd Z	e
dd Zedd	 Zd
d Zedd Ze fddZ  ZS )HistoryPanelz A panel to display History Historyz!debug_toolbar/panels/history.htmlc                 C   s   dS )zAThe HistoryPanel should not be included in the historical panels.F selfr   r   d/var/www/html/analyze/labelStudio/lib/python3.10/site-packages/debug_toolbar/panels/history/panel.pyis_historical   s   zHistoryPanel.is_historicalc                 C   s    t dtjddt dtjddgS )Nzhistory_sidebar/history_sidebar)namezhistory_refresh/history_refresh)r   r   r   r   )clsr   r   r   get_urls   s   zHistoryPanel.get_urlsc                 C   s   |   ddS )Nrequest_url )	get_statsgetr   r   r   r   nav_subtitle$   s   zHistoryPanel.nav_subtitlec                 C   s   z1|j dkr|j }n|j }|s0|jr0|jddkr0zt|j}W n	 t	y/   Y nw W n t
y<   d }Y nw | | |j |t d d S )NGETCONTENT_TYPEzapplication/json)r   request_methoddatatime)methodr   copyPOSTbodyMETAr   jsonloads
ValueErrorr   record_statsget_full_pathr   now)r   requestresponser!   r   r   r   generate_stats(   s2   

zHistoryPanel.generate_statsc                 C   sn   t  }t| jj D ]\}}|ttd|idjdd||< qt| j	| jj
|ttd| jj
idjddS )zContent of the panel when it's displayed in full screen.

        Fetch every store for the toolbar and include it in the template.
        store_id)initial)toolbarform)current_store_idstoresrefresh_form)r   reversedr3   _storeitemsr	   r   r2   r   templater1   )r   r6   idr3   r   r   r   contentF   s&   
zHistoryPanel.contentc                    s   t  j}|td |S )Nzdebug_toolbar/js/history.js)superscriptsappendr   )r   r?   	__class__r   r   r?   b   s   zHistoryPanel.scripts)__name__
__module____qualname____doc___title	nav_titler;   propertyr   classmethodr   r   r0   r=   r?   __classcell__r   r   rA   r   r      s     



r   )r(   collectionsr   django.http.requestr   django.template.loaderr   django.templatetags.staticr   django.urlsr   django.utilsr   django.utils.translationr   rG   debug_toolbar.formsr	   debug_toolbar.panelsr
   debug_toolbar.panels.historyr   "debug_toolbar.panels.history.formsr   r   r   r   r   r   <module>   s    