
    h                        d dl mZ d dlmZmZmZ d dlmZ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 d d	lZd d
l mZ d dlmZmZmZmZmZmZ d dlmZmZmZ  G d dej@                        Z! G d dej@                        Z" G d dej@                        Z# G d dej@                        Z$ G d dej@                        Z% G d dej@                        Z& G d dej@                        Z' G d dej@                        Z(d Z) ee)d      Z* ee)d      Z+ ee)d      Z, ee)d       Z- ee)d!      Z. ee)d"      Z/d# Z0 ee0d      Z1 G d$ d%ej@                        Z2 G d& d'ej@                        Z3 G d( d)ej@                        Z4 G d* d+ej@                        Z5 G d, d-ej@                        Z6 G d. d/ej@                        Z7 G d0 d1ej@                        Z8 G d2 d3ej@                        Z9 G d4 d5ej@                        Z: G d6 d7ej@                        Z; G d8 d9ej@                        Z< G d: d;ej@                        Z= G d< d=ej@                        Z> G d> d?ej@                        Z? G d@ dAej@                        Z@ G dB dCej@                        ZA G dD dEej@                        ZB G dF dGe      ZC G dH dIee      ZD G dJ dKej@                        ZE G dL dMej@                        ZFy	)N    )models)AbstractBaseUserPermissionsMixinBaseUserManager)authenticatelogin)timezone)	timedelta)settings)slugify)partialN)
migrations)ValueFMax	CharFieldCaseWhen)CoalesceConcatCastc                      e Zd Z ej                  d      Z ej                  ddd      Z ej                  ddd      Z ej                  ddd      Z	 ej                  ddd      Z
 ej                  ddd      Z G d d      Zd Zy)	AirlinesTprimary_key   
max_lengthblanknullc                       e Zd ZdZy)Airlines.MetaairlinesN__name__
__module____qualname__db_table     :D:\Kush\my_value_trip_django\my_value_trip\users\models.pyMetar"   &       r*   r,   c                 "    | j                   xs dS N )airlineselfs    r+   __str__zAirlines.__str__)   s    ||!r!r*   N)r%   r&   r'   r   	AutoFieldid	TextFieldiataicaor1   callsigncountryr,   r4   r)   r*   r+   r   r      s    			d	+B6s$TBD6s$TBDf#TEGv3dFHf#TEG "r*   r   c                       e Zd Z ej                  dej
                  ddd      Z ej                  dej
                  ddd      Z ej                  ddd      Z	 ej                  d	dd
      Z G d d      Zy)AssocClientCompanyzusers.CompanyTassoc_client_company	on_deleter   r    related_namezusers.Clientclient_companies2   r   F)defaultr    r   c                       e Zd ZdZy)AssocClientCompany.Metar>   Nr$   r)   r*   r+   r,   rF   3       )r*   r,   N)r%   r&   r'   r   
ForeignKeySET_NULLref_company
ref_clientr   designationBooleanFieldprimary_companyr,   r)   r*   r+   r=   r=   -   s    #&##OvVZae  uK  LK""">V__TX_c  sE  FJ"&""b4HK)f))%d$OO* *r*   r=   c                       e Zd Z ej                  dej
                  dd      Z ej                  d      Z ej                         Z
 G d d      Zy)	AuthGroupsUser
users.UserTr@   r   r       r   c                       e Zd ZdZy)AuthGroupsUser.Metaauth_groups_usersNr$   r)   r*   r+   r,   rV   <       &r*   r,   N)r%   r&   r'   r   rH   CASCADEuserr   groupDateTimeField
created_atr,   r)   r*   r+   rP   rP   7   sK    6\V^^4VZ[DF,E%%%'J' 'r*   rP   c                   (   e Zd Z ej                  d      Z ej                  ddd      Z ej                  d      Z ej                  d      Z ej                  dd      Z
 ej                         Z ej                         Z G d d      Zy)		AuthLoginrS   rT   Tr   r   r    c                       e Zd ZdZy)AuthLogin.Metaauth_loginsNr$   r)   r*   r+   r,   rb   I   s     r*   r,   Nr%   r&   r'   r   r   
ip_address
user_agentid_type
identifierPositiveIntegerFielduser_idr\   dateIntegerFieldsuccessr,   r)   r*   r+   r_   r_   @   s    !!!S1J!!!S4HJf#.G!!!S1J)f))4@G6!D!f!!#G! !r*   r_   c                       e Zd Z ej                  dej
                  dd      Z ej                  d      Z ej                         Z
 G d d      Zy)	AuthPermissionsUserrQ   TrR   rS   rT   c                       e Zd ZdZy)AuthPermissionsUser.Metaauth_permissions_usersNr$   r)   r*   r+   r,   rq   R       +r*   r,   N)r%   r&   r'   r   rH   rY   rZ   r   
