o
    th7                     @   s0  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 d dlm Z  G dd dej!Z"G dd dej!Z#G dd dej!Z$G dd dej!Z%G dd dej!Z&G dd dej!Z'G dd dej!Z(G dd dej!Z)dd Z*ee*d d!Z+ee*d d!Z,ee*d d!Z-ee*d"d!Z.ee*d#d!Z/ee*d$d!Z0d%d& Z1ee1d d!Z2G d'd( d(ej!Z3G d)d* d*ej!Z4G d+d, d,ej!Z5G d-d. d.ej!Z6G d/d0 d0ej!Z7G d1d2 d2ej!Z8G d3d4 d4ej!Z9G d5d6 d6ej!Z:G d7d8 d8ej!Z;G d9d: d:ej!Z<G d;d< d<ej!Z=G d=d> d>ej!Z>G d?d@ d@ej!Z?G dAdB dBej!Z@G dCdD dDej!ZAG dEdF dFej!ZBG dGdH dHej!ZCG dIdJ dJeZDG dKdL dLeeZEG dMdN dNej!ZFG dOdP dPej!ZGd	S )Q    )models)AbstractBaseUserPermissionsMixinBaseUserManager)authenticatelogin)timezone)	timedelta)settings)slugify)partialN)
migrations)ValueFMax	CharFieldCaseWhen)CoalesceConcatCast)signalsc                   @   s~   e Zd Z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ddddZ
ejddddZG dd dZdd Zd	S )
AirlinesTprimary_key   
max_lengthblanknullc                   @      e Zd ZdZdS )zAirlines.MetaairlinesN__name__
__module____qualname__db_table r'   r'   J/var/www/html/myvaluetrips/my_value_trip_new/my_value_trip/users/models.pyMeta(       r)   c                 C   
   | j pdS N )airlineselfr'   r'   r(   __str__+      
zAirlines.__str__N)r#   r$   r%   r   	AutoFieldid	TextFieldiataicaor.   callsigncountryr)   r1   r'   r'   r'   r(   r       s    r   c                   @   sf   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dddZ	ej
d	ddd
ZG dd dZdS )AssocClientCompanyzusers.CompanyTassoc_client_company	on_deleter   r   related_namezusers.Clientclient_companies2   r   F)defaultr   r   c                   @   r    )zAssocClientCompany.Metar;   Nr"   r'   r'   r'   r(   r)   5   r*   r)   N)r#   r$   r%   r   
ForeignKeySET_NULLref_company
ref_clientr   designationBooleanFieldprimary_companyr)   r'   r'   r'   r(   r:   /   s    r:   c                   @   B   e Zd ZejdejdddZejddZe	 Z
G dd dZdS )	AuthGroupsUser
users.UserTr=   r   r      r   c                   @   r    )zAuthGroupsUser.Metaauth_groups_usersNr"   r'   r'   r'   r(   r)   >   r*   r)   N)r#   r$   r%   r   rB   CASCADEuserr   groupDateTimeField
created_atr)   r'   r'   r'   r(   rJ   9   
    rJ   c                   @   l   e Zd ZejddZejddddZejddZejddZej	dddZ
e Ze ZG dd dZdS )		AuthLoginrM   rN   Tr   r   r   c                   @   r    )zAuthLogin.Metaauth_loginsNr"   r'   r'   r'   r(   r)   K   r*   r)   Nr#   r$   r%   r   r   
ip_address
user_agentid_type
identifierPositiveIntegerFielduser_idrS   dateIntegerFieldsuccessr)   r'   r'   r'   r(   rW   B       rW   c                   @   rI   )	AuthPermissionsUserrK   TrL   rM   rN   c                   @   r    )zAuthPermissionsUser.Metaauth_permissions_usersNr"   r'   r'   r'   r(   r)   T   r*   r)   N)r#   r$   r%   r   rB   rP   rQ   r   
permissionrS   rT   r)   r'   r'   r'   r(   re   O   rU   re   c                   @   sb   e Zd ZejdddZejdddZejdejdddZ	e
 Ze
 Ze
 ZG dd	 d	Zd
