
    RZPfq                         d dl mZ d dlmZ d dlmZ d dlmZ d dlZd dl	m
Z
 ddlmZ dd	lmZ ed
             Zed             ZdS )    )render)status)JsonResponse)csrf_exemptN)verify_token   )Notifications)NotificationSerializerc                 ~   t          |           }|d k    r)t          dt          j        ddt          j                  S | j        dk    rt          j        | j                  }t                      }|d         |_	        |d         |_        t          |d                   |_        |                                 t          d	t          j        ddt          j                  S t          j                                        }t!          |d
          }t          |j        t          j        ddt          j                  S )NzUser not logged in.messager   Fsafer   POSTtitlebodysend_tozNotification Send succesfully.T)many)notificationsr   )r   r   r   HTTP_401_UNAUTHORIZEDmethodjsonloadsr   r	   r   intr   saveHTTP_200_OKobjectsallr
   data)requestuser_idrequest_datanotificationr   
serializers         EC:\Users\hp\python\driverzz\driverzz-admin-api\notifications\views.pyr   r      sR   7##G$(=Hdeelq  {A  {W  X  X  X  	X>V##:gl33L(??L!-g!6L ,V 4L#&|I'>#?#?L ,LW]Wi j jqv  @F  @R  S  S  S  S)15577M/DIIIJ*/FL^ _ _fktz  uG  H  H  H  H    c                    t          |           }|d k    r)t          dt          j        ddt          j                  S 	 t	          j        | j                  }t          j        	                    |d                   
                                 t          dt          j        ddt          j                  S # t          j        $ r, t          dt          j        ddt          j                  cY S w xY w)	NzUser not login.r   Fr   id)r(   z!Notification deleted Successfullyz4Notification doesn't exists. Invalid Notification id)r   r   r   r   r   r   r   r	   r   getdeleter   DoesNotExistHTTP_400_BAD_REQUEST)r    r!   r"   s      r%   deleteNotificationr-       sB   7##G$'86C_``glu{  vR  S  S  S  	S	{:gl33L!%%<+=%>>EEGGG,O[a[m n nuz  DJ  DV  W  W  W  W) 	{ 	{ 	{,bms  nI  !J  !J  QV  _e  _z  {  {  {  {  {  {	{s    A9B: :8C54C5)django.shortcutsr   rest_frameworkr   django.httpr   django.views.decorators.csrfr   r   authentication.authr   modelsr	   r$   r
   r   r-    r&   r%   <module>r5      s    # # # # # # ! ! ! ! ! ! $ $ $ $ $ $ 4 4 4 4 4 4  , , , , , , ! ! ! ! ! ! . . . . . . H H H& 
{ 
{ 
{ 
{ 
{r&   