https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/django/forms/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/django/forms/__pycache__/formsets.cpython-310.pyc
o

3�a�M�
@s�ddlmZddlmZddlmZmZddlmZddl	m
Z
mZddlm
Z
ddlmZddlmZdd	lmZmZd
ZdZdZd
ZdZdZdZdZdZGdd�de�ZeGdd�d��Z e dddddddddf
dd�Z!dd�Z"dS)�)�ValidationError)�Form)�BooleanField�IntegerField)�	ErrorList)�HiddenInput�NumberInput)�cached_property)�	html_safe)�	mark_safe)�gettext_lazy�ngettext)�BaseFormSet�formset_factory�	all_valid�TOTAL_FORMS�
INITIAL_FORMS�
MIN_NUM_FORMS�
MAX_NUM_FORMS�ORDER�DELETEi�cs,eZdZdZ�fdd�Z�fdd�Z�ZS)�ManagementFormz�
    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.
    csZttd�|jt<ttd�|jt<tdtd�|jt<tdtd�|jt<t�j|i|��dS)N)�widgetF)�requiredr)	rr�base_fields�TOTAL_FORM_COUNT�INITIAL_FORM_COUNT�MIN_NUM_FORM_COUNT�MAX_NUM_FORM_COUNT�super�__init__)�self�args�kwargs��	__class__��7/usr/lib/python3/dist-packages/django/forms/formsets.pyr "s
zManagementForm.__init__cs&t���}|�td�|�td�|S�Nr)r�clean�
setdefaultrr)r!�cleaned_datar$r&r'r),s
zManagementForm.clean)�__name__�
__module__�__qualname__�__doc__r r)�
__classcell__r&r&r$r'rs
rc@szeZdZdZeZded�iZdddddeddfdd�Z	dd	�Z
d
d�Zdd
�Zdd�Z
dd�Zedd��Zdd�Zdd�Zedd��Zdd�Zdd�Zedd��Zed d!��Zed"d#��Zed$d%��Zed&d'��Zed(d)��Zed*d+��Zed,d-��Zd.d/�Z ed0d1��Z!d2d3�Z"d4d5�Z#d6d7�Z$d8d9�Z%d:d;�Z&d<d=�Z'd>d?�Z(d@dA�Z)dBdC�Z*edDdE��Z+dFdG�Z,dHdI�Z-dJdK�Z.dS)Lrz;
    A collection of instances of the same Form class.
    �missing_management_formz�ManagementForm 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.Nzid_%sc	Cs�|dup|du|_|p|��|_||_|pi|_|pi|_||_|p#i|_||_d|_	d|_
i}	tt|�j
�D]}
|	�t|
di��q7|durL|	�|�|	|_dS)N�default_error_messages)�is_bound�get_default_prefix�prefix�auto_id�data�files�initial�form_kwargs�error_class�_errors�_non_form_errors�reversed�type�__mro__�update�getattr�error_messages)r!r7r8r6r5r9r;r:rC�messages�clsr&r&r'r Bs 




zBaseFormSet.__init__cCs|��S�N��as_table�r!r&r&r'�__str__WszBaseFormSet.__str__cC�
t|j�S)z5Yield the forms in the order they should be rendered.)�iter�formsrIr&r&r'�__iter__Z�
zBaseFormSet.__iter__cCs
|j|S)zAReturn the form at the given index, based on the rendering order.�rM�r!�indexr&r&r'�__getitem__^rOzBaseFormSet.__getitem__cCrKrF)�lenrMrIr&r&r'�__len__bs
zBaseFormSet.__len__cC�dS)zt
        Return True since all formsets have a management form which is not
        included in the length.
        Tr&rIr&r&r'�__bool__eszBaseFormSet.__bool__cCsX|jrt|j|j|jd�}|��|St|j|jt|��t|�	�t
|jt|j
id�}|S)z4Return the ManagementForm instance for this FormSet.)r6r5)r6r5r9)r3rr7r6r5�
full_cleanr�total_form_countr�initial_form_countr�min_numr�max_num�r!�formr&r&r'�management_formls
��zBaseFormSet.management_formcCsx|jr
t|jjt|j�S|��}t||j�|j	}||j
kr(dkr)|}|S||j
kr4dkr:n|S|j
}|S)z1Return the total number of forms in this FormSet.r)r3�minr_r+r�absolute_maxrZ�maxr[�extrar\)r!�
initial_forms�total_formsr&r&r'rY{s��zBaseFormSet.total_form_countcCs*|jr	|jjtS|jrt|j�nd}|S)z=Return the number of forms that are required in this FormSet.r)r3r_r+rr9rT)r!rdr&r&r'rZ�szBaseFormSet.initial_form_countcs�fdd�t����D�S)z+Instantiate forms at first property access.cs$g|]}�j|fi��|����qSr&)�_construct_form�get_form_kwargs��.0�irIr&r'�
<listcomp>�s��z%BaseFormSet.forms.<locals>.<listcomp>)�rangerYrIr&rIr'rM�s

