o
    hY                     @   sr   d dl mZ d dlmZ d dlmZ d dlmZmZm	Z	m
Z
mZ ddlmZ G dd deZG d	d
 d
ejZdS )    )forms)UserCreationForm)
FormHelper)LayoutRowColumnSubmitHTML   )Userc                       s~   e Zd ZdZejdddZejdddZejddZ	ejddddZ
ejd	dd
dZG dd dZ fddZdd Z  ZS )UserRegistrationFormz(User registration form with crispy forms   T)
max_lengthrequired)r      z>Enter your phone number with country code (e.g., 260971234567))r   r   	help_text   z"Enter your ICTAZ membership numberc                   @      e Zd ZeZdZdS )zUserRegistrationForm.Meta)username
first_name	last_nameemailphone_numbermembership_number	password1	password2N__name__
__module____qualname__r   modelfields r"   r"   */var/www/html/ictaz-jobs/accounts/forms.pyMeta       r$   c              
      s   t  j|i | | j D ]\}}|jjd|jd qt | _	t
ttdddtdddddttdddtd	ddddttd
ddtdddddttdddtdddddtdddd| j	_d S )Nz form-control form-control-modern)classplaceholderr   zform-group col-md-6 mb-3	css_classr   form-rowr   r   r   r   r   r   submitRegisterz!btn btn-primary btn-lg w-100 mt-3)super__init__r!   itemswidgetattrsupdatelabelr   helperr   r   r   r   layout)selfargskwargs
field_namefield	__class__r"   r#   r.      s<   








zUserRegistrationForm.__init__c                 C   s8   | j d }|dstdt|dk rtd|S )Nr   260z7Phone number must start with 260 (Zambia country code).   z?Please enter a valid Zambian phone number (e.g., 260971234567).)cleaned_data
startswithr   ValidationErrorlen)r6   phoner"   r"   r#   clean_phone_number@   s   



z'UserRegistrationForm.clean_phone_number)r   r   r   __doc__r   	CharFieldr   r   
EmailFieldr   r   r   r$   r.   rD   __classcell__r"   r"   r;   r#   r      s$    #r   c                       s.   e Zd ZdZG dd dZ fddZ  ZS )UserProfileFormzUser profile update formc                   @   r   )zUserProfileForm.Meta)r   r   r   r   r   Nr   r"   r"   r"   r#   r$   L   r%   r$   c              	      s   t  j|i | t | _tttdddtdddddttdddtdddddttdddtd	ddddtd
ddd| j_d S )Nr   zform-group col-md-6 mb-0r(   r   r*   r   r   r   organizationr+   zUpdate Profilezbtn btn-primary)	r-   r.   r   r4   r   r   r   r   r5   )r6   r7   r8   r;   r"   r#   r.   Q   s(   





zUserProfileForm.__init__)r   r   r   rE   r$   r.   rH   r"   r"   r;   r#   rI   I   s    rI   N)djangor   django.contrib.auth.formsr   crispy_forms.helperr   crispy_forms.layoutr   r   r   r   r	   modelsr   r   	ModelFormrI   r"   r"   r"   r#   <module>   s    A