
    vg                        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
mZ ddlmZ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mZmZ ddlm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      Z" G d de      Z# G d dej                        Z$ G d dej                        Z% G d de      Z&y )!a  
forms.py

This module contains the form classes used in the application.

Each form represents a specific functionality or data input in the
application. They are responsible for validating
and processing user input data.

Classes:
- YourForm: Represents a form for handling specific data input.

Usage:
from django import forms

class YourForm(forms.Form):
    field_name = forms.CharField()

    def clean_field_name(self):
        # Custom validation logic goes here
        pass
    )Any)formsrender_to_string)	ModelForm)filtersubordinatesemployeemodelis_reportingmanager)
DepartmentJobPosition)MultipleFileField)Employee)FAQ
AttachmentCommentDepartmentManagerFAQCategoryTicket
TicketType)horilla_middlewaresc                   &    e Zd Z G d d      Zd Zy)TicketTypeFormc                       e Zd ZeZdZdgZy)TicketTypeForm.Meta__all__	is_activeN)__name__
__module____qualname__r   modelfieldsexclude     "/var/www/horilla/helpdesk/forms.pyMetar   0   s    -r#   r%   c                 &    d| i}t        d|      }|S zS
        Render the form fields as HTML table rows with Bootstrap styling.
        formzhorilla_form.htmlr   selfargskwargscontext
table_htmls        r$   as_pzTicketTypeForm.as_p5         4.%&97C
r#   N)r   r   r   r%   r/   r"   r#   r$   r   r   .   s       
r#   r   c                   2     e Zd Z G d d      Z fdZ xZS )FAQFormc                   j    e Zd ZeZdZdgZ ej                          ej                  ddd      dZ
y)	FAQForm.Metar   r   /oh-select oh-select-2 select2-hidden-accessiblezupdateTag(this)classonchangeattrs)categorytagsN)r   r   r   r   r   r    r!   r   HiddenInputSelectMultiplewidgetsr"   r#   r$   r%   r4   ?   sC    -)))+(E((N 1
r#   r%   c                     t        |   |i | t        | j                  d   j                        | j                  d   _        | j                  d   j                  j                  d       y)
        Initializes the Ticket tag form instance.
        If an instance is provided, sets the initial value for the form's .
        r<   create_new_tagzCreate new tagN)super__init__listr    choicesappend)r*   r+   r,   	__class__s      r$   rE   zFAQForm.__init__M   sZ    
 	$)&)&*4;;v+>+F+F&GF#F##**+OPr#   r   r   r   r%   rE   __classcell__rI   s   @r$   r2   r2   >   s    
 
Q Qr#   r2   c                        e Zd Z ej                   ej
                  ddi            Z G d d      Zd Z fdZ	 xZ
S )	
TicketFormtypedater9   )widgetc                   H    e Zd ZeZg dZd ej                  ddd      iZy)TicketForm.Meta)idtitleemployee_iddescriptionticket_typepriorityassigning_type	raised_ondeadlinestatusr<   r[   oh-select oh-select-2truer7   requiredr9   N	r   r   r   r   r   r    r   Selectr?   r"   r#   r$   r%   rS   Z   s/    
  7VL
r#   r%   c                 &    d| i}t        d|      }|S r'   r   r)   s        r$   r/   zTicketForm.as_po   r0   r#   c                    t        |   |i | t        dd      | j                  d<   t	        t
        j                  dd       }|j                  d      }|r|j                  }n|j                  j                  }t        |t        j                  j                  d      d	
      t        j                  j                  |j                        z  | j                  d   _        || j                  d   _        t#        |      s|j                  j%                  d      r\t'        | j                  d   j(                        | j                  d   _        | j                  d   j(                  j+                  d       t#        |      s|j                  j%                  d      r]t'        | j                  d   j(                        | j                  d   _        | j                  d   j(                  j+                  d       y y )NAttachementsF)labelra   
attachmentrequestinstanceT)r   zhelpdesk.add_ticket)perm)employee_user_idrV   zhelpdesk.add_tickettyperX   )create_new_ticket_typezCreate new ticket typebase.add_tagsr<   rB   )rD   rE   r   r    getattrr   _thread_localsgetrV   useremployee_getr   r   objectsfilterquerysetinitialr	   has_permrF   rG   rH   )r*   r+   r,   ri   rj   employeerI   s         r$   rE   zTicketForm.__init__w   s   $)&)$5 5%
L! -<<iN::j)++H||00H.MX%%,,t,<CX/
##W\\#B/CM"+ .6M"*w'7<<+@+@%,
 26M*222DKK&. KK&..55D w'7<<+@+@+Q*.t{{6/B/J/J*KDKK'KK''../ST ,Rr#   )r   r   r   r   	DateField	DateInputr\   r%   r/   rE   rK   rL   s   @r$   rN   rN   W   s>    uoeooVV<L&MNH
 