S )AuthRememberTokenTrM   uniquer   hashedValidator	db_columnr   rK   rL   c                   @   r    )zAuthRememberToken.Metaauth_remember_tokensNr"   r'   r'   r'   r(   r)   `   r*   r)   N)r#   r$   r%   r   r   selectorhashedvalidatorrB   rC   rQ   rS   expiresrT   
updated_atr)   r'   r'   r'   r(   rh   X   s    rh   c                   @   rV   )	AuthTokenLoginrM   rN   Tr   rX   c                   @   r    )zAuthTokenLogin.Metaauth_token_loginsNr"   r'   r'   r'   r(   r)   m   r*   r)   NrZ   r'   r'   r'   r(   rs   d   rd   rs   c                   @   sB   e Zd ZejddZejdejdddZG dd dZ	dd	 Z
d
S )Cities   rN   users.StateTr=   r   r   c                   @   r    )zCities.MetacitiesNr"   r'   r'   r'   r(   r)   u   r*   r)   c                 C   r+   r,   namer/   r'   r'   r(   r1   x   r2   zCities.__str__N)r#   r$   r%   r   r   r{   rB   rC   state_idr)   r1   r'   r'   r'   r(   ru   q   
    ru   c                 C   s6   t | jdd pt | dd pd}tjddt|||S )N	client_id
unassigneduploadsclients)getattrrE   ospathjoinstr)instancefilenamefolderr~   r'   r'   r(   client_upload_path|   s   r   r-   )r   	insurancevisasother_documentsc                 C   s"   | j pd}tjddt|||S )Nr   r   company)r4   r   r   r   r   )r   r   r   
company_idr'   r'   r(   company_upload_path   s   
r   c                       sB  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 dejZg dZejddZejdddZejdejdddddZejdedddZejdedddZejdedddZejddddZejdddddZ ejdddddZ!ejdddddZ"ejd e	dddZ#ej$d!d"Z%ej&dddZ'ejd#ejddd$d%d&Z(ejdddddZ)ejdddddZ*ejd'edddd(Z+ejde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dddZ0ejdddddZ1ej2e3ddd*Z4d+d,d-d.d/Z5d0d1 Z6ej7e8ddd2Z9ejddddZ:ej7e;ddd2Z<ejd3dddZ=ejddddZ>ejd4ejddd5d5d&Z?ejd6ejddd7d7d&Z@ejd8ejddd9d9d&ZAejd'dddZBejd:ejddd;d<d&ZCejd edddZDejddddZEejd'edddZFejde
dddZGejd'edddZHejdedddZIejdedddZJejdedddZKejLejMddejNd=ZOejLd>d"ZPejQdddd?ZRejeSjTejddd@dAdZUejQddddBZVejeSjTejdddCdDdZW fdEdFZXdGdH fdIdJ
ZYeZdKdL Z[G dMdN dNZ\  Z]S )OClient))Mr.r   )Ms.r   )Mrs.r   )Miss.r   )Masterr   )Dr.r   ))Maler   )Femaler   Otherr   ))Marriedr   )	Unmarriedr   )Divorcedr   ))Walk Inr   )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                   @   s   e Zd ZdZdZdZdS )zClient.Status)r   Inactive)   Active)   DeletedN)r#   r$   r%   INACTIVEACTIVEDELETEDr'   r'   r'   r(   StatusK  s    r   ))Breakfast Includedr   )Swimming Pool Accessr   )
Gym Accessr   )Near Airportr   )Near City Centerr   Tr   rX   r0   ref_client_idrelated_clientsr=   r   r   rm   r>      r   choicesr   r     r   r-   r   r   r   rA   r@   )r   rj   r   r   rv   FrA   	Countriescountry_codecountry_codes)r=   r   r   rm   r>   
   r   r   r   r   rA      )rA   r   r   MailCallWhatsAppGroup Message)r   r   r   r   c                 C   sh   g }| j pg D ]'}t|tr|dp|dp|d}nt|}|r.|| j|| qd|S )Nr4   valuelabelz, )preferred_contact_method
isinstancedictgetr   appendPREFERRED_CONTACT_METHODSr   )r0   valuesvkeyr'   r'   r(   $get_preferred_contact_method_display}  s   
 