permissionr\   r]   r,   r)   r*   r+   ro   ro   M   sK    6\V^^4VZ[D!!!S1J%%%'J, ,r*   ro   c                      e Zd Z ej                  dd      Z ej                  dd      Z ej                  dej                  dd      Z	 ej                         Z ej                         Z ej                         Z G d d	      Zy
)AuthRememberTokenTrS   uniquer   hashedValidator	db_columnr   rQ   rR   c                       e Zd ZdZy)AuthRememberToken.Metaauth_remember_tokensNr$   r)   r*   r+   r,   r}   ^   rG   r*   r,   N)r%   r&   r'   r   r   selectorhashedvalidatorrH   rI   rZ   r\   expiresr]   
updated_atr,   r)   r*   r+   rv   rv   V   s    vt<H&f&&1BsSO6\V__DW[\D"f""$G%%%'J%%%'J* *r*   rv   c                   (   e Zd Z ej                  d      Z ej                  ddd      Z ej                  d      Z ej                  d      Z ej                  dd      Z
 ej                         Z ej                         Z G d d      Zy)	AuthTokenLoginrS   rT   Tr   r`   c                       e Zd ZdZy)AuthTokenLogin.Metaauth_token_loginsNr$   r)   r*   r+   r,   r   k   rX   r*   r,   Nrd   r)   r*   r+   r   r   b   s    !!!S1J!!!S4HJf#.G!!!S1J)f))4@G6!D!f!!#G' 'r*   r   c                       e Zd Z ej                  d      Z ej                  dej                  dd      Z G d d      Z	d Z
y	)
Cities   rT   users.StateTr@   r    r   c                       e Zd ZdZy)Cities.MetacitiesNr$   r)   r*   r+   r,   r   s       r*   r,   c                 "    | j                   xs dS r/   namer2   s    r+   r4   zCities.__str__v       yyBr*   N)r%   r&   r'   r   r   r   rH   rI   state_idr,   r4   r)   r*   r+   r   r   o   sA    6r*D v  &//PT\`aH r*   r   c                     t        | j                  dd       xs t        | dd       xs d}t        j                  j	                  ddt        |      ||      S )N	client_id
unassigneduploadsclients)getattrrK   ospathjoinstr)instancefilenamefolderr   s       r+   client_upload_pathr   z   sM    ++[$?w78U`bfCgwkwI 77<<	9c)nfhOOr*   r0   )r   	insurancevisasother_documentsc                 z    | j                   xs d}t        j                  j                  ddt	        |      ||      S )Nr   r   company)r6   r   r   r   r   )r   r   r   
company_ids       r+   company_upload_pathr      s1    ,J 77<<	9c*ovxPPr*   c                   $
    e Zd Zg dZg dZg dZg dZg dZg dZddgZ	g dZ
