o
     #i~                     @   sf   d dl mZ d dlmZ d dlmZ d dlmZ G dd dej	Z
G dd deZG d	d
 d
eZdS )    )AbstractUser)models)gettext_lazy)BaseUserManagerc                   @   s$   e Zd ZejddddZdd ZdS )UserRole   T)
max_lengthnullblankc                 C      | j S Ntitleself r   ?/var/www/GraceOrthoHospital/grace_ortho_care/accounts/models.py__str__
      zUserRole.__str__N)__name__
__module____qualname__r   	CharFieldr   r   r   r   r   r   r      s    r   c                   @   s    e Zd ZdZdd Zdd ZdS )UserManagerzv
    Custom user model manager where email is the unique identifiers
    for authentication instead of usernames.
    c                 K   sD   |st td| |}| jdd|i|}|| |  |S )zK
        Create and save a user with the given email and password.
        zThe Email must be setemailNr   )
ValueError_normalize_emailmodelset_passwordsave)r   r   passwordextra_fieldsuserr   r   r   create_user   s   

zUserManager.create_userc                 K   s   t jjdd }|dd |dd |dd |d|j |ddur/ttd|ddur<ttd	| j	||fi |S )
zP
        Create and save a SuperUser with the given email and password.
        Adminr   is_staffTis_superuser	is_activerole_idz"Superuser must have is_staff=True.z&Superuser must have is_superuser=True.)
r   objectsfilterfirst
setdefaultidgetr   r   r$   )r   r   r!   r"   
admin_roler   r   r   create_superuser    s   zUserManager.create_superuserN)r   r   r   __doc__r$   r1   r   r   r   r   r      s    r   c                   @   sl   e Zd ZdZejedddZeje	ej
dddZejddddZejdddd	Zd
Zg Ze Zdd ZdS )UserNzemail addressT)unique)	on_deleter	   r
   F)defaultr	   r
   zusers/)	upload_tor
   r	   r   c                 C   r   r   )r   r   r   r   r   r   =   r   zUser.__str__)r   r   r   usernamer   
EmailFieldr   r   
ForeignKeyr   RESTRICTroleBooleanFieldemail_verification
ImageFieldprofile_picUSERNAME_FIELDREQUIRED_FIELDSr   r*   r   r   r   r   r   r3   1   s    r3   N)django.contrib.auth.modelsr   	django.dbr   django.utils.translationr   r   django.contrib.auth.base_userr   Modelr   r   r3   r   r   r   r   <module>   s    #