o
    PGf*                     @   s   d dl mZ d dlmZ d dlmZ G dd dejZG dd dejZG dd	 d	ejZ	d
Z
dZdZdZdZdZdZdZG dd dejZdS )    )forms)Usuario)Groupc                       s8  e Zd ZejejddddddZejejdddddZ	ejejdd	dddZ
ejejdd
dddZejejdddddZejejdddddZejejdddddZejejdddddZejdejdddddZejdejdddddddZG dd dZ fddZ  ZS )
PerfilFormform-controlzejemplo@ejemplo.comreadonly)classplaceholderr   attrswidgetNombrer   r	   Apellidor   date)r   typeCedulaTelefonou
   Dirección)0zSeleccione el Genero)1	Masculino)2FemeninoGenerochoicesr      Imagenfile_imagenFzshowPreview(event);)r	   idrequiredonchange
max_lengthr   c                   @   s   e Zd ZeZdZg dZdS )zPerfilForm.Meta)
email
first_name	last_nameusernamedate_of_birthnum_documentphone_numberaddressgenderimg_profile)is_superuserpassword	rpasswordN)__name__
__module____qualname__r   modelfieldsexclude r9   r9   (/var/www/vitalapp/apps/usuarios/forms.pyMeta!   s    
r;   c                    $   t  j|i | d| jd j_d S Nz%Y-%m-%dr*   super__init__r7   r   formatselfargskwargs	__class__r9   r:   r@   /      zPerfilForm.__init__)r3   r4   r5   r   
EmailField
EmailInputr&   	CharField	TextInputr'   r(   r)   	DateField	DateInputr*   NumberInputr+   r,   r-   ChoiceFieldSelectr.   
ImageField	FileInputr/   r;   r@   __classcell__r9   r9   rF   r:   r      s(     r   c                   @   sh   e Zd ZejejdddddZejejdddddZejejdddddZG dd	 d	Z	d
S )ChangePwdFormr   u   Antigua Contraseñar   r
   r   u   Nueva Contraseñau   Confirmar Contraseñac                   @      e Zd ZeZdZdS )zChangePwdForm.Meta)old_passwordnew_password1new_password2Nr3   r4   r5   r   r6   r7   r9   r9   r9   r:   r;   9       r;   N)
r3   r4   r5   r   rK   PasswordInputrW   rX   rY   r;   r9   r9   r9   r:   rU   4   s
    rU   c                       s  e Zd ZejejdddddZejejdddddZejej	dddddZ
ejejdddddZejejdd	dddZejejdd
dddZejdejddddddZejejddddddddZejejddddddddZejdejdddddZejejddddddZejejdddddZej Zej ed ejd!didd"Z!G d#d$ d$Z" fd%d&Z# fd'd(Z$ fd)d(Z$d- fd+d,	Z%  Z&S ).CreateUserFormr   zNombres Completosr   r
   r   zApellidos CompletoszCorreo Electronicou   Contraseñau   Confirma la contraseñazUsuario de Ingresor   
file_inputfilezshowPreview(event))r!   r   r#   r$   cedular   numberzcontarCaracteres(1))r   r!   r	   r   onkeyupcelularCelularzcontarCaracteres(2)r   r   r   r   z
YYYY-MM-DD)r   r   r	   zDireccion de ResidenciazSelecciona un tipo de usuarior   )querysetempty_labelr   c                   @   rV   )zCreateUserForm.Meta)r'   r&   r(   r1   	password1r)   r+   r,   r.   r*   r-   r/   tipo_usuarioNrZ   r9   r9   r9   r:   r;   R   r[   r;   c                    sD   t   }|d}|d}|r|r||kr tdd S d S d S )Nr1   rg   u   Las contraseñas no coinciden.)r?   cleangetr   ValidationError)rC   cleaned_datar1   rg   rF   r9   r:   ri   d   s   



zCreateUserForm.cleanc                    s,   t t| j|i | tj | jd _d S )Nrh   )r?   r]   r@   r   objectsallr7   re   rB   rF   r9   r:   r@   l   s   zCreateUserForm.__init__c                    r<   r=   r>   rB   rF   r9   r:   r@   q   rH   Tc                    s.   t  jdd}|| jd  |r|  |S )NF)commitr1   )r?   saveset_passwordrl   )rC   ro   userrF   r9   r:   rp   u   s
   zCreateUserForm.save)T)'r3   r4   r5   r   rK   rL   r'   r(   rI   rJ   r&   r\   r1   rg   r)   rR   rS   r/   rO   r+   r,   rP   rQ   r.   rM   rN   r*   r-   r   rm   rn   initial_groupModelChoiceFieldrh   r;   ri   r@   rp   rT   r9   r9   rF   r:   r]   >   s(      
r]   ))add_category	Adicionar)change_category	Modificar)delete_categoryEliminar)view_category
Visualizar))add_postrv   )change_postrx   )delete_postrz   )	view_postr|   ))add_relacion_cintura_caderarv   )change_relacion_cintura_caderarx   )delete_relacion_cintura_caderarz   )view_relacion_cintura_caderar|   ))add_testrockportrv   )change_testrockportrx   )delete_testrockportrz   )view_testrockportr|   ))add_propiedadesrv   )change_propiedadesrx   )delete_propiedadesrz   )view_propiedadesr|   ))add_historialrv   )change_historialrx   )delete_historialrz   )view_historialr|   ))add_usuariorv   )change_usuariorx   )delete_usuariorz   )view_usuarior|   ))	add_grouprv   )change_grouprx   )delete_grouprz   )
view_groupr|   c                
   @   s   e Zd Zejdddejddddddd	Zejedej	d
Z
ejedej	d
Zejedej	d
Zejedej	d
Zejedej	d
Zejedej	d
Zejedej	d
Zejedej	d
ZG dd dZdS )	GroupFormGrupo2   Ftextzform-control forminputsname)r   r   r	   r!   r
   )labelr%   r"   r   )r   r"   r   c                   @   rV   )zGroupForm.Meta)r   postrockportusuariosgruposantropometria	historial	programasN)r3   r4   r5   r   r6   r7   r9   r9   r9   r:   r;     r[   r;   N)r3   r4   r5   r   rK   rL   r   MultipleChoiceFieldPOST_CHOICECheckboxSelectMultipler   TestRockport_CHOICEr   Usuarios_CHOICEr   Grupos_CHOICEr   Antropometria_CHOICEr   Historial_CHOICEr   Programas_CHOICEr   r;   r9   r9   r9   r:   r      sF    
r   N)djangor   apps.usuarios.modelsr   django.contrib.auth.modelsr   	ModelFormr   rU   r]   CATAGEORY_CHOICEr   r   r   r   r   r   r   r   r9   r9   r9   r:   <module>   s    	'
>+	