g d	Zg d
Zg dZg dZg dZ G d dej"                        Zg dZ ej(                  d      Z ej,                  dd      Z ej0                  dej2                  dddd      Z ej6                  dedd      Z ej6                  dedd      Z ej6                  dedd      Z ej6                  ddd      Z ej6                  dddd      Z  ej6                  dddd      Z! ej6                  dddd      Z" ej6                  d e	dd      Z# ejH                  d!"      Z% ejL                  dd      Z' ej0                  d#ej2                  ddd$d%&      Z( ej6                  dddd      Z) ej6                  dddd      Z* ej6                  d'eddd(      Z+ ej6                  dedd      Z, ejL                  dd      Z- ej6                  dedd      Z. ej,                  dd      Z/ ej6                  d)ddd      Z0 ej6                  dddd      Z1 ejd                  e3dd*      Z4d+d,d-d.d/Z5d0 Z6 ejn                  e8dd1      Z9 ej6                  ddd      Z: ejn                  e;dd1      Z< ej6                  d2dd      Z= ej6                  ddd      Z> ej0                  d3ej2                  ddd4d4&      Z? ej0                  d5ej2                  ddd6d6&      Z@ ej0                  d7ej2                  ddd8d8&      ZA ej6                  d'dd      ZB ej0                  d9ej2                  ddd:d;&      ZC ej6                  d edd      ZD ej6                  ddd      ZE ej6                  d'edd      ZF ej6                  de
dd      ZG ej6                  d'edd      ZH ej6                  dedd      ZI ej6                  dedd      ZJ ej6                  dedd      ZK ej                  ej                  ddej                  <      ZO ej                  d="      ZP ej                  ddd>      ZR ej0                  eSj                  ej2                  ddd?d@      ZU ej                  dddA      ZV ej0                  eSj                  ej2                  dddBdC      ZW fdDZXeYdE        ZZ fdFZXdGdH fdI
Z[ G dJ dK      Z\ xZ]S )LClient))Mr.r   )Ms.r   )Mrs.r   )Miss.r   )Masterr   )Dr.r   ))Maler   )Femaler   Otherr   ))Marriedr   )	Unmarriedr   )Divorcedr   ))zWalk inWalk_in)BNIr   )r   r   )zAtul SirAtul_sir)zJignesh SirJignesh_Sir)CounterzCounter/Internal_Staff))Fatherr   )Motherr   )Spouser   )Daughterr   )Brotherr   )Sisterr   )Sonr   )zPrimary MemberzPrimary-Member)zFamily MemberzFamily-Member))F - First classr   )J - Business classr   )W - Premium economyr   )Y - Economy classr   ))Vegr   )Non-Vegr   )z	Jain Foodz	Jain-Food))zKing Size BedKing_Size_Bed)zSmoking RoomSmoking_Room)zNon-Smoking RoomzNon-Smoking_Room))   Short Stay (1–2 Nights)r   )Long Stay (3+ Nights)r   )Business Stayr   )Leisure Stayr   )
Staycationr   ))3 Starr   )4 Starr   )5 Starr   ))Windowr   )Aisler   )Middler   )zDouble SeatDouble_Seat)z	First Row	First_Row)Emergency Exit Rowr   r   c                       e Zd ZdZdZdZy)Client.Status)r   Inactive)   Active)   DeletedN)r%   r&   r'   INACTIVEACTIVEDELETEDr)   r*   r+   Statusr      s     r*   r   ))Breakfast Includedr   )Swimming Pool Accessr   )
Gym Accessr   )Near Airportr   )Near City Centerr   Tr   r`   r3   ref_client_idrelated_clientsr@   r   r    r{   rA      r   choicesr   r      r   r0   r   r   r    rD   rC   )r   rx   r   r    r   FrD   	Countriescountry_codecountry_codes)r@   r    r   r{   rA   
   r   r   r   r    rD      )rD   r   r    MailCallWhatsAppGroup Message)r   r   r   r   c                 T   g }| j                   xs g D ]  }t        |t              r8|j                  d      xs$ |j                  d      xs |j                  d      }nt	        |      }|sY|j                  | j                  j                  ||              dj                  |      S )Nr6   valuelabelz, )preferred_contact_method
isinstancedictgetr   appendPREFERRED_CONTACT_METHODSr   )r3   valuesvkeys       r+   $get_preferred_contact_method_displayz+Client.get_preferred_contact_method_display3  s    //525A!T"eeDkEQUU7^EquuW~!fd<<@@cJK 6 yy  r*   	upload_tor   r       zusers.Citiesresidential_cityr   residential_statezusers.Countriesresidential_countryzusers.Airlinesref_preferred_airlineref_preferred_airline_clients)r   r   r    rD   r   auto_now_addr   r    
created_byclients_createdauto_nowr   r    
updated_byclients_updatedc                     | j                   dk(  rd| _        n,| j                   dk(  rd| _        n| j                  rdnd| _         t        |   |i | y )Nr   Tr   F)client_status	is_activesupersaver3   argskwargs	__class__s      r+   r   zClient.save\  sP    "!DN1$"DN '+nn!Dd%f%r*   c                     | j                   xs d d| j                  xs d d| j                  xs d j                         S )Nr0    )client_first_nameclient_middle_nameclient_last_namestripr2   s    r+   	full_namezClient.full_namef  sH    ((.B/q1H1H1NB0OqQUQfQfQljlPmnttvvr*   c                 F   i }| j                   s| j                  r| j                  |d<   d | _        | j                  r| j                  |d<   d | _        t        |   |i | |j                         D ]  \  }}|| _        t        | ||        t        |   t        |j                                      y | j                  r"| j                  j                  dd       | _
        | j                  r"| j                  j                  dd       | _        t        |   |i | y )Naadhaar_card_filepan_card_fileupdate_fieldsr   )microsecondtzinfo)pkr-  r.  r  r   items_current_file_fieldsetattrlistkeysr]   replacer   )r3   r"  r#  
temp_filesfieldfiler$  s         r+   r   zClient.save  s	   
 ww%%262H2H
./)-&!!.2.@.@
?+%)" GL$)&)  *//1t+0(eT*  2
 GLtJOO,='>L? "&//"9"9aPT"9"U"&//"9"9aPT"9"UGL$)&)r*   N)rZ   c                6    |r|| _         t        |   |i | y)zQ
        Custom save method to attach the user who performed the action.
        N)_performed_byr  r   )r3   rZ   r"  r#  r$  s       r+   save_with_userzClient.save_with_user  s!    
 !%Dd%f%r*   c                       e Zd ZdZy)Client.Metar   Nr$   r)   r*   r+   r,   rA        r*   r,   )^r%   r&   r'   SALUTIONGENDERMARITAL_STATUSREFERENCE_FROMRELATIONCROSS_RELATIONCLIENT_TYPEPREFERED_FARE_TYPEPREFERED_MEALROOM_PREFEREDSTAY_PREFEREDSTAR_RATINGSEAT_PREFEREDr   IntegerChoicesr   EXTRA_AMENITIESr5   r   rl   old_ref_client_idrH   rI   rK   r   relationcrossrelationclient_salutationr'  r(  r)  client_codeclient_typerM   is_prepayment	DateFielddobr   
contact_noemailgendermarital_statusanniversary_datereference_fromreference_idreference_remark
occupation	JSONFieldr7  r  r  r  	FileFieldclient_aadhar_card_pathr-  
aadhaar_noclient_pan_card_pathr.  pan_noresidential_addressr  r  r  residential_pincoder  seat_preferenceseat_preference_othermeal_preferencefare_preferencestar_ratingstay_preferenceroom_preferenceextra_amenitiesSmallIntegerFieldr   r   r  r  r\   r]   r   AUTH_USER_MODELr  r   r  r   propertyr+  r?  r,   __classcell__r$  s   @r+   r   r      s   HFNNHN 	-*K
MMMKM&& 
O !  T2I+++$TB"""6V__DW[gv  FW  XJv2xtRVWH$F$$NRV]abM(((BPT[_`(((Ct$O)))S4Y[\'v''3dWYZ"&""bTPTUK"&""b+TX\]K'F''6M
&

D
1C$6$$[FOORV^bn|  L[  \L!!!Rt$PRSJF4dBOEVV4d\^_F%V%%^SW^bcN'v''d>%V%%^SW^bcN&6&&T=L'v''3dWYZ!!!S4QSTJ/v//DtT (	!
! )((3JRV]ab!!!Rt$GJ$F$$/C4VZ[MV4dCF*&**cDQ(v((6??Y]ei  vH  Wi  j)))-6??Y]ei  vI  Xk  l+&++,=_cko  |Q  `u  v*&**b4P-F--.>&//`dlp  }T  cB  C&f&&"mSW^bcO,F,,$TR&f&&"mSW^bcO&f&&">PX\cghO"&""b+TX\]K&f&&"mSW^bcO&f&&"mSW^bcO&f&&"oUY`deO,F,,V^^4VZdjdqdqrM(((3I%%%4t$OJ"""8#;#;v^bim  zF  Uf  gJ%%%t4dKJ"""8#;#;v^bim  zF  Uf  gJ& w w:*| *. &B r*   r   c                      e Zd Z ej                  d      Z ej                  d      Z ej                  ddd      Z ej                  ddd      Z	 ej                  d      Z
 ej                  ddd      Z ej                  ddd      Z ej                  d      Z ej                  dd	      Z ej                  dd	      Z ej                  d
