o
    Wf_
                     @   sp   d dl mZ d dlZd dlmZ d dlmZ ddlmZm	Z	m
Z
 ddlmZmZmZ dd	 Zd
d Zdd ZdS )    )verify_tokenN)JsonResponse)status   )VehicleModelsVehicleTypesTransmissionTypes)VehicleTypesSerializerVehicleModelsSerializer"VehicleTransmissionTypesSerializerc              
   C   s   t | }|d krtdtjddtjdS ztj }t|dd}t|jtj	ddtj	dW S  t
yO } zt| tdtjddtjdW  Y d }~S d }~ww )	NUser not login.messager   Fsafer   Tmany)vehicle_typesr   -Something went wrong. Please try again later.)r   r   r   HTTP_401_UNAUTHORIZEDr   objectsallr	   dataHTTP_200_OK	ExceptionprintHTTP_400_BAD_REQUEST)requestuser_idr   
serializere r!   T/media/darth/New Volume E/PROJECTS/DRIVERZZ/DRIVERZZ_CUSTOMER_APIS/vehicles/views.pyvehicleTypes	   s   
$r#   c              
   C      t | }|d krtdtjddtjdS ztj }t|dd}t|jtj	ddtj	dW S  t
yK } ztdtjddtjdW  Y d }~S d }~ww )	Nr   r   Fr   Tr   )vehicle_modelsr   r   )r   r   r   r   r   r   r   r
   r   r   r   r   )r   r   r%   r   r    r!   r!   r"   vehicleModels      
$r&   c              
   C   r$   )	Nr   r   Fr   Tr   )transmission_typesr   r   )r   r   r   r   r   r   r   r   r   r   r   r   )r   r   r(   r   r    r!   r!   r"   transmissionTypes&   r'   r)   )authentication.authr   jsondjango.httpr   rest_frameworkr   modelsr   r   r   serializersr	   r
   r   r#   r&   r)   r!   r!   r!   r"   <module>   s    