
    Si                     z    d dl mZ d dlmZ d dlmZ d dlmZ d Z G d de      Z	 G d d	ej                        Zy
)    )AbstractUser)models)Session)timezonec                 :    d| j                   j                   d| S )Nzdocuments/user_/)userid)instancefilenames     %/var/www/alwasay/apps/users/models.pydocument_upload_pathr      s     X]]--.az::    c                   \     e Zd Z ej                  d      ZdZg dZd Zd Z	 fdZ
 xZS )UserT)uniqueemail)username
first_name	last_namec                     | j                   S N)r   selfs    r   __str__zUser.__str__   s    zzr   c                    g }t         j                  j                  t        j                               D ]^  }|j                         }t        | j                        t        |j                  d            k(  sD|j                  |j                         ` t         j                  j                  |      j                          y )N)expire_date__gte_auth_user_id)pk__in)r   objectsfilterr   nowget_decodedstrpkgetappenddelete)r   user_sessionssessionsession_datas       r   force_logoutzUser.force_logout   s    --x||~-N 	1G"..0L477|s<#3#3O#DEE$$WZZ0	1 	m4;;=r   c                    | j                   rS	 t        j                  j                  | j                         }|j                  r| j                  s| j                          t        |    |i | y # t        j                  $ r Y %w xY w)N)r%   )	r%   r   r    r&   	is_activer,   DoesNotExistsupersave)r   argskwargsold_user	__class__s       r   r1   z	User.save   sr    77<<++tww+7%%dnn%%' 	d%f% $$ s   AA1 1BB)__name__
__module____qualname__r   
EmailFieldr   USERNAME_FIELDREQUIRED_FIELDSr   r,   r1   __classcell__)r5   s   @r   r   r      s3    FT*EN=O>& &r   r   c                      e Zd Z G d dej                        Z ej                  eej                  d      Z	 ej                  dej                  ej                        Z ej                  dd	      Z ej                  d
      Z ej                  dd	      Z ej                  dd	      Z ej$                  d      Z ej                  dd	      Z ej                  d
      Z ej                  d
      Z ej                  dd      Z ej                  dd	      Z ej                  d
      Z ej4                  ed      Z ej4                  ed      Z ej4                  ed      Z ej4                  ed      Z ej4                  ed      Z  ejB                  d      Z" ejB                  d      Z# G d d      Z$d Z%e&d        Z'e&d        Z(y)CustomerProfilec                       e Zd ZdZdZy)CustomerProfile.CustomerType)personalPersonal)businessBusinessN)r6   r7   r8   PERSONALBUSINESS r   r   CustomerTyper@   (   s    ))r   rH   profile)	on_deleterelated_name   )
max_lengthchoicesdefaultd   T)rM   blank)rM      )rQ   2   zUnited Arab Emirates)rM   rO   )	upload_torQ   )auto_now_add)auto_nowc                       e Zd ZdZdZy)CustomerProfile.MetazCustomer ProfilezCustomer ProfilesN)r6   r7   r8   verbose_nameverbose_name_pluralrG   r   r   MetarX   F   s    )1r   r[   c                 L    | j                   j                   d| j                   S )Nz - )r	   r   customer_typer   s    r   r   zCustomerProfile.__str__J   s#    ))//"#d&8&8%9::r   c                 H    | j                   | j                  j                  k(  S r   )r]   rH   rF   r   s    r   is_businesszCustomerProfile.is_businessM       !!T%6%6%?%???r   c                 H    | j                   | j                  j                  k(  S r   )r]   rH   rE   r   s    r   is_personalzCustomerProfile.is_personalQ   r`   r   N))r6   r7   r8   r   TextChoicesrH   OneToOneFieldr   CASCADEr	   	CharFieldrN   rE   r]   	job_titlephone_numbercompany_namecompany_legal_namer9   company_emailvat_tax_numberstreet_addresscitycountrystate_provincezip_code	FileFieldr   business_permitcommercial_trading_licensevat_registration_certificateowner_passport_copynational_idDateTimeField
created_at
updated_atr[   r   propertyr_   rb   rG   r   r   r>   r>   '   s   *v)) *  6YWD$F$$L<P<PZfZoZopM   Ct<I#6##r2L#6##s$?L)))SE%F%%D1M%V%%4@N%V%%5N6s+Df#7MNG%V%%DANv2.H&f&&1ETRO!1!1!1<PX\!]#36#3#3>RZ^#_ *&**5IQUV"&""-ANK%%%48J%%%t4J2 2; @ @ @ @r   r>   N)django.contrib.auth.modelsr   	django.dbr   django.contrib.sessions.modelsr   django.utilsr   r   r   Modelr>   rG   r   r   <module>r      s4    3  2 !;&< &8,@fll ,@r   