HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib/python3.10/site-packages/django/forms/__pycache__/formsets.cpython-310.pyc
o

�h�R�@s�ddlmZddlmZddlmZmZddlmZddl	m
Z
mZddlm
Z
mZmZddlmZddlmZdd	lmZd
ZdZdZd
ZdZdZdZdZdZGdd�de�ZGdd�de�Z e ddddddddddfdd�Z!dd�Z"dS)�)�ValidationError)�Form)�BooleanField�IntegerField)�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�csPeZdZdZdZeed�Zeed�Zeded�Z	eded�Z
�fdd�Z�ZS)�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.
    zdjango/forms/div.html)�widgetF)�requiredrcs&t���}|�td�|�td�|S�Nr)�super�clean�
setdefault�TOTAL_FORM_COUNT�INITIAL_FORM_COUNT)�self�cleaned_data��	__class__��H/usr/local/CyberCP/lib/python3.10/site-packages/django/forms/formsets.pyr-s
zManagementForm.clean)
�__name__�
__module__�__qualname__�__doc__�
template_namerr
rrrrr�
__classcell__r%r%r#r&rs

rc@s�eZdZdZeZeZed�e	ddd�e	ddd�d�Z
d	Zd
ZdZ
dZd
d
dd
d
ed
d
fdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zedd��Zdd�Zdd �Zed!d"��Zd#d$�Zd%d&�Zed'd(��Zed)d*��Zed+d,��Z ed-d.��Z!ed/d0��Z"ed1d2��Z#e$d3d4��Z%e$d5d6��Z&e$d7d8��Z'd9d:�Z(ed;d<��Z)d=d>�Z*d?d@�Z+dAdB�Z,dCdD�Z-dEdF�Z.dGdH�Z/dIdJ�Z0dKdL�Z1dMdN�Z2edOdP��Z3edQdR��Z4dSdT�Z5d
S)Urz;
    A collection of instances of the same Form class.
    z�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.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_formszdjango/forms/formsets/div.htmlzdjango/forms/formsets/p.htmlz django/forms/formsets/table.htmlzdjango/forms/formsets/ul.htmlNzid_%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!r6r7r5r4r8r:r9rB�messages�clsr%r%r&�__init__Ss 




zBaseFormSet.__init__cC�
t|j�S)z5Yield the forms in the order they should be rendered.)�iter�forms�r!r%r%r&�__iter__p�
zBaseFormSet.__iter__cCs
|j|S)zAReturn the form at the given index, based on the rendering order.�rH�r!�indexr%r%r&�__getitem__trKzBaseFormSet.__getitem__cCrF�N)�lenrHrIr%r%r&�__len__xs
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__{szBaseFormSet.__bool__cCsN|jdurd}n|jo|jotdd�|jD��}d|jj|j||��fS)N�Unknowncss�|]}|VqdSrPr%��.0�form_errorsr%r%r&�	<genexpr>�s�z'BaseFormSet.__repr__.<locals>.<genexpr>z&<%s: bound=%s valid=%s total_forms=%s>)r;r2r<�anyr$r)�total_form_count)r!�is_validr%r%r&�__repr__�s
���zBaseFormSet.__repr__cCs`|jrt|j|j|j|jd�}|��|St|j|jt|��t	|�
�t|jt
|ji|jd�}|S)z4Return the ManagementForm instance for this FormSet.)r5r4�renderer)r5r4r8r^)r2rr6r5r4r^�
full_cleanrr[r �initial_form_count�MIN_NUM_FORM_COUNT�min_num�MAX_NUM_FORM_COUNT�max_num�r!�formr%r%r&�management_form�s(�
���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)r2�minrgr"r�absolute_maxr`�maxrb�extrard)r!�
initial_forms�total_formsr%r%r&r[�s���zBaseFormSet.total_form_countcCs*|jr	|jjtS|jrt|j�nd}|S)z=Return the number of forms that are required in this FormSet.r)r2rgr"r r8rQ)r!rlr%r%r&r`�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�rW�irIr%r&�
<listcomp>�s��z%BaseFormSet.forms.<locals>.<listcomp>)�ranger[rIr%rIr&rH�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.
        )r9�copyrMr%r%r&ro�s
zBaseFormSet.get_form_kwargscKs�|j|�|�|jd|jd�}|jr|j|d<|j|d<|jr5d|vr5z	|j||d<Wn	ty4Ynw||�	�krD||j
krDd|d<|�|�|jd	i|��}|�
||�|S)
z;Instantiate and return the i-th form instance in a formset.F)r5r4r:�use_required_attributer^r6r7r8T�empty_permittedNr%)r5�
add_prefixr:r^r2r6r7r8�
IndexErrorr`rbr@rf�
add_fields)r!rq�kwargs�defaultsrfr%r%r&rn�s*�


�
zBaseFormSet._construct_formcCs|jd|���S)z7Return a list of all the initial forms in this formset.N�rHr`rIr%r%r&rl��zBaseFormSet.initial_formscCs|j|��d�S)z5Return a list of all the extra forms in this formset.Nr|rIr%r%r&�extra_forms�r}zBaseFormSet.extra_formscCsHi|�d��|j|�d�dd|jd��}|jdi|��}|�|d�|S)N�
__prefix__TF)r5r4rvrur^r%)ror5rwr^rfry)r!r9rfr%r%r&�
empty_forms��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"�rWrfr%r%r&rrsz,BaseFormSet.cleaned_data.<locals>.<listcomp>)r\�AttributeErrorr$r'rHrIr%r%r&r"s

