o
    þâfý  ã                   @   sh   d 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 dd„ Zd	d
„ Zdd„ Zdd„ ZdS )zViews.é    )Ústates)ÚAsyncResultÚGroupResult)Úget_full_cls_name)ÚJsonResponse)Ú	safe_reprc                 C   s   t d|t|ƒ ¡ dœiƒS )z,Return task execution status in JSON format.Útask©ÚidÚexecuted)r   r   Ú
successful)ÚrequestÚtask_id© r   úN/var/www/html/venv/lib/python3.10/site-packages/django_celery_results/views.pyÚis_task_successful	   s   

þr   c                 C   sZ   t |ƒ}|j|j}}|||dœ}|tjv r'|j}| t|ƒt|j	ƒ|dœ¡ t
d|iƒS )z-Return task status and result in JSON format.)r
   ÚstatusÚresult)r   ÚexcÚ	tracebackr   )r   Ústater   r   ÚEXCEPTION_STATESr   Úupdater   r   Ú	__class__r   )r   r   r   r   ÚretvalÚresponse_datar   r   r   r   Útask_status   s   

þr   c                 C   s.   t  |¡}td||rdd„ |D ƒng dœiƒS )z+Return if group was successfull as boolean.Úgroupc                 S   s   g | ]
}|j | ¡ d œ‘qS )r	   )r
   r   )Ú.0r   r   r   r   Ú
<listcomp>%   s    ÿÿz'is_group_successful.<locals>.<listcomp>©r
   Úresults)r   Úrestorer   )r   Úgroup_idr!   r   r   r   Úis_group_successful   s   
ýþûÿr$   c                 C   s0   t  |¡}dd„ |jD ƒ}||dœ}td|iƒS )zEReturn group id and its async results status & result in JSON format.c                 S   s   g | ]	}|j |jd œ‘qS )©r   r   r%   )r   Úasync_resultr   r   r   r   0   s    ÿÿz group_status.<locals>.<listcomp>r    r   )r   r"   r!   r   )r   r#   r   r   r   r   r   r   Úgroup_status-   s   
þ
r'   N)Ú__doc__Úceleryr   Úcelery.resultr   r   Úcelery.utilsr   Údjango.httpr   Úkombu.utils.encodingr   r   r   r$   r'   r   r   r   r   Ú<module>   s    