dd      Z ej                  ddd      Z ej                  ddd      Z ej                  d
dd      Z ej                  dd	      Z ej                  ddd      Z ej                  ddd      Z ej                  d
dd      Z ej                  ddd      Z ej                  d
dd      Z ej                  ddd      Z ej                  dd	      Z ej                  dd	      Z ej                  dd	      Z ej                  ddd      Z ej                  ddd      Z  ejB                  dd	      Z" ej                  dd	      Z# ejB                  dd	      Z$ ej                  dd	      Z% ej                  d
dd      Z& ej                  ddd      Z' ej                  ddd      Z( ej                  d
dd      Z) ej                  ddd      Z* ej                  ddd      Z+ ej                  ddd      Z, ej                  d      Z- ej                  ddd      Z. ej                  d
      Z/ ej                  d      Z0 ej                  d
      Z1 G d d      Z2y)ClientDataViewTr   )r    rS   r   r   rT   d   r`   rC   r   c                       e Zd ZdZdZy)ClientDataView.MetaFview_client_dataNr%   r&   r'   managedr(   r)   r*   r+   r,   r}    s    %r*   r,   N)3r%   r&   r'   r   rl   r   r   r   rS  rU  r'  r(  r)  rV  rY  rZ  r   r[  r\  r]  r^  r_  rc  r-  rg  r.  ri  rj  r  r  r  rk  r  r\   r]   r  r   r  full_contact_nodateOfBirthanniversaryDatepassport_nopassportExpiryDate	city_namecompany_nameclient_nameResidentialAddressrW  clientStatus	createdOnr,   r)   r*   r+   rz  rz    s   ###5I'F''T2Mv3dFH(((BdN(((C8)))S4P'v''3dN"&""c2K
&

D
1C&6&&T=L!!!Rt$GJF4dCEV4dCF%V%%4dKN'v''d>!!!S4HJ(((Ct$O!!!Rt$GJ$F$$4dKMV4dCF*&**cDQ*v**DA+++$TB-&--DtD*&**b4P$F$$$TJM%%%Dt<J$$$4d;J%%%Dt<J$$$4d;J&f&&"DtLO"&""b4HK&f&&"DtLO"&""b4HK)))Rt$O   Ct$GI#6##s$TJL"&""c2K)))S4P"&""b1K#6##r2L   B/I& &r*   rz  c                      e Zd Z ej                  eej                  d      Z ej                  eej                  d      Z ej                  dej                  dd      Z ej                  dej                  dd      Z G d d      Zy	)
ClientRelationrelations_fromr@   rA   relations_tor   Tr   c                       e Zd ZdZy)ClientRelation.Metaclients_relationsNr$   r)   r*   r+   r,   r     rX   r*   r,   N)r%   r&   r'   r   rH   r   rY   from_client	to_clientr   rG  rS  rH  cross_relationr,   r)   r*   r+   r  r    s    #&##FfnnScdK!!!&FNNQ_`Iv2vdY]^H%V%%V=R=RZ^eijN' 'r*   r  c                       e Zd Z ej                  dej
                  ddd      Z ej                  edd      Z	 ej                  ddd      Z G d d	      Zy
)ClientDocumentzusers.clientTclient_documents)r@   r    r   rA   r  r{  r   c                       e Zd ZdZy)ClientDocument.Metaclients_documentsNr$   r)   r*   r+   r,   r  )  rX   r*   r,   N)r%   r&   r'   r   rH   rI   rK   re  client_document_pathother_documentr   other_document_namer,   r)   r*   r+   r  r  $  sc    """>V__SW_c  sE  FJ%V%%0DDW[\N*&**cDQ' 'r*   r  c                       e Zd Z ej                  eej                  dddd      Z ej                  eej                  dddd      Z	 ej                  ddd      Z G d	 d
      Zy)ClientFrequentFlyerr   frequent_flyersTr@   r{   rA   r   r    ref_airline_idfrequent_flyers_airlinesrC   r   c                       e Zd ZdZy)ClientFrequentFlyer.Metaclients_frequent_flyerNr$   r)   r*   r+   r,   r  2  rs   r*   r,   N)r%   r&   r'   r   rH   r   rI   rK   r   ref_airliner   ff_nor,   r)   r*   r+   r  r  -  s    """6V__P_n  HL  SW  XJ#&##HSc  sM  UY  `d  eKF$TBE, ,r*   r  c                      e Zd Z ej                  dej
                  dddd      Z ej                  dej
                  dddd      Z ej                  d	ej
                  ddd