�zBaseFormSet.formscCs
|j��S)z�
        Return additional keyword arguments for each individual formset form.

        index will be None if the form being constructed is a new empty
        form.
        )r:�copyrQr&r&r'rg�s
zBaseFormSet.get_form_kwargscKs�|j|�|�|jdd�}|jr|j|d<|j|d<|jr3d|vr3z	|j||d<Wn	ty2Ynw||��krB||j	krBd|d<|�
|�|jd	i|��}|�||�|S)
z;Instantiate and return the i-th form instance in a formset.F)r6r5r;�use_required_attributer7r8r9T�empty_permittedNr&)
r6�
add_prefixr;r3r7r8r9�
IndexErrorrZr[rAr^�
add_fields)r!rjr#�defaultsr^r&r&r'rf�s(�	

�
zBaseFormSet._construct_formcCs|jd|���S)z7Return a list of all the initial forms in this formset.N�rMrZrIr&r&r'rd��zBaseFormSet.initial_formscCs|j|��d�S)z5Return a list of all the extra forms in this formset.NrtrIr&r&r'�extra_forms�ruzBaseFormSet.extra_formscCs8|jd|j|�d�ddd�|�d���}|�|d�|S)N�
__prefix__TF)r6r5rornr&)r^r6rprgrrr]r&r&r'�
empty_form�s��zBaseFormSet.empty_formcCs(|��std|jj��dd�|jD�S)zX
        Return a list of form.cleaned_data dicts for every form in self.forms.
        z+'%s' object has no attribute 'cleaned_data'cSsg|]}|j�qSr&)r+�rir^r&r&r'rk�sz,BaseFormSet.cleaned_data.<locals>.<listcomp>)�is_valid�AttributeErrorr%r,rMrIr&r&r'r+�szBaseFormSet.cleaned_datacsv���r�js	gSt�d�s1g�_t�j�D]\}}|���kr%|��s%q��|�r0�j�	|�q�fdd��jD�S)z:Return a list of forms that have been marked for deletion.�_deleted_form_indexescsg|]}�j|�qSr&rPrhrIr&r'rk�sz-BaseFormSet.deleted_forms.<locals>.<listcomp>)
rz�
can_delete�hasattrr|�	enumeraterMrZ�has_changed�_should_delete_form�append)r!rjr^r&rIr'�
deleted_forms�s

�zBaseFormSet.deleted_formscs����r�jstd�jj��t�d�sKg�_t�j�D]#\}}|��	�kr+|�
�s+q�jr4��|�r4q�j�
||jtf�qdd�}�jj|d��fdd��jD�S)z�
        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'�	_orderingcSs|ddurdSd|dfS)N�)r�rrr&)�kr&r&r'�compare_ordering_keysz7BaseFormSet.ordered_forms.<locals>.compare_ordering_key)�keycsg|]	}�j|d�qS)rrPrhrIr&r'rksz-BaseFormSet.ordered_forms.<locals>.<listcomp>)rz�	can_orderr{r%r,r~r�rrMrZr�r}r�r�r+�ORDERING_FIELD_NAME�sort)r!rjr^r�r&rIr'�
ordered_forms�s
zBaseFormSet.ordered_formscCrV)Nr^r&�rEr&r&r'r4szBaseFormSet.get_default_prefixcCs|jSrF)�ordering_widgetr�r&r&r'�get_ordering_widgetszBaseFormSet.get_ordering_widgetcC�|jdur	|��|jS)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.
        N)r=rXrIr&r&r'�non_form_errors"s
zBaseFormSet.non_form_errorscCr�)z:Return a list of form.errors for every form in self.forms.N)r<rXrIr&r&r'�errors,s
zBaseFormSet.errorscCs t|���tdd�|jD��S)z<Return the number of errors across all forms in the formset.css�|]}t|�VqdSrF)rT)ri�form_errorsr&r&r'�	<genexpr>6��z0BaseFormSet.total_error_count.<locals>.<genexpr>)rTr��sumr�rIr&r&r'�total_error_count3s
�zBaseFormSet.total_error_countcCs|j�td�S)z7Return whether or not the form was marked for deletion.F)r+�get�DELETION_FIELD_NAMEr]r&r&r'r�8szBaseFormSet._should_delete_formcs6�jsdS�jt�fdd��jD��}|o���S)z1Return True if every form in self.forms is valid.Fcs$g|]}�jr��|�s|���qSr&)r}r�rzryrIr&r'rkDs���z(BaseFormSet.is_valid.<locals>.<listcomp>)r3r��allrMr�)r!�forms_validr&rIr'rz<s�zBaseFormSet.is_validc
s�g�_����_d}�jsdS�j��s2t�jddd��fdd��jj	D��idd�}�j�
|�t�j�D]$\}}|�
�sI|���krI|d	7}|j	}�jrU��|�rUq7�j�
|�q7zL�jrl���t�j��jksu�jjt�jkr�ttd
d�j��jdd
���jr����t�j�|�jkr�ttdd�j��jdd
�����WdSty�}z��|j��_WYd}~dSd}~ww)ze
        Clean all of self.data and populate self._errors and
        self._non_form_errors.
        rNr1�field_namesz, c3s�|]	}�j�|�VqdSrF)r_rp)ri�
