
    .~h                         d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	  e       Z
 G d d	e      Z G d
 de      Z G d de      Z G d de      Z G d de      Z G d dej                         Zy)a#  
Forms and validation code for user registration.

Note that all of these forms assume Django's bundle default ``User``
model; since it's not possible for a form to anticipate in advance the
needs of custom user models, you will need to write your own forms if
you're using a custom model.

    )forms)UserCreationForm   )	UserModel)UsernameField)_c                   Z    e Zd ZdZdZ ej                   ed            Z G d d      Z	y)RegistrationForma  
    Form for registering a new user account.

    Validates that the requested username is not already in use, and
    requires the password to be entered twice to catch typos.

    Subclasses should feel free to add any additional validation they
    need, but should avoid defining a ``save()`` method -- the actual
    saving of collected user data is delegated to the active
    registration backend.

    requiredE-maillabelc                   "    e Zd ZeZ e       dfZy)RegistrationForm.MetaemailN)__name__
__module____qualname__Usermodelr   fields     [/var/www/peopleoo.sandbox-dev.co.uk/venv/lib/python3.12/site-packages/registration/forms.pyMetar   $   s    /7+r   r   N)
r   r   r   __doc__required_css_classr   
EmailFieldr   r   r   r   r   r   r
   r
      s/     $E1X;/E, ,r   r
   c                       e Zd ZdZd Zy)!RegistrationFormUsernameLowercasez
    A subclass of :class:`RegistrationForm` which enforces unique case insensitive
    usernames, make all usernames to lower case.

    c                    | j                   j                  dd      j                         }t        j                  j
                  di t               |ij                         rt        j                  t        d            |S )Nusername z)A user with that username already exists.r   )cleaned_datagetlowerr   objectsfilterr   existsr   ValidationErrorr   )selfr"   s     r   clean_usernamez0RegistrationFormUsernameLowercase.clean_username/   sd    $$((R8>>@<<=-/8!<=DDF''*U(VWWr   N)r   r   r   r   r,   r   r   r   r    r    )   s    
r   r    c                   j    e Zd ZdZ ej
                  ej                   ed      d ed      i      Zy)RegistrationFormTermsOfServicezy
    Subclass of ``RegistrationForm`` which adds a required checkbox
    for agreeing to a site's Terms of Service.

    z-I have read and agree to the Terms of Servicer   z'You must agree to the terms to register)widgetr   error_messagesN)	r   r   r   r   r   BooleanFieldCheckboxInputr   tosr   r   r   r.   r.   7   s;    
 %

E$7$7#$%T#U-7;d9e,fhCr   r.   c                       e Zd ZdZd Zy)RegistrationFormUniqueEmailz]
    Subclass of ``RegistrationForm`` which enforces uniqueness of
    email addresses.

    c                     t         j                  j                  | j                  d         rt	        j
                  t        d            | j                  d   S )z[
        Validate that the supplied email address is unique for the
        site.

        r   )email__iexactzNThis email address is already in use. Please supply a different email address.)r   r'   r(   r$   r   r*   r   )r+   s    r   clean_emailz'RegistrationFormUniqueEmail.clean_emailH   sL     <<T->->w-GH''*z({||  ))r   N)r   r   r   r   r8   r   r   r   r5   r5   B   s    
*r   r5   c                       e Zd ZdZg dZd Zy)RegistrationFormNoFreeEmaila6  
    Subclass of ``RegistrationForm`` which disallows registration with
    email addresses from popular free webmail services; moderately
    useful for preventing automated spam registrations.

    To change the list of banned domains, subclass this form and
    override the attribute ``bad_domains``.

    )zaim.comzaol.comz	email.comz	gmail.comzgooglemail.comzhotmail.comzhushmail.comzmsn.comzmail.ruzmailinator.comzlive.comz	yahoo.comzoutlook.comc                     | j                   d   j                  d      d   }|| j                  v rt        j                  t        d            | j                   d   S )zi
        Check the supplied email address against a list of known free
        webmail domains.

        r   @r   z_Registration using free email addresses is prohibited. Please supply a different email address.)r$   splitbad_domainsr   r*   r   )r+   email_domains     r   r8   z'RegistrationFormNoFreeEmail.clean_emailb   sf     ((177<Q?4+++''  +L  )M  N  N  ))r   N)r   r   r   r   r>   r8   r   r   r   r:   r:   S   s    /K
	*r   r:   c                   B    e Zd ZdZ ej
                   ed            Zy)ResendActivationFormr   r   r   N)r   r   r   r   r   r   r   r   r   r   r   rA   rA   n   s    #E1X;/Er   rA   N)r   djangor   django.contrib.auth.formsr   usersr   r   utilsr   r   r
   r    r.   r5   r:   FormrA   r   r   r   <module>rG      su     6    {,' ,*(8 h%5 h*"2 *"*"2 *605:: 0r   