z+Client.get_preferred_contact_method_display	upload_tor   r      zusers.Citiesresidential_cityrw   residential_statezusers.Countriesresidential_countryzusers.Airlinesref_preferred_airlineref_preferred_airline_clients)r   r   r   rA   r   auto_now_addr   r   
created_byclients_createdauto_nowr   r   
updated_byclients_updatedc                    sb   t d| j d| j  | jdkrd| _n| jdkrd| _n| jr#dnd| _t j|i | d S )NzSaving client: pk=z, client_first_name=r   Tr   F)printpkclient_first_nameclient_status	is_activesupersaver0   argskwargs	__class__r'   r(   r    s   

zClient.saveN)rQ   c                   s    |r|| _ t j|i | dS )zQ
        Custom save method to attach the user who performed the action.
        N)_performed_byr  r  )r0   rQ   r  r  r  r'   r(   save_with_user  s   zClient.save_with_userc                 C   s*   | j pd d| jp
d d| jpd  S )Nr-    )r   client_middle_nameclient_last_namestripr/   r'   r'   r(   	full_name  s   *zClient.full_namec                   @   r    )zClient.Metar   Nr"   r'   r'   r'   r(   r)     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_AMENITIESr3   r~   rb   old_ref_client_idrB   rC   rE   r   relationcrossrelationclient_salutationr   r  r  client_codeclient_typerG   is_prepayment	DateFielddobr   
contact_noemailgendermarital_statusanniversary_datereference_fromreference_idreference_remark
occupation	JSONFieldlistr   r   r   	FileFieldclient_aadhar_card_pathaadhaar_card_file
aadhaar_noclient_pan_card_pathpan_card_file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  rS   rT   r
   AUTH_USER_MODELr   rr   r   r  r  propertyr  r)   __classcell__r'   r'   r  r(   r     s    		

%
r   c                   @   s  e Zd ZejddZejddZejddddZejddddZ	ejddZ
ejddddZejd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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d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ddddZejd
dddZejd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dZejd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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ddddZ*ejddddZ+ejddddZ,ejddZ-ejddddZ.ejd
dZ/ejddZ0ejd
dZ1G dd dZ2dS )ClientDataViewTr   )r   rM   r   r   rN   d   rX   r@   r   c                   @      e Zd ZdZdZdS )zClientDataView.MetaFview_client_dataNr#   r$   r%   managedr&   r'   r'   r'   r(   r)         r)   N)3r#   r$   r%   r   rb   r~   r   r   r!  r#  r   r  r  r$  r'  r(  r   r)  r*  r+  r,  r-  r1  r6  r7  r9  r:  r;  r   r   r   r<  r  rS   rT   r   rr   r   full_contact_nodateOfBirthanniversaryDatepassport_nopassportExpiryDate	city_namecompany_nameclient_nameResidentialAddressr%  clientStatus	createdOnr)   r'   r'   r'   r(   rI    sX    rI  c                   @   sf   e Zd ZejeejddZejeejddZej	dej
dddZej	dejdddZG dd dZd	S )
ClientRelationrelations_fromr=   r>   relations_tor   Tr   c                   @   r    )zClientRelation.Metaclients_relationsNr"   r'   r'   r'   r(   r)     r*   r)   N)r#   r$   r%   r   rB   r   rP   from_client	to_clientr   r  r!  r  cross_relationr)   r'   r'   r'   r(   r[    s    r[  c                   @   sP   e Zd ZejdejddddZejedddZ	ej
ddddZG dd	 d	Zd
S )ClientDocumentzusers.clientTclient_documents)r=   r   r   r>   r   rJ  r   c                   @   r    )zClientDocument.Metaclients_documentsNr"   r'   r'   r'   r(   r)     r*   r)   N)r#   r$   r%   r   rB   rC   rE   r4  client_document_pathother_documentr   other_document_namer)   r'   r'   r'   r(   rc    s
    rc  c                   @   sZ   e Zd ZejeejdddddZejeejdddddZ	ej
ddddZG d	d
 d
