3
 \                  @   s  d dl mZ d dlmZ d dlmZ d dlmZ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 d d
lmZ d dlmZmZ d dlmZ d dlZd dl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G dd deZ G dd deZ!dS )    )render)django_pbkdf2_sha256)APIView)MultiPartParser
FormParser)*)HttpResponse)Response)IsAuthenticated)csrf_exempt)Token)api_viewpermission_classes)AllowAnyNc               @   s   e Zd Zedd ZdS )CustomerSignUpc             O   s  t d t d|j |jjd}|jjd}|jjd}|jjd}tj|}ytjj|d}	|	rrt d td	S t d
 t	jj
|||||d}	|	j  t d tjj|	d\}
}t d t t	j|
j |	rtdd|dS W n, tk
r
 } zt | W Y d d }~X nX d S )Nz



zdata is  : nameemailphonepassword)r   1zEmail exists2)usernamer   r   r   r   3)user11   zSignup Successful)codemessage
user_email)printPOSTgethandlerhashCustomerobjectsfilterr   	Customerrcreatesaver   get_or_creater   keyr	   	Exception)selfrequestargskwargsZname_val	email_valZ	phone_valpassword_valZnew_password_valatokencreatede r7   :/home/ip-n/Documents/suman/Transporter/Mobileapis/views.pypost   s.    
zCustomerSignUp.postN)__name__
__module____qualname__r   r9   r7   r7   r7   r8   r      s   r   c               @   s   e Zd ZefZdd ZdS )CustomerLoginc       
      O   s   t d t |j t d|j |jjd}|jjd}ytjj|d}t d t | |r|d j}t | t d tj	||}t | t d	 |rt d
 t
dd|j|d jdS tdS ntdS W n* tk
r }	 zt |	 W Y d d }	~	X nX d S )Nz



zdata is  : r   r   )r   r   r   r   Z22Z33r   zLogin Successful)r   r   r4   r   0)r   authr    r!   r'   r%   r&   r   r"   verifyr	   r   r   r,   )
r-   r.   r/   r0   r1   r2   r3   Z	new_passwcheckr6   r7   r7   r8   r9   F   s.    


zCustomerLogin.postN)r:   r;   r<   r
   r   r9   r7   r7   r7   r8   r=   D   s   r=   c               @   s   e Zd Zdd ZdS )CustomerForgetPasswordc             O   s6   t d t d|j |jjd}tjj|d}tdS )Nz



zdata is  : r   )r   r   )r   r    r!   r$   r%   r&   r   )r-   r.   r/   r0   r1   r3   r7   r7   r8   r9   q   s
    zCustomerForgetPassword.postN)r:   r;   r<   r9   r7   r7   r7   r8   rB   o   s   rB   c               @   s   e Zd Zdd ZdS )	ContactUsc             O   s   t d t d|j |jjd}|jjd}|jjd}|jjd}|jjd}y6tjj|||||d}	|	j  |	rtd	d
|dS W n0 tk
r }
 zt |
 td|
iS d }
~
X nX d S )Nz



zdata is  : addressmobiler   websiteop_hours)rD   rE   r   rF   rG   r   zForm Registered)r   r   r   r   )	r   r    r!   ContactModelr%   r(   r)   r	   r,   )r-   r.   r/   r0   rD   rE   r   rF   rG   r3   r6   r7   r7   r8   r9   {   s    zContactUs.postN)r:   r;   r<   r9   r7   r7   r7   r8   rC   y   s   rC   c               @   s   e Zd Zdd ZdS )CustomerProfilec          
   O   s   t d t d|j |jjd}|jjd}|jjd}|jjd}|jjd}|jjd}	|jjd	}
|jjd
}|jjd}|jd}t|d d t|d  d t|d  }t | tjj|dj	|||||	|
||d t d t
dddS )Nz



zdata is  : r   imageadd1add2countrystatecity
postalcodedob/   -r      )r   )rJ   addressline1addressline2rM   rN   rO   rP   dateofbirthzprofile updatedr   zProfile Updated)r   r   )r   r    r!   FILESsplitstrr$   r%   r&   updater	   )r-   r.   r/   r0   r   rJ   rK   rL   rM   rN   rO   rP   dob_valrQ   r7   r7   r8   r9      s"    
,$zCustomerProfile.postN)r:   r;   r<   r9   r7   r7   r7   r8   rI      s   rI   c               @   s   e Zd Zdd ZdS )CustomerSendParcelc       "   "   O   s  t d t d|j t |j |jjd}|jjd}t | |jjd}t | |jjd}t | |jjd}t | |jjd}	t |	 |jjd	}
t |
 |jjd
}t | |r|jd}t|d d t|d  d t|d  }t | |jjd}|sd}t | |jjd}t | |jjd}t | |jjd}t | |jjd}t | |jjd}t | |jjd}t | |jjd}t | |jjd}t | |jjd}t | |jjd}t | |jjd}t | |jjd}t | |jjd}t | |jjd}t | |jjd }t | |jjd!}t | |jjd"}t | tjj|d#}|ryVtjj	||||||	|
|||||||||||||||||||d$} | j
  td%d&d'S  tk
r  }! zt |! W Y d d }!~!X nX td(d)iS )*Nz



zdata is  : r   Zpickup_addrZadditional_addrZ
country_nmZcity_nmZpostal_codeZ	pickup_opZpickup_daterR   rS   rT   r   rU   Zpickup_time Zrec_nameZ	rec_phoneZparcel_drop_addrZrec_additional_addrZrec_country_nmZrec_city_nmZrec_postal_codeZrec_pickup_opZ
parcel_lenZ	parcel_htZ	parcel_wdZ	parcel_wtZparcel_vol_wtZ
parcel_typZ
parcel_valZinsureZ
parcel_des)r   )r   pickupaddressadditionaladdressfromcountryfromcityfrompostalcodefrompickupoption
pickupdate
pickuptimereceivernamereceiverphonereceiverdropaddressreceiveradditionaladdress	tocountrytocitytopostalcodetopickupoptionparcellengthparcelheightparcelwidthparcelweightparcelvolweight
parceltypeparcelvalue	insurancedescriptionr   zDetails Updated)r   r   r   Error)r   r    r   r!   rZ   r[   r$   r%   CustomerJobr(   r)   r	   r,   )"r-   r.   r/   r0   r1   Zpickup_addr_valZadditional_addr_valZcountry_nm_valZcity_nm_valZpostal_code_valZpickup_op_valZpickup_date_valr]   Zpickup_time_valZrec_name_valZrec_phone_valZparcel_drop_addr_valZrec_additional_addr_valZrec_country_nm_valZrec_city_nm_valZrec_postal_code_valZrec_pickup_op_valZparcel_len_valZparcel_ht_valZparcel_wd_valZparcel_wt_valZparcel_vol_wt_valZparcel_typ_valZparcel_val_valZ
insure_valZparcel_des_valr3   br6   r7   r7   r8   r9      s    

,@zCustomerSendParcel.postN)r:   r;   r<   r9   r7   r7   r7   r8   r^      s   r^   )"django.shortcutsr   Zpasslib.hashr   r"   rest_framework.viewsr   Zrest_framework.parsersr   r   ZCustomer.modelsZMobileapis.modelsdjango.httpr   rest_framework.responser	   Zrest_framework.permissionsr
   django.views.decorators.csrfr   rest_framework.authtoken.modelsr   Zrest_framework.decoratorsr   r   r   osbinasciir   r=   rB   rC   rI   r^   r7   r7   r7   r8   <module>   s(   3+
