o
    ‡l 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d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)ÚusingN© )Ú
ValueErrorÚnormalize_emailÚmodelÚset_passwordÚsaveÚ_db)Úselfr   ÚpasswordÚextra_fieldsÚuserr   r   ú;/var/www/html/docker_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r"t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    