d      Z ej                  ddd      Z
 ej                  dd      Z ej                  ddd      Z ej                         Z ej                  ej"                  ej
                  dd      Z ej&                  dd      Zed        Z G d d      Zy)	ClientLogr   Tr   client_logsr   Companyref_company_idcompany_logsrQ   ref_user_id
users_logsr{  r   r`   rC   r   c                 8    | j                   j                  d      S )Nz%d/%m/%Y %H:%M)performed_atstrftimer2   s    r+   formatted_performed_atz ClientLog.formatted_performed_atC  s      ))*:;;r*   c                       e Zd ZdZy)ClientLog.Metaclients_logsNr$   r)   r*   r+   r,   r  G  s    !r*   r,   N)r%   r&   r'   r   rH   rI   r   r  r  r   ref_table_namerl   ref_idaction_typerd  changed_datar   ru  performed_byr\   r  rv  r  r,   r)   r*   r+   r  r  6  s'   %F%%h&//QU\`l{  KX  YM&V&&yFOOSW^bn~  N\  ]N#&##LFOOSW^bn{  KW  XK%V%%DtLN V  t$7F"&""b4HK#6##%L$6$$X%=%=_ckopL'6''d>L< <" "r*   r  c                       e Zd Z ej                  eej                  ddd      Z ej                  e	dd      Z
 ej                  ddd      Z ej                  dd      Z G d d	      Zy
)ClientPassportTclient_passportr?   r  r   r   r`   c                       e Zd ZdZy)ClientPassport.Metaclients_passportsNr$   r)   r*   r+   r,   r  Q  rX   r*   r,   N)r%   r&   r'   r   rH   r   rI   rK   re  client_passport_pathpassport_filer   r  rY  passport_expiry_dater,   r)   r*   r+   r  r  K  so    """6V__DW[j{|J$F$$/C4VZ[M"&""b4HK+6++$TB' 'r*   r  c                       e Zd Z ej                  eej                  ddd      Z ej                  e	dd      Z
 ej                  dd      Z ej                  dd      Z G d d      Zy)	ClientTravelInsuranceTtravel_insurancer?   r  r`   c                       e Zd ZdZy)ClientTravelInsurance.Metaclients_travel_insuranceNr$   r)   r*   r+   r,   r  [  s    -r*   r,   N)r%   r&   r'   r   rH   r   rI   rK   re  client_insurance_pathinsurance_documentrY  insurance_from_dateinsurance_to_dater,   r)   r*   r+   r  r  U  sp    """6V__DW[j|}J)))4IQU\`a*&**DA(((t$?. .r*   r  c                   N   e Zd ZdZ ej
                  eej                  ddd      Z ej
                  dej                  ddd      Z
 ej                  dedd	      Z ej                  edd
      Z ej                   dd      Z ej                   dd      Z G d d      Zy)
ClientVisa))Business_visaBusiness_Visa)Employment_visaEmployment_Visa)Tourist_visaTourist_Visa)Medical_visaMedical_Visa)Student_visaStudent_VisaTclient_visar?   r   ref_visa_country)r@   rA   r   r    r   r   r  r`   c                       e Zd ZdZy)ClientVisa.Metaclients_visasNr$   r)   r*   r+   r,   r  n  s    "r*   r,   N)r%   r&   r'   	VISA_TYPEr   rH   r   rI   rK   rY   r  r   	visa_typere  client_visa_pathpassport_size_photographrY  visa_from_datevisa_to_dater,   r)   r*   r+   r  r  _  s    I #""6V__DW[jwxJ(v((]ow{  CG  H   B	TXYI/v//:JRV]ab%V%%Dt<N#6##$T:L# #r*   r  c                       e Zd ZdZ ej
                  d      Z ej
                  ddd      Z ej                  dej                  dd	      Z
 ej                  d
