U
    ãö—e)  ã                   @   s4   d dl mZ d dlmZ G dd„ deƒZdd„ ZdS )é    )ÚBaseUserManager)Úgettext_lazyc                   @   s   e Zd ZdZdd„ ZdS )ÚCustomUserManagerzv
    Custom user model manager where email is the unique identifiers
    for authentication instead of usernames.
    c                 K   sD   |st tdƒƒ‚|  |¡}| jf d|i|—Ž}| |¡ | ¡  |S )zK
        Create and save a user with the given email and password.
        zThe Email must be setÚemail)Ú
ValueErrorÚ_Únormalize_emailÚmodelÚset_passwordÚsave)Úselfr   ÚpasswordÚextra_fieldsÚuser© r   ú//var/www/html/Adatlas/src/apps/core/managers.pyÚcreate_user
   s    

zCustomUserManager.create_userN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r      s   r   c                 K   sh   |  dd¡ |  dd¡ |  dd¡ | d¡dk	r>ttdƒƒ‚| d¡dk	rXttdƒƒ‚| j||f|ŽS )zP
        Create and save a SuperUser with the given email and password.
        Úis_staffTÚis_superuserÚ	is_activez"Superuser must have is_staff=True.z&Superuser must have is_superuser=True.)Ú
setdefaultÚgetr   r   r   )r   r   r   r   r   r   r   Úcreate_superuser   s    r   N)Údjango.contrib.auth.base_userr   Údjango.utils.translationr   r   r   r   r   r   r   r   Ú<module>   s   