*U Ur#   rN   c                   2     e Zd Z G d d      Z fdZ xZS )TicketTagFormc                   F    e Zd ZeZdgZd ej                  ddd      iZy)TicketTagForm.Metar<   r5   zupdateTag()r6   r9   N)	r   r   r   r   r   r    r   r>   r?   r"   r#   r$   r%   r      s8    
 (E((N -
r#   r%   c                 `   t        |   |i | t        t        j                  dd      }t        |      s|j                  j                  d      r]t        | j                  d   j                        | j                  d   _
        | j                  d   j                  j                  d       yy)rA   ri   Nrn   r<   rB   )rD   rE   ro   r   rp   r	   rr   rx   rF   r    rG   rH   )r*   r+   r,   ri   rI   s       r$   rE   zTicketTagForm.__init__   s    
 	$)&)-<<iNw'7<<+@+@+Q*.t{{6/B/J/J*KDKK'KK''../ST ,Rr#   rJ   rL   s   @r$   r}   r}      s    
 
	U 	Ur#   r}   c                        e Zd Z G d d      Zy)TicketRaisedOnFormc                   H    e Zd ZeZddgZd ej                  ddd      iZy)TicketRaisedOnForm.MetarZ   r[   r^   r_   r`   r9   Nrb   r"   r#   r$   r%   r      s0    "K0 7VL
r#   r%   Nr   r   r   r%   r"   r#   r$   r   r      s    
 
r#   r   c                        e Zd Z G d d      Zy)TicketAssigneesFormc                       e Zd ZeZdgZy)TicketAssigneesForm.Metaassigned_toN)r   r   r   r   r   r    r"   r#   r$   r%   r      s    
r#   r%   Nr   r"   r#   r$   r   r      s    
 
r#   r   c                        e Zd Z G d d      Zy)FAQCategoryFormc                       e Zd ZeZdZdgZy)FAQCategoryForm.Metar   r   N)r   r   r   r   r   r    r!   r"   r#   r$   r%   r      s    -r#   r%   Nr   r"   r#   r$   r   r      s       r#   r   c                        e Zd Z G d d      Zy)CommentFormc                   B    e Zd ZeZdgZdgZd ej                         iZ	y)CommentForm.Metacommentr   rV   N)
r   r   r   r   r   r    r!   r   r=   r?   r"   r#   r$   r%   r      s0    
 - "3%"3"3"56r#   r%   Nr   r"   r#   r$   r   r      s    7 7r#   r   c            	       t    e Zd Z ej                   ej
                  ddddd      d      Z G d	 d
      Zy)AttachmentFormfileFilezform-controlTrue)namerO   r7   multipler9    )rQ   rg   c                       e Zd ZeZg dZdgZy)AttachmentForm.Meta)r   r   ticketr   N)r   r   r   r   r   r    r!   r"   r#   r$   r%   r      s    .-r#   r%   N)r   r   r   r   	FileField	TextInputr   r%   r"   r#   r$   r   r      s@    5??u'"	
 
D   r#   r   c                   2     e Zd Z G d d      Z fdZ xZS )DepartmentManagerCreateFormc                   F    e Zd ZeZddgZd ej                  ddi      iZy) DepartmentManagerCreateForm.Meta
departmentmanagerr8   zgetDepartmentEmployees($(this))r9   N)	r   r   r   r   r   r    r   rc   r?   r"   r#   r$   r%   r      s3    !	*,%,, A
r#   r%   c                     t        |   |i | d|v r_|d   j                  }|j                  j	                  dd      }t
        j                  j                  |      | j                  d   _	        y y )Nrj   rV   T)flat)id__inr   )
rD   rE   r   employeeworkinformation_setvalues_listr   rt   ru   r    rv   )r*   r+   r,   r   	employeesrI   s        r$   rE   z$DepartmentManagerCreateForm.__init__   sz    $)&)
+66J">>JJD K I /7.>.>.E.EY.E.WDKK	"+  r#   rJ   rL   s   @r$   r   r      s    	
 	
	X 	Xr#   r   N)'__doc__typingr   djangor   django.template.loaderr   
base.formsr   base.methodsr   r	   base.modelsr
   r   employee.formsr   employee.modelsr   helpdesk.modelsr   r   r   r   r   r   r   horillar   r   r2   rN   r}   r   r   r   r   r   r   r"   r#   r$   <module>r      s   .   3   M / , $   (Y  Qi Q2<U <U~UI U6
 

) 
 i  7%// 7 U__  &X) Xr#   