ej                  dd	      Z ej                  dej                  dd	      Z ej
                  dddd      Z ej
                  dddd      Z ej
                  dddd      Z ej                   edd      Z ej
                  dddd      Z ej                  dej                  dddd      Z ej
                  dddd      Z ej
                  ddd      Z ej                  dej                  dddd      Z ej
                  ddd      Z ej
                  deddd      Z ej4                  d      Z ej8                  ddd      Z ej                  ej>                  ej                  dddd       Z  ej8                  ddd!      Z! ej                  ej>                  ej                  ddd"d#       Z" fd$Z# G d% d&      Z$d' Z% xZ&S )(r  )activer   )inactiver   r{  rT      Tr   r   company_city)r@   r    r{   Statecompany_stater   company_countryr   r0   )r   r    r   rD   r   r  r  account_country_code%account_concerned_person_country_code)r@   r    r   rA   r{   travel_country_code$travel_concerned_person_country_coder   r  r   r   r  r  company_createdr   r  r  company_updatedc                 h   i }| j                   s| j                  r| j                  |d<   d | _        t        
|   |i | |j	                         D ]S  \  }}d}t        | |j                  |      }t        | |      j                  }|j                  ||      }	t        | ||	       U t        
|   t        |j                                      nt        
|   |i | | j                  dk(  rd| _        n,| j                  dk(  rd| _        n| j                  rdnd| _        t        
|   dd	g       y )
Ngst_document_filer0   r/  r  Tr  Fr  company_status)r3  r  r  r   r4  r   r   r   storager6  r7  r8  r  r  )r3   r"  r#  r:  r;  r<  r   	full_pathr  
saved_pathr$  s             r+   r   zCompany.save  s'   
 ww%%262H2H
./)-& GL$)&)  *//1t/diiH	 "$.66$\\)T:
 eZ0  2 GLtJOO,='>L? GL$)&) (*!DN  J."DN.2nn(*DK1A#BCr*   c                       e Zd ZdZy)Company.Metar   Nr$   r)   r*   r+   r,   r    rB  r*   r,   c                 "    | j                   xs dS r/   )r  r2   s    r+   r4   zCompany.__str__  s      &B&r*   )'r%   r&   r'   COMPANY_STATUSr   r   r  company_addressrH   rI   r  r  r  company_pincodegst_namegst_nore  company_gst_doc_pathr  account_concerned_personr  #account_concerned_person_contact_notravel_concerned_personr  "travel_concerned_person_contact_nor  rM   r  r\   r]   r   ru  r  r   r  r   r,   r4   rw  rx  s   @r+   r  r  r  s   N $6##s3L&f&&#TMO$6$$Xt_mnL%F%%gt_noM'f''vUYevwO&f&&"4tUWXOv3drRHV4dBOF(((3GtZ^_/v//3dQU_ab,=F,=,=vT+7^-) +;&*:*:bPT[_ik*l'.f..#TPTU+<6+<+<vT*6\,( *:)9)9RtZ^)_&%V%%^SW^bltuN###D1I%%%4t$OJ"""8#;#;v^bim  zF  Uf  gJ%%%t4dKJ"""8#;#;v^bim  zF  Uf  gJ&DP 'r*   r  c                      e Zd Z ej                  d      Z ej                  d      Z ej                  ddd      Z ej                  ddd      Z	 ej                  ddd      Z
 ej                  ddd      Z ej                  ddd      Z ej                  ddd      Z ej                  dd      Z ej                  d	      Z G d
 d      Zy)CompanyDataViewTr   rS   rT   r   rC   r   r`   r   c                       e Zd ZdZdZy)CompanyDataView.MetaFview_company_dataNr  r)   r*   r+   r,   r    s    &r*   r,   N)r%   r&   r'   r   rl   r6   r   r  r  r  CompanyAddressr  r  (full_account_concerned_person_contact_nor  companyStatusr,   r)   r*   r+   r  r    s    				.B#6##s3Lv3dFHV4dCF%V%%DtLN/v//3dQUV*:&*:*:bPT[_*`'/?v/?/?2UY`d/e,(V((t$?N$F$$3M' 'r*   r  c                       e Zd Z ej                  d      Z ej                  d      Z ej                         Z ej                  dd      Z	 ej                  dd      Z
 G d d      Zd Zy	)