ZdS )ClientFrequentFlyerr   frequent_flyersTr=   rm   r>   r   r   ref_airline_idfrequent_flyers_airlinesr@   r   c                   @   r    )zClientFrequentFlyer.Metaclients_frequent_flyerNr"   r'   r'   r'   r(   r)   %  r*   r)   N)r#   r$   r%   r   rB   r   rC   rE   r   ref_airliner   ff_nor)   r'   r'   r'   r(   ri     s
    ri  c                   @   s   e Zd ZejdejdddddZejdejdddddZejd	ejddd
ddZej	ddddZ
ejdddZej	ddddZe ZejejejdddZejdddZedd ZG dd dZdS )	ClientLogr   Tr   client_logsr   Companyref_company_idcompany_logsrK   ref_user_id
users_logsrJ  r   rX   r@   rx   c                 C   s   | j dS )Nz%d/%m/%Y %H:%M)performed_atstrftimer/   r'   r'   r(   formatted_performed_at6  s   z ClientLog.formatted_performed_atc                   @   r    )zClientLog.Metaclients_logsNr"   r'   r'   r'   r(   r)   :  r*   r)   N)r#   r$   r%   r   rB   rC   r   rt  rv  r   ref_table_namerb   ref_idaction_typer2  changed_datar
   rF  performed_byrS   rx  rG  rz  r)   r'   r'   r'   r(   rq  )  s    
rq  c                   @   s^   e Zd ZejeejddddZeje	dddZ
ejddddZejdddZG dd	 d	Zd
S )ClientPassportTclient_passportr<   r   r   r   rX   c                   @   r    )zClientPassport.Metaclients_passportsNr"   r'   r'   r'   r(   r)   D  r*   r)   N)r#   r$   r%   r   rB   r   rC   rE   r4  client_passport_pathpassport_filer   rS  r'  passport_expiry_dater)   r'   r'   r'   r(   r  >  s    r  c                   @   s\   e Zd ZejeejddddZeje	dddZ
ejdddZejdddZG dd dZdS )	ClientTravelInsuranceTtravel_insurancer<   r   rX   c                   @   r    )zClientTravelInsurance.Metaclients_travel_insuranceNr"   r'   r'   r'   r(   r)   N  r*   r)   N)r#   r$   r%   r   rB   r   rC   rE   r4  client_insurance_pathinsurance_documentr'  insurance_from_dateinsurance_to_dater)   r'   r'   r'   r(   r  H  s    r  c                   @   s   e Zd ZdZejeejddddZejdej	ddddZ
ejdeddd	Zejeddd
ZejdddZejdddZG dd dZdS )
ClientVisa))Business Visar  )Employment Visar  )Tourist Visar  )Medical Visar  )Student Visar  Tclient_visar<   r   ref_visa_country)r=   r>   r   r   r   r   r   rX   c                   @   r    )zClientVisa.Metaclients_visasNr"   r'   r'   r'   r(   r)   a  r*   r)   N)r#   r$   r%   	VISA_TYPEr   rB   r   rC   rE   rP   r  r   	visa_typer4  client_visa_pathpassport_size_photographr'  visa_from_datevisa_to_dater)   r'   r'   r'   r(   r  R  s    r  c                       s  e Zd ZdZejddZejddddZejdej	dd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ddZejdddddZejdddddZejedddZejdddddZejdej	dddddZejdddddZejddddZejdej	dddddZejddddZejdeddddZejddZejddddZejejej	ddddd Z ejdddd!Z!ejejej	ddd"d#d Z" fd$d%Z#G d&d' d'Z$d(d) Z%  Z&S )*rs  )activer   )inactiver   rJ  rN      Tr   ru   company_city)r=   r   rm   Statecompany_stater   company_countryr   r-   )r   r   r   rA   r   r   r   account_country_code%account_concerned_person_country_code)r=   r   r   r>   rm   travel_country_code$travel_concerned_person_country_coder   r  r   r   r   r   company_createdr   r   r   company_updatedc           
         s   i }| j s>t j|i | | D ]\}}d}t| |j|}t| |j}|||}	t| ||	 qt jt	|
 d n	t j|i | | jdkrPd| _n| jdkrYd| _n| jr^dnd| _t jddgd d S )	Nr-   )update_fieldsr  Tr  Fr  company_status)r   r  r  itemsr   r{   r   storagesetattrr3  keysr  r  )