�zBaseFormSet.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%rLrprIr%r&rr*sz-BaseFormSet.deleted_forms.<locals>.<listcomp>)
r\�
can_delete�hasattrr��	enumeraterHr`�has_changed�_should_delete_form�append)r!rqrfr%rIr&�
deleted_formss

�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_keyJsz7BaseFormSet.ordered_forms.<locals>.compare_ordering_key)�keycsg|]	}�j|d�qS)rrLrprIr%r&rrRsz-BaseFormSet.ordered_forms.<locals>.<listcomp>)r\�	can_orderr�r$r'r�r�r�rHr`r�r�r�r�r"�ORDERING_FIELD_NAME�sort)r!rqrfr�r%rIr&�
ordered_forms,s
�
zBaseFormSet.ordered_formscCrS)Nrfr%�rDr%r%r&r3TszBaseFormSet.get_default_prefixcC�|jSrP)�deletion_widgetr�r%r%r&�get_deletion_widgetX�zBaseFormSet.get_deletion_widgetcCr�rP)�ordering_widgetr�r%r%r&�get_ordering_widget\r�zBaseFormSet.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<r_rIr%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;r_rIr%r%r&�errorsjs
zBaseFormSet.errorscCs t|���tdd�|jD��S)z<Return the number of errors across all forms in the formset.css�|]}t|�VqdSrP)rQrVr%r%r&rYss�
�z0BaseFormSet.total_error_count.<locals>.<genexpr>)rQr��sumr�rIr%r%r&�total_error_countqs
�zBaseFormSet.total_error_countcCs|j�td�S)z7Return whether or not the form was marked for deletion.F)r"�get�DELETION_FIELD_NAMErer%r%r&r�wszBaseFormSet._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�r\r�rIr%r&rr�s���z(BaseFormSet.is_valid.<locals>.<listcomp>)r2r��allrHr�)r!�forms_validr%rIr&r\{s
��zBaseFormSet.is_validc
s�g�_�jd�jd��_d}�jsdS�j��s6t�jddd�	�fdd	��jj
D��idd
�}�j�|�t�j
�D]$\}}|��sM|���krM|d7}|j
}�jrY��|�rYq;�j�|�q;zL�jrp���t�j��jksy�jjt�jkr�t�jdd
�jidd���jr����t�j�|�jkr�t�jdd
�jidd�����WdSty�}z�j|jd�jd��_WYd}~dSd}~ww)ze
        Clean all of self.data and populate self._errors and
        self._non_form_errors.
        �nonform)r:r^rNr.�field_namesz, c3s�|]	}�j�|�VqdSrP)rgrw)rW�
field_namerIr%r&rY�s
�
�
�z)BaseFormSet.full_clean.<locals>.<genexpr>)�params�coder�r/r-)r�r0)r;r:r^r<r2rgr\rrB�joinr�r�r�rHr�r`r�r��validate_maxr[rQr�rdr"rri�validate_minrbr�
error_list)r!�empty_forms_count�errorrqrfrX�er%rIr&r_�sv�
���
������������zBaseFormSet.full_cleancCrS)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.css�|]}|��VqdSrP)r�r�r%r%r&rY�s�z*BaseFormSet.has_changed.<locals>.<genexpr>)rZrIr%r%r&r��szBaseFormSet.has_changedcCs�|��}|jr/|dur!||kr!ttd�|dd|��d�|jt<nttd�d|��d�|jt<|jrM|js=|durO||krQt	td�d|�
�d�|jt<dSdSdSdS)z8A hook for adding extra fields on to each form instance.N�Orderr�F)�labelr8rr)r�rr�Delete)r`r�r�_r��fieldsr�r��can_delete_extrarr�r�)r!rfrNr`r%r%r&ry�s2�����zBaseFormSet.add_fieldscCsd|j|fS)Nz%s-%s)r4rMr%r%r&rw�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)rH�is_multipartr�rIr%r%r&r��s
zBaseFormSet.is_multipartcCs|jr	|jdjS|jjSr)rH�mediar�rIr%r%r&r�szBaseFormSet.mediacCs|jjSrP)r^�formset_template_namerIr%r%r&r+szBaseFormSet.template_namecCsd|iS)N�formsetr%rIr%r%r&�get_contextszBaseFormSet.get_context)6r'r(r)r*r	r�rr�r�rr1�template_name_div�template_name_p�template_name_table�template_name_ulrrErJrOrRrTr]rrgr[r`rHrorn�propertyrlr~r�r"r�r��classmethodr3r�r�r�r�r�r�r\r_rr�ryrwr�r�r+r�r%r%r%r&r6s�����
�
	
	






'




D	


rr�FNTc
Csn|durt}|durt}|	dur|t}	||	krtd��|||||
|||	|||p*t�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'.)rfrkr�r�r�rbrdrir�r�r^�FormSet)�DEFAULT_MIN_NUM�DEFAULT_MAX_NUM�
ValueErrorrr>r')
rfr�rkr�r�rdr�rbr�rir�r^�attrsr%r%r&rs*�
rcCr�)z8Validate every formset and return True if all are valid.cSsg|]}|���qSr%)r\)rWr�r%r%r&rrCszall_valid.<locals>.<listcomp>)r�)�formsetsr%r%r&r@r}r)#�django.core.exceptionsr�django.formsr�django.forms.fieldsrr�django.forms.renderersr�django.forms.utilsrr�django.forms.widgetsr	r
r�django.utils.functionalr�django.utils.translationr
r�r�__all__rr rarcr�r�r�r�rrrrr%r%r%r&�<module>sHe
�*