r      rT   r   Tr`   c                       e Zd ZdZy)Countries.Meta	countriesNr$   r)   r*   r+   r,   r    s    r*   r,   c                 "    | j                   xs dS r/   r   r2   s    r+   r4   zCountries.__str__  r   r*   N)r%   r&   r'   r   r   	shortnamer   rl   r   
min_lengthr   r,   r4   r)   r*   r+   r   r     sm       A.I6s+D&6&&(L$$$4d;J$$$4d;J r*   r   c                       e Zd ZdZ ej
                  dej                  d      Z ej                  d      Z	 ej                  d      Z ej                  d	
      Z ej                  ded      Zd Zd Zy)LoginOTP))r   Login)forgot_passwordzForgot PasswordUser	login_otpr     rT   T)r  Fr   r   r   )r   r   rD   c                 ^    t        j                         | j                  t        d      z   kD  S )N   )minutes)r	   nowr]   r
   r2   s    r+   
is_expiredzLoginOTP.is_expired  s!    ||~)A2F FFFr*   c                 j    d| j                   j                   d| j                   d| j                   dS )NzOTP for  - z ())rZ   r\  otppurposer2   s    r+   r4   zLoginOTP.__str__  s.    $))//*#dhhZr$,,qIIr*   N)r%   r&   r'   PURPOSE_CHOICESr   OneToOneFieldrY   rZ   r   r*  r\   r]   rM   is_verifiedr+  r&  r4   r)   r*   r+   r  r    s}    O
  6&..{[D
&

a
(C%%%48J%&%%e4Kf"owWGGJr*   r  c                      e Zd Z ej                  dej
                  ddd      Z ej                  d      Z ej                  ddd      Z	 ej                  ddd	
      Z
 ej                  dd      Z ej                  dej
                  dd      Z ej                  d      Z ej                  d      Zd Z G d d      Zy)Menur3   Tsubmenusr?   r{  rT   r   rS   #)r   r   rD   r`   rR   Fr   c                 "    | j                   xs dS r/   )	menu_namer2   s    r+   r4   zMenu.__str__  s    ~~##r*   c                       e Zd ZdZdgZy)	Menu.Metamenusmenu_order_noN)r%   r&   r'   r(   orderingr)   r*   r+   r,   r6    s    #$r*   r,   N)r%   r&   r'   r   rH   rI   ref_menur   r4  menu_actionmenu_urlPositiveSmallIntegerFieldr8  parentrM   menu_defaultmenu_statusr4   r,   r)   r*   r+   r0  r0    s     v  6??$UYhrsH   C0I"&""cDIKv3dCHH4F444dKMVvSWXF&6&&u5L%&%%d3K$% %r*   r0  c                   *   e Zd Z ej                  dd      Z ej                  d      Z ej                  dd      Z ej                  d      Z	 ej                  ddd      Z
 ej                         Z ej                         Z G d	 d
      Zy)SettingsclassrS   rz   rT   Tr`      r   c                       e Zd ZdZy)Settings.Metar   Nr$   r)   r*   r+   r,   rF     r-   r*   r,   N)r%   r&   r'   r   r   class_fieldr
  r7   r   typecontextr\   r]   r   r,   r)   r*   r+   rB  rB    s    "&""WEK
&

c
*CF4d3E6r*Df#TEG%%%'J%%%'J r*   rB  c                       e Zd Z ej                  d      Z ej                  eej                  dd      Z	 G d d      Z
d Zy)	r  r   rT   Tr   c                       e Zd ZdZy)
State.MetastatesNr$   r)   r*   r+   r,   rL  (  r   r*   r,   c                 "    | j                   xs dS r/   r   r2   s    r+   r4   zState.__str__+  r   r*   N)r%   r&   r'   r   r   r   rH   r   rI   r;   r,   r4   r)   r*   r+   r  r  $  s@    6r*Df	V__4W[\G r*   r  c                       e Zd Z ej                  dd      Z ej                         Z ej                  dd      Z	 ej                  dd      Z
 G d d      Zy)SystemEmailNotificationT   rw   r`   c                       e Zd ZdZy)SystemEmailNotification.Metasystem_email_notificationNr$   r)   r*   r+   r,   rS  5  s    .r*   r,   N)r%   r&   r'   r   r   notification_typer7   emailsr\   r]   r   r,   r)   r*   r+   rP  rP  /  sY    (((DVF%%%Dt<J%%%Dt<J/ /r*   rP  c                       e Zd ZddZddZy)CustomUserManagerNc                     |st        d      | j                  |      } | j                  dd|i|}|j                  |       |j	                  | j
                         |S )NzThe Email field is requiredr\  )usingr)   )
