
    ZLXf@                         d dl 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Zd dlmZ d dlmZ d d	lmZ d
dlmZmZ ed             Zed             ZdS )    N)render)status)JsonResponse)csrf_exempt)check_passwordmake_password)verify_token)User)DriverPartnerSerializer   )DriverPartnersDriverVehiclesc                    t          |           }|d k    r)t          dt          j        ddt          j                  S | j        dk    r_t          j        | j                  }t                      |d         _	        |d         _
        |d         _        t          d	          _        d
_        d_        |d         _        d                    d t%          d          D                       }d|z   _        d_                                         j        r`t/                      }j        |_        t3          |d                   |_        |d         |_        |d         |_        |d         |_        |d         |_        |d         |_        |d         |_         t3          |d                   |_!        t3          |d                   |_"        t3          |d                   |_#        t3          |d                   |_$        |                                 |d         r1tJ          j&        '                    fd|d         D                        t          dt          j(        ddt          j(                  S t          d t          j)        ddt          j)                  S t.          j&        *                                }tW          |d!"          }t          |j,        t          j(        d#dt          j(                  S )$NzUser is not loginmessager   Fsafer   POSTnameemailmobile123456   r   r    c              3   >   K   | ]}t          j        d           V  dS )$1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZN)randomchoice).0is     GC:\Users\hp\python\driverzz\driverzz-admin-api\driver_partners\views.py	<genexpr>z!driverPartners.<locals>.<genexpr>!   s.      hhZ[.T U Uhhhhhh       zUSER-r   genderlicensce_nodate_of_birth
experiencelocationhouse_numberpincodeuniform_typestation_type	trip_typetransmission_typevehicle_modelsc                 <    g | ]}t          j        |           S )	driver_idvehicle_model)r   id)r   r4   users     r!   
<listcomp>z"driverPartners.<locals>.<listcomp>7   s5     8 8 8`m47][[[8 8 8r#   z Driver partner added Succesfullyz-Something went wrong. Please try again later.Tmany)driver_partnersr   )-r	   r   r   HTTP_401_UNAUTHORIZEDmethodjsonloadsbodyr
   r   r   r   r   password	user_typeis_staff	is_activejoinrangeusernameis_superusersaver5   r   user_idintr%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r   objectsbulk_createHTTP_200_OKHTTP_400_BAD_REQUESTallr   data)requestrI   request_datarF   driver_partner
serializerr6   s         @r!   driverPartnersrU      s:   7##G$)<vGcddkpy  zV  W  W  W  	W>V##:gl33L66D$V,DI%g.DJ&x0DK)(33DMDNDM)(3DNwwhh_def_g_ghhhiiH#h.DM !DIIKKKw y!/!1!1)-&(+L,B(C(C%-9--H*/;O/L,,8,F)*6z*B'.:>.J+)5i)@&.1,~2N.O.O+.1,~2N.O.O++.|K/H+I+I(47EX8Y4Z4Z0##%%% 01 "*66 8 8 8 8q}  O  rP8 8 8    $1S^d^p$q$qx}  GM  GY  Z  Z  Z  Z#1`kq  lG  %H  %H  OT  ]c  ]x  y  y  y  y ,37799N0dKKKJJOfN` a ahmv|  wI  J  J  J  Jr#   c                    | j         dk    rat          j        | j                  }|d         rt          j                            |d                   |d         j        _        |d         j        _	        |d         j        _
        t          |d                   j        _        t          |d                   _        |d	         _        |d
         _        |d         _        |d         _        |d         _        |d         _        t          |d                   _        t          |d                   _        t          |d                   _        t          |d                   _        j                                                                          t2          j                            j        j                                                   |d         r1t2          j                            fd|d         D                        t=          dt>          j         ddt>          j                   S t=          dt>          j!        ddt>          j!                  S | j"                            d          r	 t          j                            | j"                            d                    tG          d          }t=          |j$        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t=          dt>          j!        ddt>          j!                  S )Nr   r5   )r5   r   r   r   r   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   )r3   r0   c                 F    g | ]}t          j        j        |           S r2   )r   r6   r5   )r   r4   rS   s     r!   r7   z%editDriverPartner.<locals>.<listcomp>`   s:     4 4 4kxN~/B/EXefff4 4 4r#   z!Driver details edited Succesfullyr   Fr   zDriver id is requiredr8   )rS   r   zDriver partner doesn't exists.zDriver partner id is required)&r<   r=   r>   r?   r   rK   getr6   r   r   r   rJ   rC   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   rH   r   filterr5   deleterL   r   r   rM   rN   GETr   rP   DoesNotExist)rQ   rR   rT   rS   s      @r!   editDriverPartnerr]   E   s   ~z',// 	\+377<;M7NNN'3F';N$)5h)?N&(4W(=N%,/X0F,G,GN)$'X(>$?$?N!)5m)DN&+7+HN((4\(BN%&2:&>N#*6~*FN'%1)%<N"*-l>.J*K*KN'*-l>.J*K*KN''*<+D'E'EN$03LAT4U0V0VN,$$&&&!!!"))n6I6L)MMTTVVV,- &22 4 4 4 4 }I  JZ  }[4 4 4     -P[a[m n nuz  DJ  DV  W  W  W  W+BfNi j jqv  @F  @[  \  \  \  \ ;??4   	di!/!7!;!;w{t?T?T!;!U!U4^%PPP
#zQWQc$d$dkpy  zL  M  M  M  M!. i i i#/O[a[v$w$w  D  MS  Mh  i  i  i  i  i  ii  +JV\Vq r ry~  HN  Hc  d  d  d  ds   
A6L 8L<;L<)r   django.shortcutsr   rest_frameworkr   django.httpr   django.views.decorators.csrfr   django.contrib.auth.hashersr   r   r=   authentication.authr	   authentication.modelsr
   driver_partners.serializerr   modelsr   r   rU   r]    r#   r!   <module>rh      s    # # # # # # ! ! ! ! ! ! $ $ $ $ $ $ 4 4 4 4 4 4 E E E E E E E E  , , , , , , & & & & & & > > > > > > 2 2 2 2 2 2 2 2 1J 1J 1Jh *d *d *d *d *dr#   