a
    c/                     @   s,   d dl mZ d dlmZ G dd deZdS )    )BaseUserManager)gettext_lazyc                   @   s.   e Zd ZdZdZdd Zd
ddZdd	 ZdS )UserManagerz? Define a model manager for User model with no username field. Tc                 K   sF   |st d| |}| jf d|i|}|| |j| jd |S )z; Create and save a User with the given email and password. zThe given Email must be setemail)using)
ValueErrornormalize_emailmodelset_passwordsave_db)selfr   passwordextra_fieldsuser r   FC:\Users\brahi\OneDrive\Desktop\UseVoice\src\apps\accounts\managers.py_create_user
   s    

zUserManager._create_userNc                 K   s,   | dd | dd | j||fi |S )zC Create and save a regular User with the given email and password. is_staffFis_superuser)
setdefaultr   r   r   r   r   r   r   r   create_user   s    zUserManager.create_userc                 K   sX   | dd | dd |ddur.td|ddurDtd| j||fi |S )z@ Create and save a SuperUser with the given email and password. r   Tr   z"Superuser must have is_staff=True.z&Superuser must have is_superuser=True.)r   getr   r   r   r   r   r   create_superuser   s    zUserManager.create_superuser)N)__name__
__module____qualname____doc__use_in_migrationsr   r   r   r   r   r   r   r      s
   
r   N)django.contrib.auth.modelsr   django.utils.translationr   _r   r   r   r   r   <module>   s   