
    hR                         S SK Jr  S SKJrJr  S SKJr  S SKJr  S SK	J
r
Jr  S SKJrJrJr  S SKJr  S SKJr  S S	KJr  S
rSrSrSrSrSrSrS rSr " S S\5      r " S S\5      r \ SSSSSSSSSS4S jr!S r"g)    )ValidationError)BooleanFieldIntegerField)Form)get_default_renderer)	ErrorListRenderableFormMixin)CheckboxInputHiddenInputNumberInput)cached_property)gettext_lazy)ngettext_lazy)BaseFormSetformset_factory	all_validTOTAL_FORMSINITIAL_FORMSMIN_NUM_FORMSMAX_NUM_FORMSORDERDELETEi  c                   `   ^  \ rS rSrSr\" \S9r\" \S9r\" S\S9r	\" S\S9r
U 4S jrSrU =r$ )ManagementForm   z
Keep track of how many form instances are displayed on the page. If adding
new forms via JavaScript, you should increment the count field of this form
as well.
)widgetF)requiredr   c                 |   > [         TU ]  5       nUR                  [        S5        UR                  [        S5        U$ Nr   )superclean
setdefaultTOTAL_FORM_COUNTINITIAL_FORM_COUNT)selfcleaned_data	__class__s     G/var/www/html/env/lib/python3.13/site-packages/django/forms/formsets.pyr!   ManagementForm.clean+   s8    w} 	 0!4 2A6     )__name__
__module____qualname____firstlineno____doc__r   r   r   r   r   r   r!   __static_attributes____classcell__)r'   s   @r(   r   r      sB     k2K 4M !%DM %DM r*   r   c                      \ rS rSrSr\r\r\	" S5      \
" SSS5      \
" SSS5      S	.rS
rSrSrSrSSSSS\SS4S jrS rS rS rS rS r\S 5       rS rS r\S 5       rS rS r\S 5       r\S 5       r \S 5       r!\S 5       r"\S  5       r#\S! 5       r$\%S" 5       r&\%S# 5       r'\%S$ 5       r(S% r)\S& 5       r*S' r+S( r,S) r-S* r.S+ r/S, r0S- r1S. r2S/ r3\S0 5       r4\S1 5       r5S2 r6S3r7g)4r   4   z3
A collection of instances of the same Form class.
zManagementForm data is missing or has been tampered with. Missing fields: %(field_names)s. You may need to file a bug report if the issue persists.z#Please submit at most %(num)d form.z$Please submit at most %(num)d forms.numz$Please submit at least %(num)d form.z%Please submit at least %(num)d forms.)missing_management_formtoo_many_formstoo_few_formszdjango/forms/formsets/div.htmlzdjango/forms/formsets/p.htmlz django/forms/formsets/table.htmlzdjango/forms/formsets/ul.htmlNzid_%sc	                 (   US L=(       d    US LU l         U=(       d    U R                  5       U l        X0l        U=(       d    0 U l        U=(       d    0 U l        XPl        U=(       d    0 U l        X`l        S U l	        S U l
        U R                  U l        U R                  =(       d
    [        5       U l        0 n	[        [        U 5      R                   5       H  n
U	R#                  [%        U
S0 5      5        M!     Ub  U	R#                  U5        Xl        g )Ndefault_error_messages)is_boundget_default_prefixprefixauto_iddatafilesinitialform_kwargserror_class_errors_non_form_errorsrendererform_rendererr   reversedtype__mro__updategetattrerror_messages)r%   r?   r@   r>   r=   rA   rC   rB   rM   messagesclss              r(   __init__BaseFormSet.__init__Q   s     D(=E,=9 7 7 9JB	[b
&,"& $!]]?)=)?DJ../COOGC)A2FG 0%OON+&r*   c                 ,    [        U R                  5      $ )z5Yield the forms in the order they should be rendered.)iterformsr%   s    r(   __iter__BaseFormSet.__iter__p   s    DJJr*   c                      U R                   U   $ )zAReturn the form at the given index, based on the rendering order.)rT   r%   indexs     r(   __getitem__BaseFormSet.__getitem__t   s    zz%  r*   c                 ,    [        U R                  5      $ N)lenrT   rU   s    r(   __len__BaseFormSet.__len__x   s    4::r*   c                     g)z\
Return True since all formsets have a management form which is not
included in the length.
Tr+   rU   s    r(   __bool__BaseFormSet.__bool__{   s    
 r*   c           	      8   U R                   c  SnOLU R                  =(       a9    U R                  (       + =(       a!    [        S U R                    5       5      (       + nSU R                  R
                  < SU R                  < SU< SU R                  5       < S3	$ )NUnknownc              3   $   #    U  H  ov   M     g 7fr^   r+   .0form_errorss     r(   	<genexpr>'BaseFormSet.__repr__.<locals>.<genexpr>   s     H<KK<s   <z: bound=z valid=z total_forms=>)rD   r;   rE   anyr'   r.   total_form_count)r%   is_valids     r(   __repr__BaseFormSet.__repr__   s|    << H  I---IH4<<HHH  NN''MM!!#	
 	
r*   c                    U R                   (       aF  [        U R                  U R                  U R                  U R
                  S9nUR                  5         U$ [        U R                  U R                  [        U R                  5       [        U R                  5       [        U R                  [        U R                  0U R
                  S9nU$ )z4Return the ManagementForm instance for this FormSet.)r>   r=   rF   )r>   r=   rA   rF   )r;   r   r?   r>   r=   rF   
full_cleanr#   rp   r$   initial_form_countMIN_NUM_FORM_COUNTmin_numMAX_NUM_FORM_COUNTmax_numr%   forms     r(   management_formBaseFormSet.management_form   s     ==!		{{	D OO  "{{$d&;&;&=&(?(?(A&&	 
D r*   c                 t   U R                   (       a1  [        U R                  R                  [           U R
                  5      $ U R                  5       n[        XR                  5      U R                  -   nXR                  s=:  a  S:  a  O  OUnU$ X R                  s=:  a  S:  a  O  U$ U R                  nU$ )z1Return the total number of forms in this FormSet.r   )r;   minr}   r&   r#   absolute_maxrv   maxrx   extrarz   )r%   initial_formstotal_formss      r(   rp   BaseFormSet.total_form_count   s    ==
 $$112BCTEVEV  !335Mm\\:TZZGK ||0q0+  ||0q0 #llr*   c                     U R                   (       a  U R                  R                  [           $ U R                  (       a  [        U R                  5      OSnU$ )z=Return the number of forms that are required in this FormSet.r   )r;   r}   r&   r$   rA   r_   )r%   r   s     r(   rv   BaseFormSet.initial_form_count   s?    ==''445GHH 26C-1Mr*   c           
          [        U R                  5       5       Vs/ s H%  nU R                  " U40 U R                  U5      D6PM'     sn$ s  snf )z+Instantiate forms at first property access.)rangerp   _construct_formget_form_kwargs)r%   is     r(   rT   BaseFormSet.forms   sR     40023
3   >d&:&:1&=>3
 	
 
s   ,Ac                 6    U R                   R                  5       $ )z
Return additional keyword arguments for each individual formset form.

index will be None if the form being constructed is a new empty
form.
)rB   copyrY   s     r(   r   BaseFormSet.get_form_kwargs   s     $$&&r*   c                    U R                   U R                  U5      U R                  SU R                  S.nU R                  (       a  U R
                  US'   U R                  US'   U R                  (       a  SU;  a   U R                  U   US'   XR                  5       :  a  XR                  :  a  SUS'   UR                  U5        U R                  " S0 UD6nU R                  XA5        U$ ! [         a     Nif = f)	z;Instantiate and return the i-th form instance in a formset.F)r>   r=   rC   use_required_attributerF   r?   r@   rA   Tempty_permittedr+   )r>   
add_prefixrC   rG   r;   r?   r@   rA   
IndexErrorrv   rx   rK   r|   
add_fields)r%   r   kwargsdefaultsr|   s        r(   r   BaseFormSet._construct_form   s     ||ooa(++ ',**	
 ==#yyHV $

HW<<IV3&*ll1o#
 ''))a<<.?*.H&'yy$8$   s   =C, ,
C98C9c                 <    U R                   SU R                  5        $ )z7Return a list of all the initial forms in this formset.NrT   rv   rU   s    r(   r   BaseFormSet.initial_forms   s     zz5D33566r*   c                 <    U R                   U R                  5       S $ )z5Return a list of all the extra forms in this formset.Nr   rU   s    r(   extra_formsBaseFormSet.extra_forms   s     zz$113566r*   c                     0 U R                  S 5      EU R                  U R                  S5      SSU R                  S.EnU R                  " S0 UD6nU R                  US 5        U$ )N
__prefix__TF)r>   r=   r   r   rF   r+   )r   r>   r   rG   r|   r   )r%   rB   r|   s      r(   
empty_formBaseFormSet.empty_form  si    
""4(
||ool3#&+**
 yy';'d#r*   c                     U R                  5       (       d"  [        SU R                  R                  -  5      eU R                   Vs/ s H  oR
                  PM     sn$ s  snf )zH
Return a list of form.cleaned_data dicts for every form in self.forms.
z+'%s' object has no attribute 'cleaned_data')rq   AttributeErrorr'   r,   rT   r&   r{   s     r(   r&   BaseFormSet.cleaned_data  sP    
 }} =@W@WW  /3jj9jd!!j999s   Ac                    U R                  5       (       a  U R                  (       d  / $ [        U S5      (       d  / U l        [	        U R
                  5       Hb  u  pXR                  5       :  a  UR                  5       (       d  M/  U R                  U5      (       d  MG  U R                  R                  U5        Md     U R                   Vs/ s H  oR
                  U   PM     sn$ s  snf )z:Return a list of forms that have been marked for deletion._deleted_form_indexes)
rq   
can_deletehasattrr   	enumeraterT   rv   has_changed_should_delete_formappend)r%   r   r|   s      r(   deleted_formsBaseFormSet.deleted_forms  s     }}dooI t455)+D&$TZZ0//11$:J:J:L:L++D11..55a8 1 (,'A'AB'A!

1'ABBBs   
C%c                    U R                  5       (       a  U R                  (       d"  [        SU R                  R                  -  5      e[        U S5      (       d  / U l        [        U R                  5       H  u  pXR                  5       :  a  UR                  5       (       d  M/  U R                  (       a  U R                  U5      (       a  MX  U R                  R                  XR                  [           45        M     S nU R                  R!                  US9  U R                   Vs/ s H  oR                  US      PM     sn$ s  snf )zx
Return a list of form in the order specified by the incoming data.
Raise an AttributeError if ordering is not allowed.
z,'%s' object has no attribute 'ordered_forms'	_orderingc                     U S   c  gSU S   4$ )N   )r   r   r   r+   )ks    r(   compare_ordering_key7BaseFormSet.ordered_forms.<locals>.compare_ordering_keyJ  s    Q4<!1Q4y r*   )keyr   )rq   	can_orderr   r'   r,   r   r   r   rT   rv   r   r   r   r   r&   ORDERING_FIELD_NAMEsort)r%   r   r|   r   s       r(   ordered_formsBaseFormSet.ordered_forms,  s     }}dnn >AXAXX  t[))DN$TZZ0//11$:J:J:L:L??t'?'?'E'E%%q*;*;<O*P&QR 1!
 NN$89 +/..9.Q

1Q4 .999s   )Ec                     g)Nr|   r+   rO   s    r(   r<   BaseFormSet.get_default_prefixT  s    r*   c                     U R                   $ r^   )deletion_widgetr   s    r(   get_deletion_widgetBaseFormSet.get_deletion_widgetX      """r*   c                     U R                   $ r^   )ordering_widgetr   s    r(   get_ordering_widgetBaseFormSet.get_ordering_widget\  r   r*   c                 T    U R                   c  U R                  5         U R                   $ )z
Return an ErrorList of errors that aren't associated with a particular
form -- i.e., from formset.clean(). Return an empty ErrorList if there
are none.
)rE   ru   rU   s    r(   non_form_errorsBaseFormSet.non_form_errors`  s&       (OO$$$r*   c                 T    U R                   c  U R                  5         U R                   $ )z:Return a list of form.errors for every form in self.forms.)rD   ru   rU   s    r(   errorsBaseFormSet.errorsj  s"     <<OO||r*   c                 n    [        U R                  5       5      [        S U R                   5       5      -   $ )z<Return the number of errors across all forms in the formset.c              3   8   #    U  H  n[        U5      v   M     g 7fr^   )r_   rh   s     r(   rk   0BaseFormSet.total_error_count.<locals>.<genexpr>s  s      1
0;Cs   )r_   r   sumr   rU   s    r(   total_error_countBaseFormSet.total_error_countq  s5    4'')*S 1
041
 .
 
 	
r*   c                 B    UR                   R                  [        S5      $ )z7Return whether or not the form was marked for deletion.F)r&   getDELETION_FIELD_NAMEr{   s     r(   r   BaseFormSet._should_delete_formw  s      $$%8%@@r*   c                 >   U R                   (       d  gU R                    [        U R                   Vs/ s H<  nU R                  (       a  U R                  U5      (       a  M,  UR                  5       PM>     sn5      nU=(       a    U R                  5       (       + $ s  snf )z1Return True if every form in self.forms is valid.F)r;   r   allrT   r   r   rq   r   )r%   r|   forms_valids      r(   rq   BaseFormSet.is_valid{  sz    }}  !JJ&DD,D,DT,J  &
 94#7#7#999s   +B!Bc                 `  ^  / T l         T R                  ST R                  S9T l        SnT R                  (       d  gT R
                  R                  5       (       db  [        T R                  S   SSR                  U 4S jT R
                  R                   5       5      0SS	9nT R                  R                  U5        [        T R                  5       H  u  p4UR                  5       (       d  UT R                  5       :  a  US
-  nUR                  nT R                   (       a  T R#                  U5      (       a  Mh  T R                   R                  U5        M      T R$                  (       a4  T R'                  5       [)        T R*                  5      -
  T R,                  :  d+  T R
                  R.                  [0           T R2                  :  a&  [        T R                  S   ST R,                  0-  SS9eT R4                  (       a]  T R'                  5       [)        T R*                  5      -
  U-
  T R6                  :  a&  [        T R                  S   ST R6                  0-  SS9eT R9                  5         g! [         a4  nT R                  UR:                  ST R                  S9T l         SnAgSnAff = f)zM
Clean all of self.data and populate self._errors and
self._non_form_errors.
nonform)rC   rF   r   Nr6   field_namesz, c              3   Z   >#    U  H   nTR                   R                  U5      v   M"     g 7fr^   )r}   r   )ri   
field_namer%   s     r(   rk   )BaseFormSet.full_clean.<locals>.<genexpr>  s,      -*EJ ,,77
CC*Es   (+)paramscoder   r7   r5   )r   r8   )rD   rC   rF   rE   r;   r}   rq   r   rM   joinr   r   r   rT   r   rv   r   r   validate_maxrp   r_   r   rz   r&   r#   r   validate_minrx   r!   
error_list)r%   empty_forms_counterrorr   r|   rj   es   `      r(   ru   BaseFormSet.full_clean  sf   
  $ 0 0!DMM !1 !
 }}##,,..###$=>!499 -*.*>*>*E*E- $ /	E !!((/ ,GA##%%!t/F/F/H*H!Q&! ++K4#;#;D#A#ALL, -	!!))+c$2D2D.EET%%22 !!" &''(89UDLL<QQ) 
 !!))+d(()*#$ ,,
 &''8E4<<;PP( 
 JJL 	$($4$4% %5 %D!!	s   DI/ /
J-9*J((J-c                     g)z
Hook for doing any extra formset-wide cleaning after Form.clean() has
been called on every form. Any ValidationError raised by this method
will not be associated with a particular form; it will be accessible
via formset.non_form_errors()
Nr+   rU   s    r(   r!   BaseFormSet.clean  s     	r*   c                 &    [        S U  5       5      $ )z5Return True if data in any form differs from initial.c              3   @   #    U  H  oR                  5       v   M     g 7fr^   )r   )ri   r|   s     r(   rk   *BaseFormSet.has_changed.<locals>.<genexpr>  s     7$$##%%$s   )ro   rU   s    r(   r   BaseFormSet.has_changed  s    7$777r*   c                    U R                  5       nU R                  (       as  Ub=  X#:  a8  [        [        S5      US-   SU R	                  5       S9UR
                  [        '   O3[        [        S5      SU R	                  5       S9UR
                  [        '   U R                  (       aO  U R                  (       d  Ub:  X#:  a4  [        [        S5      SU R                  5       S9UR
                  [        '   gggg)z8A hook for adding extra fields on to each form instance.NOrderr   F)labelrA   r   r   )r   r   r   Delete)rv   r   r   _r   fieldsr   r   can_delete_extrar   r   r   )r%   r|   rZ   rv   s       r(   r   BaseFormSet.add_fields  s    !446>> U%?3?G*!AI"335	4/0 4@G*"3354/0
 ??!!e&7E<V/;k//10DKK+, =W&7 r*   c                 (    U R                   < SU< 3$ )N-)r=   rY   s     r(   r   BaseFormSet.add_prefix  s    ++u--r*   c                     U R                   (       a  U R                   S   R                  5       $ U R                  R                  5       $ )z^
Return True if the formset needs to be multipart, i.e. it
has FileInput, or False otherwise.
r   )rT   is_multipartr   rU   s    r(   r  BaseFormSet.is_multipart  s5    
 ::::a=--//??//11r*   c                     U R                   (       a  U R                   S   R                  $ U R                  R                  $ r   )rT   mediar   rU   s    r(   r  BaseFormSet.media  s/     ::::a=&&&??(((r*   c                 .    U R                   R                  $ r^   )rF   formset_template_namerU   s    r(   template_nameBaseFormSet.template_name  s    }}222r*   c                 
    SU 0$ )Nformsetr+   rU   s    r(   get_contextBaseFormSet.get_context  s    4  r*   )r   rD   rE   r   r>   r?   rC   rM   r@   rB   rG   rA   r;   r=   rF   )8r,   r-   r.   r/   r0   r
   r   r   r   r   r   r:   template_name_divtemplate_name_ptemplate_name_tabletemplate_name_ulr   rP   rV   r[   r`   rc   rr   r   r}   rp   rv   rT   r   r   propertyr   r   r   r&   r   r   classmethodr<   r   r   r   r   r   r   rq   ru   r!   r   r   r   r  r  r  r  r1   r+   r*   r(   r   r   4   s	    $O!O#$X$
 (12

 '23
" 94O<6 '> !
   0* 
 
': 7 7 7 7   : : C C  %: %:N   # # # #%  
A:"BH86.2 ) ) 3 3!r*   r   r   FNTc                     Uc  [         nUc  [        nU	c	  U[        -   n	XY:  a  [        S5      eU UUUU
UUU	UUUS.n[        U R                  S-   U4U5      $ )z*Return a FormSet for the given form class.z5'absolute_max' must be greater or equal to 'max_num'.)r|   r   r   r   r   rx   rz   r   r   r   rF   FormSet)DEFAULT_MIN_NUMDEFAULT_MAX_NUM
ValueErrorrI   r,   )r|   r  r   r   r   rz   r   rx   r   r   r   rF   attrss                r(   r   r     s     !! 0PQQ ,$$$E 	)G:u==r*   c                 ^    [        U  Vs/ s H  oR                  5       PM     sn5      $ s  snf )z8Validate every formset and return True if all are valid.)r   rq   )formsetsr  s     r(   r   r   @  s(     (;(w  "(;<<;s   *)#django.core.exceptionsr   django.forms.fieldsr   r   django.forms.formsr   django.forms.renderersr   django.forms.utilsr   r	   django.forms.widgetsr
   r   r   django.utils.functionalr   django.utils.translationr   r   r   __all__r#   r$   rw   ry   r   r   r  r  r   r   r   r   r+   r*   r(   <module>r%     s    2 : # 7 = H H 3 6 2
9 ! $ $ $     T 0_!% _!H 
'>T=r*   