o
    «…fb  ã                   @   s˜   d dl Z d dlmZ d dlT ddlT 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G dd„ deƒZG dd„ deƒZG dd„ deƒZdS )é    N)Úrender)Ú*é   )ÚAPIView)ÚResponse)Ústatus)ÚJsonResponsec                   @   ó   e Zd Zdd„ ZdS )ÚgetUserListc           	   
   C   s¢   i }z-t j ¡  d¡}td|ƒ |r!t|dd�}|j}d\}}}n
d\}}}W t	|ƒS W t	|ƒS  tyP } zdt|ƒ dd	}}}W Y d }~t	|ƒS d }~ww )
Nú-idÚ	user_postT©Úmany©zFetched successfully.ÚsuccesséÈ   ©zNo User data.r   r   úSomething went wrong :éô  Úerror)
ÚUserInfoÚobjectsÚallÚorder_byÚprintÚUserListSerializerÚdataÚ	ExceptionÚstrr   )	ÚselfÚrequestÚuser_info_datar   Úuser_posts_serializerÚmessageÚcoder   Úe© r&   ú1/home/esfera/Documents/myproject/mazaapi/views.pyÚget   s"   
øý"€ýzgetUserList.getN©Ú__name__Ú
__module__Ú__qualname__r(   r&   r&   r&   r'   r
      s    r
   c                   @   r	   )ÚgetReportListc           	   
   C   sž   i }z%t j ¡  d¡}td|ƒ |r!t|dd�}|j}d\}}}nd\}}}W n tyE } zdt|ƒ dd	}}}W Y d }~nd }~ww t	||||d
œƒS )Nr   Úuser_reportTr   r   r   r   r   r   )r#   r   r$   Úinfo)
ÚKeyClickesInfor   r   r   r   ÚUserReportSerializerr   r   r   r   )	r   r    Úuser_report_datar.   Úuser_report_serializerr#   r$   r   r%   r&   r&   r'   r(   .   s   

€$€ÿzgetReportList.getNr)   r&   r&   r&   r'   r-   ,   ó    r-   c                   @   r	   )ÚgetAddedpostListc           	   
   C   ó˜   i }z(t j ¡  d¡}|rt|dd�}|j}d\}}}n
d\}}}W t|ƒS W t|ƒS  tyK } zdt|ƒ dd}}}W Y d }~t|ƒS d }~ww ©	Nr   Tr   r   r   r   r   r   )	ÚUserAddedPostr   Úfilterr   ÚAddedPostSerializerr   r   r   r   )	r   r    Úadded_report_dataÚ
user_addedÚuser_added_serializerr#   r$   r   r%   r&   r&   r'   r(   H   s    øý"€ýzgetAddedpostList.getNr)   r&   r&   r&   r'   r5   F   r4   r5   c                   @   r	   )ÚViewGenerateReportc           	   
   C   r6   r7   )	ÚKeyClickInfoPerPostr   r   r   ÚPerPostclickSerializerr   r   r   r   )	r   r    Úadded_perpost_datar<   r=   r#   r$   r   r%   r&   r&   r'   r(   \   s    øý"€ýzViewGenerateReport.getNr)   r&   r&   r&   r'   r>   Z   r4   r>   )ÚimpÚdjango.shortcutsr   Úuserapp.modelsÚserializersÚrest_framework.viewsr   Úrest_framework.responser   Úrest_frameworkr   Údjango.httpr   r
   r-   r5   r>   r&   r&   r&   r'   Ú<module>   s    