field_namerIr&r'r�Zs
�
�
�z)BaseFormSet.full_clean.<locals>.<genexpr>)�params�coder�zPlease submit at most %d form.zPlease submit at most %d forms.�too_many_forms)r�zPlease submit at least %d form.z Please submit at least %d forms.�
too_few_forms)r<r;r=r3r_rzrrC�joinr�r�rrMr�rZr}r��validate_maxrYrTr�r\r+rrar
�validate_minr[r)�
error_list)r!�empty_forms_count�errorrjr^r��er&rIr'rXJsb

���
��������zBaseFormSet.full_cleancCrV)a
        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&rIr&r&r'r)�szBaseFormSet.cleancC�tdd�|D��S)z5Return True if data in any form differs from initial.cs��|]}|��VqdSrF)r�ryr&r&r'r��r�z*BaseFormSet.has_changed.<locals>.<genexpr>)�anyrIr&r&r'r��szBaseFormSet.has_changedcCs�|��}|jr/|dur!||kr!ttd�|dd|��d�|jt<nttd�d|��d�|jt<|jrF|js9||krHt	td�dd�|jt
<dSdSdS)	z8A hook for adding extra fields on to each form instance.N�Orderr�F)�labelr9rr)r�rr�Delete)r�r)rZr�r�_r��fieldsr�r}�can_delete_extrarr�)r!r^rRrZr&r&r'rr�s"���zBaseFormSet.add_fieldscCsd|j|fS)Nz%s-%s)r5rQr&r&r'rp�szBaseFormSet.add_prefixcCs|jr
|jd��S|j��S)zv
        Return True if the formset needs to be multipart, i.e. it
        has FileInput, or False otherwise.
        r)rM�is_multipartrxrIr&r&r'r��s
zBaseFormSet.is_multipartcCs|jr	|jdjS|jjSr()rM�mediarxrIr&r&r'r��szBaseFormSet.mediacC�*d�dd�|D��}tt|j�d|�S)zLReturn this formset rendered as HTML <tr>s -- excluding the <table></table>.� csr�rFrGryr&r&r'r��r�z'BaseFormSet.as_table.<locals>.<genexpr>�
�r�r�strr_�r!rMr&r&r'rH�szBaseFormSet.as_tablecCr�)z*Return this formset rendered as HTML <p>s.r�csr�rF)�as_pryr&r&r'r��r�z#BaseFormSet.as_p.<locals>.<genexpr>r�r�r�r&r&r'r���zBaseFormSet.as_pcCr�)z+Return this formset rendered as HTML <li>s.r�csr�rF)�as_ulryr&r&r'r��r�z$BaseFormSet.as_ul.<locals>.<genexpr>r�r�r�r&r&r'r��r�zBaseFormSet.as_ul)/r,r-r.r/rr�r�r2rr rJrNrSrUrWr	r_rYrZrMrgrf�propertyrdrvrxr+r�r��classmethodr4r�r�r�r�r�rzrXr)r�rrrpr�r�rHr�r�r&r&r&r'r5sr��
�
	
	





$



7	

rr�FNTcCsf|durt}|durt}|	dur|t}	||	krtd��|||||
|||	||d�
}t|jd|f|�S)z*Return a FormSet for the given form class.Nz5'absolute_max' must be greater or equal to 'max_num'.)
r^rcr�r}r�r[r\rar�r��FormSet)�DEFAULT_MIN_NUM�DEFAULT_MAX_NUM�
ValueErrorr?r,)r^�formsetrcr�r}r\r�r[r�rar��attrsr&r&r'r�s,��rcCr�)z8Validate every formset and return True if all are valid.cSsg|]}|���qSr&)rz)rir�r&r&r'rk�szall_valid.<locals>.<listcomp>)r�)�formsetsr&r&r'r�rur)#�django.core.exceptionsr�django.formsr�django.forms.fieldsrr�django.forms.utilsr�django.forms.widgetsrr�django.utils.functionalr	�django.utils.htmlr
�django.utils.safestringr�django.utils.translationrr�r
�__all__rrrrr�r�r�r�rrrrr&r&r&r'�<module>s<
�!

https://t.me/RX1948 - 2025