o
    uӴd                     @   s   d dl mZ d dlmZ d dlmZmZmZmZ d dl	m
Z d dlmZ d dlT G dd deZG d	d
 d
ejZG dd deZG dd deZG dd dejZG dd dejZdS )    )forms)User)UserCreationFormPasswordChangeFormPasswordResetFormSetPasswordForm)gettext_lazy)ValidationError)*c                   @   s   e Zd Zejdejdddddddd	d
Zejdejddddddddd
Z	ejdej
ddddddddd
Zejdej
ddddddddd
ZG dd dZdS )UserRegistrationFormEmailEnter your email
user_emailform-controlplaceholderidclassattrs2   T Required.add valid email addresslabelwidget
max_lengthrequired	help_textUsernameEnter your username	user_namezFRequired. 150 characters or fewer. Letters, digits and @/./+/-/_ only.PasswordEnter your passworduser_passwordz1Your password must contain at least 8 characters.zConfirm PasswordzEnter confirm passwordconfirm_passwordz4Enter the same password as before, for verification.c                   @      e Zd ZeZg dZdS )zUserRegistrationForm.Meta)usernameemail	password1	password2N__name__
__module____qualname__r   modelfields r0   r0   5/var/www/html/prime-uav/Admin/authentication/forms.pyMeta       r2   N)r+   r,   r-   r   
EmailField
EmailInputr'   	CharField	TextInputr&   PasswordInputr(   r)   r2   r0   r0   r0   r1   r   	   s    $$$$r   c                   @   s\   e Zd ZejdejdddddddZejd	ejd
dddddddZG dd dZ	dS )UserLoginFormr   r   r    r   r   r   r   )r   r   r   r!   r"   r#   Tr   r   r   r   c                   @   s   e Zd ZeZddgZdS )zUserLoginForm.Metar&   passwordNr*   r0   r0   r0   r1   r2      r3   r2   N)
r+   r,   r-   r   r6   r7   r&   r8   r;   r2   r0   r0   r0   r1   r9      s     "r9   c                   @   s   e Zd Zejdejdddddddd	Zejd
ejdddddddd	Zejdejdddddddd	ZG dd dZ	dS )ChangePasswordFormzOld passwordzEnter your old passwordr   )r   r   r   
      T)r   r   r   
min_lengthr   New passwordzEnter your new passwordzConfirm new passwordc                   @   r%   )zChangePasswordForm.Meta)old_passwordnew_password1new_password2N)r+   r,   r-   r   r.   r/   r0   r0   r0   r1   r2      r3   r2   N)
r+   r,   r-   r   r6   r8   rA   rB   rC   r2   r0   r0   r0   r1   r<      s
    """r<   c                   @   s>   e Zd Zejdejdddddddd	d
ZG dd dZdS )RecoverPasswordFormr   r   r   r   r   r   r   Tr   r   c                   @      e Zd ZeZdgZdS )zRecoverPasswordForm.Metar'   N)r+   r,   r-   r   modelsr/   r0   r0   r0   r1   r2   !       
r2   N)r+   r,   r-   r   r4   r5   r'   r2   r0   r0   r0   r1   rD      s    $rD   c                   @   s<   e Zd Zejdejdddddddd	ZG d
d dZdS )LockScreenFormr!   r"   r#   r   r   r   r   Tr:   c                   @   rE   )zLockScreenForm.Metar;   Nr*   r0   r0   r0   r1   r2   .   rG   r2   N)r+   r,   r-   r   r6   r8   r;   r2   r0   r0   r0   r1   rH   ,   s    "rH   c                       s~   e Zd ZdZdediZejdejddddd	d
dZ	ejdejddddd	d
dZ
 fddZdd ZdddZ  ZS )SetPasswordForm2zZ
    A form that lets a user set their password without entering the old
    password
    password_mismatch%The two password fields didn't match.r@   r"   	user_passr   znew-password)r   r   r   autocompleter   )r   r   zNew password confirmationzEnter your confirm password
user_pass2c                    s0   || _ t j|i | dtdi| jd _d S )NrJ   rK   rC   )usersuper__init___r/   error_messages)selfrO   argskwargs	__class__r0   r1   rQ   N   s   zSetPasswordForm2.__init__c                 C   s>   | j d}| j d}|r|r||krt| jd dd|S )NrB   rC   rJ   )code)cleaned_datagetr	   rS   )rT   r(   r)   r0   r0   r1   clean_new_password2U   s   z$SetPasswordForm2.clean_new_password2Tc                 C   s   | j d }| j| |r| j  ztjj| jjd}W n tjy0   tjj	| jjd}Y nw ||_
| jj|_|  | jS )NrB   )rO   )rZ   rO   set_passwordsaveUserInfoobjectsr[   r   DoesNotExistcreater;   
updated_by)rT   commitr;   userxr0   r0   r1   r^   _   s   


zSetPasswordForm2.save)T)r+   r,   r-   __doc__rR   rS   r   r6   r8   rB   rC   rQ   r\   r^   __classcell__r0   r0   rW   r1   rI   2   s2    	

rI   N)djangor   django.contrib.auth.modelsr   django.contrib.auth.formsr   r   r   r   django.utils.translationr   rR   django.core.exceptionsr	   users.modelsr   Formr9   r<   rD   rH   rI   r0   r0   r0   r1   <module>   s    