o
    ayh{                     @   s   d dl mZ d dlmZmZmZ d dlmZm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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Group
Permission)UserCreationFormUserChangeFormc                   @   s>   e Zd ZejddZejej	 dej
dZG dd dZdS )UserFormTrequiredFquerysetr
   widgetc                   @      e Zd ZeZg dZdS )zUserForm.Meta)usernameemail	password1	password2groupsN__name__
__module____qualname__r   modelfields r   r   &/var/www/html/kangema/authapp/forms.pyMeta
       r   N)r   r   r   r   
EmailFieldr   ModelMultipleChoiceFieldr   objectsallCheckboxSelectMultipler   r   r   r   r   r   r      s    r   c                   @   sB   e Zd ZdZejddZejej	
 dejdZG dd dZdS )EditUserFormNTr	   Fr   c                   @   r   )zEditUserForm.Meta)r   r   r   Nr   r   r   r   r   r      r   r   )r   r   r   passwordr   r   r   r   r   r    r!   r"   r   r   r   r   r   r   r#      s
    r#   c                   @      e Zd ZG dd dZdS )	GroupFormc                   @      e Zd ZeZdgZdS )zGroupForm.MetanameNr   r   r   r   r   r   r   r   r   r   r          
r   Nr   r   r   r   r   r   r   r   r&          r&   c                   @   r%   )CustomUserCreationFormc                   @   r   )zCustomUserCreationForm.Meta)r   r   
first_name	last_namer   r   r   Nr   r   r   r   r   r       r   r   Nr+   r   r   r   r   r-      r,   r-   c                   @   r%   )CustomUserChangeFormc                   @   r   )zCustomUserChangeForm.Meta)r   r   r.   r/   r   Nr   r   r   r   r   r   &   r   r   Nr+   r   r   r   r   r0   %   r,   r0   c                   @   s2   e Zd Zejej ejddZ	G dd dZ
dS )GroupPermissionFormF)r   r   r
   c                   @   r'   )zGroupPermissionForm.MetapermissionsNr)   r   r   r   r   r   2   r*   r   N)r   r   r   r   r   r   r    r!   r"   r2   r   r   r   r   r   r1   +   s    r1   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Z	ejdejddddddZ
G dd dZdd Zd fdd	Z  ZS )EditProfileFormzProfile Pictureform-controlzimage/*)classacceptattrsFz2Upload a profile picture (JPG, PNG, GIF - Max 2MB))labelr   r
   	help_textzNew PasswordzEnter new passwordr5   placeholderz5Leave blank if you don't want to change your passwordzConfirm New PasswordzConfirm new password)r9   r   r
   c                   @   sN   e Zd ZeZg dZejddddejddddejdddddZ	dS )	zEditProfileForm.Meta)r.   r/   r   r4   zEnter first namer;   r7   zEnter last namezEnter email addressN)
r   r   r   r   r   r   r   	TextInput
EmailInputwidgetsr   r   r   r   r   J   s    
r   c                 C   s^   | j d}| j d}|r|r||krtd|S |r$|s$td|r-|s-td|S )Nnew_password1new_password2zPasswords don't matchz Please confirm your new passwordzPlease enter your new password)cleaned_datagetr   ValidationError)selfr   r   r   r   r   clean_new_password2S   s   


z#EditProfileForm.clean_new_password2Tc                    s8   t  jdd}| jd}|r|| |r|  |S )NF)commitr@   )supersaverB   rC   set_password)rE   rG   usernew_password	__class__r   r   rI   a   s   
zEditProfileForm.save)T)r   r   r   r   
ImageField	FileInputprofile_picture	CharFieldPasswordInputr@   rA   r   rF   rI   __classcell__r   r   rM   r   r3   7   s*    	r3   N)djangor   django.contrib.auth.modelsr   r   r   django.contrib.auth.formsr   r   r   r#   	ModelFormr&   r-   r0   r1   r3   r   r   r   r   <module>   s    	