r0   r  r  
temp_filesfieldfiler   	full_pathr  
saved_pathr  r'   r(   r    s"   

zCompany.savec                   @   r    )zCompany.Metar   Nr"   r'   r'   r'   r(   r)     r*   r)   c                 C   r+   r,   )rV  r/   r'   r'   r(   r1     r2   zCompany.__str__)'r#   r$   r%   COMPANY_STATUSr   r   rV  company_addressrB   rC   r  r  r  company_pincodegst_namegst_nor4  company_gst_doc_pathgst_document_fileaccount_concerned_personr  #account_concerned_person_contact_notravel_concerned_personr  "travel_concerned_person_contact_nor  rG   r  rS   rT   r
   rF  r   rr   r   r  r)   r1   rH  r'   r'   r  r(   rs  e  s@    

(rs  c                   @   s   e Zd ZejddZ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ddddZejddddZejddddZejdddZejd	dZG d
d dZdS )CompanyDataViewTr   rM   rN   r   r@   r   rX   r   c                   @   rK  )zCompanyDataView.MetaFview_company_dataNrM  r'   r'   r'   r(   r)     rO  r)   N)r#   r$   r%   r   rb   r4   r   rV  r  r  CompanyAddressr  r  (full_account_concerned_person_contact_nor  companyStatusr)   r'   r'   r'   r(   r    s    r  c                   @   s^   e Zd ZejddZejddZe ZejdddZ	ejdddZ
G dd dZdd	 Zd
S )r      rN   r   TrX   c                   @   r    )zCountries.Meta	countriesNr"   r'   r'   r'   r(   r)     r*   r)   c                 C   r+   r,   rz   r/   r'   r'   r(   r1     r2   zCountries.__str__N)r#   r$   r%   r   r   	shortnamer{   rb   r   
min_lengthr   r)   r1   r'   r'   r'   r(   r     s    r   c                   @   sf   e Zd ZdZejdejddZejddZ	ej
ddZejd	d
ZejdeddZdd Zdd ZdS )LoginOTP))r   Login)forgot_passwordzForgot PasswordUser	login_otpr]     rN   T)r   Fr   r   r   )r   r   rA   c                 C   s   t  | jtdd kS )N   )minutes)r   nowrT   r	   r/   r'   r'   r(   
is_expired  s   zLoginOTP.is_expiredc                 C   s    d| j j d| j d| j dS )NzOTP for  - z ())rQ   r*  otppurposer/   r'   r'   r(   r1     s    zLoginOTP.__str__N)r#   r$   r%   PURPOSE_CHOICESr   OneToOneFieldrP   rQ   r   r  rS   rT   rG   is_verifiedr  r  r1   r'   r'   r'   r(   r    s    r  c                   @   s   e Zd ZejdejddddZejddZ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ZejddZejddZdd ZG dd dZdS )Menur0   Tsubmenusr<   rJ  rN   r   rM   #)r   r   rA   rX   rL   Fr   c                 C   r+   r,   )	menu_namer/   r'   r'   r(   r1      r2   zMenu.__str__c                   @   s   e Zd ZdZdgZdS )z	Menu.Metamenusmenu_order_noN)r#   r$   r%   r&   orderingr'   r'   r'   r(   r)     s    
r)   N)r#   r$   r%   r   rB   rC   ref_menur   r  menu_actionmenu_urlPositiveSmallIntegerFieldr  parentrG   menu_defaultmenu_statusr1   r)   r'   r'   r'   r(   r    s    r  c                   @   sn   e Zd ZejdddZejddZejdddZejddZ	ejddddZ
e Ze ZG d	d
 d
ZdS )SettingsclassrM   rl   rN   TrX      r   c                   @   r    )zSettings.Metar
   Nr"   r'   r'   r'   r(   r)     r*   r)   N)r#   r$   r%   r   r   class_fieldr   r5   r   typecontextrS   rT   rr   r)   r'   r'   r'   r(   r  
  s    r  c                   @   sB   e Zd ZejddZejeejdddZ	G dd dZ
