
    Bh                         d dl mZ d dlmZmZmZ d dlmZ d dlm	Z	 d dl
mZ  G d de      Z G d d	ee      Z G d
 de      Zy)    )quote)AbstractBaseUserBaseUserManagerPermissionsMixin)	send_mail)models)timezonec                       e Zd Zd Zd Zd Zy)EmailUserManagerc           
          t        j                         }|st        d      | j                  |      } | j                  d||d|||d|}|j                  |       |j                  | j                         |S )zM
        Creates and saves a User with the given email and password.
        z,Users are required to have an email address.T)emailis_staff	is_activeis_superuser
last_logindate_joined)using )r	   now
ValueErrornormalize_emailmodelset_passwordsave_db)selfr   passwordr   r   extra_fieldsr   users           Z/home/dcms/DCMS/lib/python3.12/site-packages/cms/test_utils/project/emailuserapp/models.py_create_userzEmailUserManager._create_user   s    
 llnKLL$$U+tzz 
%#	
  ,	
 	(#			!    c                 .     | j                   ||ddfi |S )NFr!   r   usernamer   r   r   s        r    create_userzEmailUserManager.create_user$   s'     t  % 1#/1 	1r"   c                 .     | j                   ||ddfi |S )NTr$   r%   s        r    create_superuserz!EmailUserManager.create_superuser(   s'     t  $ 1#/1 	1r"   N)__name__
__module____qualname__r!   r'   r)   r   r"   r    r   r      s    *11r"   r   c                   f   e Zd ZdZ ej
                  ddddd      Z ej                  ddd	      Z ej                  d
dd	      Z	 ej                  ddd      Z ej                  ddd      Z ej                  dej                        Z e       ZdZg Z G d d      Zd Zd Zd ZddZy)AbstractEmailUsera,  
    An abstract user model that is an alternative to the standard AbstractUser.  The
    sole difference is that AbstractEmailUser does not have a username field, and uses
    the email field as the primary identifier by default.

    Email and password are required. Other fields are optional.
    zemail addressi,  Tz)Required.  Standard format email address.)
max_lengthblankunique	help_textz
first name   )r/   r0   z	last namezstaff statusFz9Designates whether the user can log into this admin site.)defaultr2   activezeDesignates whether this user should be treated as active. Unselect this instead of deleting accounts.zdate joined)r4   r   c                       e Zd ZdZdZdZy)AbstractEmailUser.Metar   usersTN)r*   r+   r,   verbose_nameverbose_name_pluralabstractr   r"   r    Metar7   ^   s    %r"   r<   c                 2    dt        | j                        z  S )Nz
/users/%s/)r   pkr   s    r    get_absolute_urlz"AbstractEmailUser.get_absolute_urlc   s    eDGGn,,r"   c                 X    | j                   d| j                  }|j                         S )zU
        Returns the first_name plus the last_name, with a space in between.
         )
first_name	last_namestrip)r   	full_names     r    get_full_namezAbstractEmailUser.get_full_namef   s#      $?	  r"   c                     | j                   S )z$Returns the short name for the user.)rC   r?   s    r    get_short_namez AbstractEmailUser.get_short_namem   s    r"   Nc                 6    t        |||| j                  g       y)z.
        Sends an email to this User.
        N)r   r   )r   subjectmessage
from_emails       r    
email_userzAbstractEmailUser.email_userq   s     	'7J=r"   )N)r*   r+   r,   __doc__r   
EmailFieldr   	CharFieldrC   rD   BooleanFieldr   r   DateTimeFieldr	   r   r   r   objectsUSERNAME_FIELDREQUIRED_FIELDSr<   r@   rG   rI   rN   r   r"   r    r.   r.   -   s     F=E "!!J !  I #v""MH $##@I '&&&}hllKK GNO 
-!>r"   r.   c                       e Zd ZdZy)	EmailUserz
    Users within the Django authentication system are represented by this
    model.

    Email and password are required. Other fields are optional.
    N)r*   r+   r,   rO   r   r"   r    rX   rX   x   s    r"   rX   N)urllib.parser   django.contrib.auth.modelsr   r   r   django.core.mailr   	django.dbr   django.utilsr	   r   r.   rX   r   r"   r    <module>r^      sJ     
 '  !1 1@H>(*: H>V! r"   