ValueErrornormalize_emailmodelset_passwordr   _db)r3   r\  passwordextra_fieldsrZ   s        r+   create_userzCustomUserManager.create_user:  s^    :;;$$U+tzz666(#			!r*   c                 r    |j                  dd       |j                  dd        | j                  ||fi |S )Nis_staffTis_superuser)
setdefaultrb  )r3   r\  r`  ra  s       r+   create_superuserz"CustomUserManager.create_superuserC  s<    
D15tx@<@@r*   N)r%   r&   r'   rb  rg  r)   r*   r+   rX  rX  9  s    Ar*   rX  c                       e Zd ZdZ ej
                  d      Z ej                  ddd      Z ej                  ddd      Z	 ej                  ddd      Z
 ej                  deddd	
      Z ej                  ddd      Z ej                  dd      Z ej                  d      Z ej                  d      Z ej                  d      Z ej                  d      Z ej(                  dej*                  dddd      Z ej                  ddd      Z ej(                  dej*                  dddd      Z ej                  ddd      ZdZdgZ e       Z G d d      Zd Z fdZ  xZ!S )r  r  T)rx   r   r   r  rS      r  r   r`   r   Fr3   user_createdr  )r@   r   r    rA   r{   r  user_updatedr  r  r\  usernamec                       e Zd ZdZy)	User.MetausersNr$   r)   r*   r+   r,   ro  f  s    r*   r,   c                 "    | j                   xs dS r/   )rm  r2   s    r+   r4   zUser.__str__i  s    }}""r*   c                     | j                   dk(  rd| _        n%| j                   dk(  rd| _        nd| _         d| _        t        |   |i | y )Nr  Tr  F)statusr  r  r   r!  s      r+   r   z	User.savel  sJ    ;;("!DN[[J&"DN #DK!DNd%f%r*   )"r%   r&   r'   STATUS_CHOICEr   
EmailFieldr\  r   rm  r[  rL   rs  r`  r\   
last_loginrM   r  rd  re  first_loginrH   rI   r  r]   r  r   USERNAME_FIELDREQUIRED_FIELDSrX  objectsr,   r4   r   rw  rx  s   @r+   r  r  H  s   M FT*Ev2TEH!!!Rt$GJ"&""cDIKVMTXbjkFv3TEH%%%Dt<J###D1I"v""51H&6&&u5L%&%%d3K #""6V__DW[jx  EQ  RJ%%%4t$OJ"""6V__DW[jx  EQ  RJ%%%t4dKJN!lO!G #& &r*   r  c                   l   e Zd Z ej                  eej                  dddd      Z ej                  eej                  dddd      Z
 ej                  d      Z ej                  d      Z ej                  d      Z ej                  d      Z ej                  d      Z G d	 d
      Zd Zy)UserPermissionsr  
menu_permsTr  ref_menu_id
user_permsFr   c                       e Zd ZdZdZy)UserPermissions.Metausers_permissions)ref_userr:  N)r%   r&   r'   r(   unique_togetherr)   r*   r+   r,   r    s    &2r*   r,   c                 `    | j                   j                   d| j                  j                   S )Nr(  )r  rm  r:  r4  r2   s    r+   r4   zUserPermissions.__str__  s)    --(()T]]-D-D,EFFr*   N)r%   r&   r'   r   rH   r  rY   r  r0  rI   r:  rM   can_viewcan_addcan_edit
can_delete
can_exportr,   r4   r)   r*   r+   r|  r|  z  s     v  =gs{  GK  LH v  Mht  }A  HL  MH$$$U3H$$$U3G$$$U3H$$$U3J$$$U3J3 3Gr*   r|  c                   n    e Zd Zg dZ ej
                  dedd      Z ej                  dd      Zd Z	y)
EmailSetup))Visa Expiryr  )Passport Expiryr  )Travel Insurance Expiryr  )Birthday Reportr  )Anniversary Reportr  )Client Reportr  rC   Tr   r`   c                 "    | j                         S rh  )get_report_type_displayr2   s    r+   r4   zEmailSetup.__str__  s    ++--r*   N)
r%   r&   r'   REPORT_TYPESr   r   report_typeru  r\  r4   r)   r*   r+   r  r    s=    L #&""b,dY]^KFDt4E.r*   r  )G	django.dbr   django.contrib.auth.modelsr   r   r   django.contrib.authr   r   django.utilsr	   datetimer
   django.confr   django.utils.textr   	functoolsr   r   r   django.db.modelsr   r   r   r   r   r   django.db.models.functionsr   r   r   Modelr   r=   rP   r_   ro   rv   r   r   r   rf  rh  r  r  r  r  r   r  r   rz  r  r  r  r  r  r  r  r  r  r   r  r0  rB  r  rP  rX  r  r|  r  r)   r*   r+   <module>r     s    Z Z 3 !  ! %  	   A A = =
"v|| "* *'V\\ '
! 
!,&,, ,	* 	*
'V\\ 
'V\\ P ""4R@ 1"= 1"=  2;G -g> 1:KL Q 22> GV\\ GX
.&V\\ .&b'V\\ ''V\\ ',&,, ," "*'V\\ '.FLL .# #&]'fll ]'@'fll '  Jv|| J&%6<< %(
v|| 
FLL /fll /A A/&- /&dGfll G&. .r*   