dd Zd	S )
r  rv   rN   Trx   c                   @   r    )z
State.MetastatesNr"   r'   r'   r'   r(   r)     r*   r)   c                 C   r+   r,   rz   r/   r'   r'   r(   r1     r2   zState.__str__N)r#   r$   r%   r   r   r{   rB   r   rC   r9   r)   r1   r'   r'   r'   r(   r    r}   r  c                   @   sL   e Zd ZejdddZe ZejdddZ	ejdddZ
G dd dZdS )SystemEmailNotificationT   ri   rX   c                   @   r    )zSystemEmailNotification.Metasystem_email_notificationNr"   r'   r'   r'   r(   r)   (  r*   r)   N)r#   r$   r%   r   r   notification_typer5   emailsrS   rT   rr   r)   r'   r'   r'   r(   r  "  s    r  c                   @   s    e Zd ZdddZdddZdS )CustomUserManagerNc                 K   sF   |st d| |}| jdd|i|}|| |j| jd |S )NzThe Email field is requiredr*  )usingr'   )
ValueErrornormalize_emailmodelset_passwordr  _db)r0   r*  passwordextra_fieldsrQ   r'   r'   r(   create_user-  s   

zCustomUserManager.create_userc                 K   s,   | dd | dd | j||fi |S )Nis_staffTis_superuser)
setdefaultr  )r0   r*  r  r  r'   r'   r(   create_superuser6  s   z"CustomUserManager.create_superuserN)r#   r$   r%   r  r  r'   r'   r'   r(   r  ,  s    
	r  c                       s4  e Zd ZdZ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deddd	d
Zejd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ZejdejdddddZejddddZejdejdddddZejddddZdZdgZe ZG dd dZdd Z fddZ   Z!S )r  r  T)rj   rv   r   r   rM      r  r   rX   r   Fr0   user_createdr   )r=   r   r   r>   rm   r   user_updatedr   r   r*  usernamec                   @   r    )z	User.MetausersNr"   r'   r'   r'   r(   r)   Y  r*   r)   c                 C   r+   r,   )r  r/   r'   r'   r(   r1   \  r2   zUser.__str__c                    sF   | j dkr	d| _n| j dkrd| _nd| _ d| _t j|i | d S )Nr  Tr  F)statusr  r  r  r  r  r'   r(   r  _  s   

z	User.save)"r#   r$   r%   STATUS_CHOICEr   
EmailFieldr*  r   r  r)  rF   r	  r  rS   
last_loginrG   r  r  r   first_loginrB   rC   r   rT   r   rr   USERNAME_FIELDREQUIRED_FIELDSr  objectsr)   r1   r  rH  r'   r'   r  r(   r  ;  s.    r  c                   @   s   e Zd ZejeejdddddZejeej	dddddZ
ejddZejddZejddZejddZejddZG d	d
 d
Zdd ZdS )UserPermissionsrv  
menu_permsTrk  ref_menu_id
user_permsFr   c                   @   rK  )zUserPermissions.Metausers_permissions)ref_userr  N)r#   r$   r%   r&   unique_togetherr'   r'   r'   r(   r)   w  rO  r)   c                 C   s   | j j d| jj S )Nr  )r  r  r  r  r/   r'   r'   r(   r1   {  s   zUserPermissions.__str__N)r#   r$   r%   r   rB   r  rP   r  r  rC   r  rG   can_viewcan_addcan_edit
can_delete
can_exportr)   r1   r'   r'   r'   r(   r  m  s    r  c                   @   s<   e Zd Zg dZejdedddZejdddZdd Z	dS )	
EmailSetup))Visa Expiryr  )Passport Expiryr  )Travel Insurance Expiryr   )Birthday Reportr!  )Anniversary Reportr"  )Client Reportr#  r@   Tr   rX   c                 C   s   |   S r  )get_report_type_displayr/   r'   r'   r(   r1     s   zEmailSetup.__str__N)
r#   r$   r%   REPORT_TYPESr   r   report_typer  r*  r1   r'   r'   r'   r(   r    s
    	r  )H	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   r   Modelr   r:   rJ   rW   re   rh   rs   ru   r   r5  r8  r  r  r  rf  r   r  r   rI  r[  rc  ri  rq  r  r  r  rs  r  r   r  r  r  r  r  r  r  r  r  r'   r'   r'   r(   <module>   sl    
		  Y u1
		

`
2