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__/forms.cpython-310.pyc
o

�h P�@s�dZddlZddlZddlZddlmZmZddlmZm	Z	ddl
mZmZm
Z
ddlmZmZddlmZddlmZdd	lmZdd
lmZddlmZmZddlmZd
dlm Z dZ!Gdd�de�Z"Gdd�de
�Z#Gdd�de#e"d�Z$dS)z
Form classes
�N)�NON_FIELD_ERRORS�ValidationError)�Field�	FileField)�	ErrorDict�	ErrorList�RenderableFormMixin)�Media�MediaDefiningClass)�MultiValueDict)�RemovedInDjango50Warning)�cached_property)�conditional_escape)�
SafeString�	mark_safe)�gettext�)�get_default_renderer)�BaseForm�Formcs eZdZdZ�fdd�Z�ZS)�DeclarativeFieldsMetaclassz,Collect Fields declared on the base classes.c	s��fdd�t����D��d<t��|||��}i}t|j�D]$}t|d�r,|�|j�|j	��D]\}}|durB||vrB|�
|�q1q||_||_|S)Ncs&i|]\}}t|t�r|��|��qS�)�
isinstancer�pop)�.0�key�value��attrsr�E/usr/local/CyberCP/lib/python3.10/site-packages/django/forms/forms.py�
<dictcomp>s�
�z6DeclarativeFieldsMetaclass.__new__.<locals>.<dictcomp>�declared_fields)�list�items�super�__new__�reversed�__mro__�hasattr�updater!�__dict__r�base_fields)	�mcs�name�basesr�	new_classr!�base�attrr��	__class__rrr%s 


�

��z"DeclarativeFieldsMetaclass.__new__)�__name__�
__module__�__qualname__�__doc__r%�
__classcell__rrr2rrsrc@sFeZdZdZdZdZdZdZdZdZ	dZ
dZdZddd	dde
dd
dddfdd�Zd
d�Zdd�Zdd�Zdd�Zdd�Zedd��Zdd�Zdd�Zdd�Zdd �Zd!d"�Zed#d$��Zd%d&�Zd'd(�Zd)d*�ZdEd+d,�Zd-d.�Z d/d0�Z!d1d2�Z"d3d4�Z#d5d6�Z$d7d8�Z%e&d9d:��Z'ed;d<��Z(d=d>�Z)d?d@�Z*dAdB�Z+dCdD�Z,dS)Frz�
    The main implementation of all the Form logic. Note that this class is
    different than Form. See the comments by the Form class for more info. Any
    improvements to the form API should be made to this class, not to the Form
    class.
    NTzdjango/forms/div.htmlzdjango/forms/p.htmlzdjango/forms/table.htmlzdjango/forms/ul.htmlzdjango/forms/label.htmlzid_%sFcCs
|dup|du|_|durt�n||_|durt�n||_||_|dur'||_|p*i|_||_|dur5|ntd�|_	||_
d|_t�
|j�|_i|_|�|	durS|jn|	�|
dur]|
|_|j
rg|jrgtd��|dur�|jdurtt�}n|j}t|jt�r�|�}||_dS)N�:zNThe empty_permitted and use_required_attribute arguments may not both be True.)�is_boundr�data�files�auto_id�prefix�initial�error_class�_�label_suffix�empty_permitted�_errors�copy�deepcopyr+�fields�_bound_fields_cache�order_fields�field_order�use_required_attribute�
ValueError�default_rendererrr�type�renderer)�selfr;r<r=r>r?r@rBrCrJrKrOrrr�__init__Ks6
�

zBaseForm.__init__c	CsV|durdSi}|D]}z
|j�|�||<Wq
tyYq
w|�|j�||_dS)a�
        Rearrange the fields according to field_order.

        field_order is a list of field names specifying the order. Append fields
        not included in the list in the default order for backward compatibility
        with subclasses not overriding field_order. If field_order is None,
        keep all fields in the order defined in the class. Ignore unknown
        fields in field_order to allow disabling fields in form subclasses
        without redefining ordering.
        N)rGr�KeyErrorr))rPrJrGrrrrrI�s�
zBaseForm.order_fieldscCs>|jdurd}n|jo|j}d|jj|j|d�|j�d�S)N�Unknownz?<%(cls)s bound=%(bound)s, valid=%(valid)s, fields=(%(fields)s)>�;)�cls�bound�validrG)rDr:r3r4�joinrG)rP�is_validrrr�__repr__�s

�zBaseForm.__repr__ccs �|jD]	}|||fVqdS)z8Yield (name, bf) pairs, where bf is a BoundField object.N�rG�rPr-rrr�_bound_items�s�
�zBaseForm._bound_itemsccs�|jD]}||VqdS)z.Yield the form's fields as BoundField objects.Nr[r\rrr�__iter__�s�
�zBaseForm.__iter__cCsfz|j|}Wntytd||jjd�t|j��f��w||jvr.|�||�|j|<|j|S)z(Return a BoundField with the given name.z,Key '%s' not found in '%s'. Choices are: %s.z, )rGrRr3r4rX�sortedrH�get_bound_field)rPr-�fieldrrr�__getitem__�s����
	
zBaseForm.__getitem__cCs|jdur	|��|jS)z7Return an ErrorDict for the data provided for the form.N)rD�
full_clean�rPrrr�errors�s
zBaseForm.errorscCs|jo|jS)z:Return True if the form has no errors, or False otherwise.)r:rerdrrrrY��zBaseForm.is_validcCs|jr
d|j|fS|S)z�
        Return the field name with a prefix appended, if this Form has a
        prefix set.

        Subclasses may wish to override.
        z%s-%s)r>�rP�
field_namerrr�
add_prefix�szBaseForm.add_prefixcCsd|�|�S)z<Add an 'initial' prefix for checking dynamic initial values.z
initial-%s)rirgrrr�add_initial_prefix�rfzBaseForm.add_initial_prefixcCs|�|j|j|�S�N)�value_from_datadictr;r<)rP�widget�	html_namerrr�_widget_data_value�szBaseForm._widget_data_valuecs�tjdtdd�|����}gg}}|��D]l\�}	|	j}
d}|�|	j�}|	j	r?|r7|�
�fdd�|D��|�t|	��q|	�
�}
|
rId|
}|rV|rV|�|t|��|	jrft|	j�}|	�|�pdd}nd}|
jrq||
j}nd}|�||||	|||
|	jd��q|r�|�d	||�|r�d�|�}|r�|d
}|�|�s�|dddd|ddd�}|�|�|dt|��|||d
<n|�|�td�|��S)
z1Output HTML. Used by as_table(), as_ul(), as_p().zddjango.forms.BaseForm._html_output() is deprecated. Please use .render() and .get_context() instead.�)�
stacklevel�c�"g|]
}td��t|�d��qS�z!(Hidden field %(name)s) %(error)s)r-�error�rA�str�r�e�r-rr�
<listcomp>�����z)BaseForm._html_output.<locals>.<listcomp>z class="%s")re�labelra�	help_text�html_class_attr�css_classesrhr���N�
)�warnings�warnr�non_field_errorsrEr]rar@re�	is_hidden�extend�appendrwr�r}r�	label_tagr~rn�insertrX�endswith�lenr)rP�
normal_row�	error_row�	row_ender�help_text_html�errors_on_separate_row�
top_errors�output�
hidden_fields�bfrar�	bf_errorsr�r}r~�
str_hidden�last_rowrrzr�_html_output�s~�

��
���


�
	 
zBaseForm._html_outputcCs|jjSrk)rO�form_template_namerdrrr�
template_name;szBaseForm.template_namecs�g}g}|����}|��D]C\�}|j|j|jd�}|jr1|r+|�fdd�|D�7}|�|�qt|�}t	|t
�sJt�d|jj
�d�t�t|�}|�||f�q||||d�S)N�rOcrsrtrvrxrzrrr{Gr|z(BaseForm.get_context.<locals>.<listcomp>zReturning a plain string from zA is deprecated. Please customize via the template system instead.)�formrGr�re)r�rEr]r@rerOr�r�rwrrr�r�r4rr)rPrGr�r�r�r��
errors_strrrzr�get_context?s4�
���zBaseForm.get_contextcCs|j�t|jd|jd��S)z�
        Return an ErrorList of errors that aren't associated with a particular
        field -- i.e., from Form.clean(). Return an empty ErrorList if there
        are none.
        �nonfield�r@rO)re�getrr@rOrdrrrr�`s�zBaseForm.non_field_errorscCs�t|t�s	t|�}t|d�r|durtd��|j}n|pt|ji}|��D]G\}}||jvr[|tkrA||j	vrAt
d|jj|f��|tkrQ|j
d|jd�|j|<n
|j
|jd�|j|<|j|�|�||jvrl|j|=q%dS)a%
        Update the content of `self._errors`.

        The `field` argument is the name of the field to which the errors
        should be added. If it's None, treat the errors as NON_FIELD_ERRORS.

        The `error` argument can be a single error, a list of errors, or a
        dictionary that maps field names to lists of errors. An "error" can be
        either a simple string or an instance of ValidationError with its
        message attribute set and a "list or dictionary" can be an actual
        `list` or `dict` or an instance of ValidationError with its
        `error_list` or `error_dict` attribute set.

        If `error` is a dictionary, the `field` argument *must* be None and
        errors will be added to the fields that correspond to the keys of the
        dictionary.
        �
error_dictNzbThe argument `field` must be `None` when the `error` argument contains errors for multiple fields.z'%s' has no field named '%s'.r�r�r�)rrr(�	TypeErrorr�r�
error_listr#rerGrLr3r4r@rOrDr��cleaned_data)rPrarur�rrr�	add_errorks6

�

���
��zBaseForm.add_errorcs2||jvo�dupt�fdd�|j��|D��S)Nc3s�|]}|j�kVqdSrk��code)rrur�rr�	<genexpr>�s�z%BaseForm.has_error.<locals>.<genexpr>)re�any�as_data)rPrar�rr�r�	has_error�s
�zBaseForm.has_errorcCsFt�|_|js	dSi|_|jr|��sdS|��|��|��dS)zY
        Clean all of self.data and populate self._errors and self.cleaned_data.
        N)	rrDr:r�rC�has_changed�
_clean_fields�_clean_form�_post_cleanrdrrrrc�szBaseForm.full_cleancCs�|��D]U\}}|j}|jr|jn|j}z-t|t�r"|�||j�}n|�|�}||j|<t	|d|�r@t
|d|��}||j|<WqtyY}z|�||�WYd}~qd}~wwdS)Nzclean_%s)
r]ra�disabledr?r;rr�cleanr�r(�getattrrr�)rPr-r�rarryrrrr��s"



����zBaseForm._clean_fieldsc
CsVz|��}Wnty}z
|�d|�WYd}~dSd}~ww|dur)||_dSdSrk)r�rr�r�)rPr�ryrrrr��s��
�zBaseForm._clean_formcCsdS)z�
        An internal hook for performing additional cleaning after form cleaning
        is complete. Used for model validation in model forms.
        Nrrdrrrr��szBaseForm._post_cleancCs|jS)a+
        Hook for doing any extra form-wide cleaning after Field.clean() has been
        called on every field. Any ValidationError raised by this method will
        not be associated with a particular field; it will have a special-case
        association with the field named '__all__'.
        )r�rdrrrr��szBaseForm.cleancCs
t|j�S)z)Return True if data differs from initial.)�bool�changed_datardrrrr��s
zBaseForm.has_changedcCsdd�|��D�S)NcSsg|]
\}}|��r|�qSr)�_has_changed)rr-r�rrrr{�sz)BaseForm.changed_data.<locals>.<listcomp>)r]rdrrrr��szBaseForm.changed_datacCs&t�}|j��D]}||jj7}q|S)z=Return all media required to render the widgets on this form.)r	rG�valuesrm�media)rPr�rarrrr��szBaseForm.mediacCstdd�|j��D��S)z{
        Return True if the form needs to be multipart-encoded, i.e. it has
        FileInput, or False otherwise.
        css�|]}|jjVqdSrk)rm�needs_multipart_form�rrarrrr��s�z(BaseForm.is_multipart.<locals>.<genexpr>)r�rGr�rdrrr�is_multipart�szBaseForm.is_multipartcC�dd�|D�S)z�
        Return a list of all the BoundField objects that are hidden fields.
        Useful for manual form layout in templates.
        cSsg|]}|jr|�qSr�r�r�rrrr{��z*BaseForm.hidden_fields.<locals>.<listcomp>rrdrrrr���zBaseForm.hidden_fieldscCr�)z�
        Return a list of BoundField objects that aren't hidden fields.
        The opposite of the hidden_fields() method.
        cSsg|]}|js|�qSrr�r�rrrr{r�z+BaseForm.visible_fields.<locals>.<listcomp>rrdrrr�visible_fields�r�zBaseForm.visible_fieldscCsH|j�||j�}t|�r|�}t|tjtjf�r"|jjs"|jdd�}|S)z�
        Return initial data for field on form. Use initial data from the form
        or the field, in that order. Evaluate callable values.
        r)�microsecond)	r?r��callabler�datetime�timerm�supports_microseconds�replace)rPrarhrrrr�get_initial_for_fields��zBaseForm.get_initial_for_fieldrk)-r4r5r6r7rMrJr>rK�template_name_div�template_name_p�template_name_table�template_name_ul�template_name_labelrrQrIrZr]r^rb�propertyrerYrirjror�r�r�r�r�r�rcr�r�r�r�r�r
r�r�r�r�r�r�rrrrr8sn
�8
	]
!
3		

rc@seZdZdZdS)rz3A collection of Fields, plus their associated data.N)r4r5r6r7rrrrrsr)�	metaclass)%r7rEr�r��django.core.exceptionsrr�django.forms.fieldsrr�django.forms.utilsrrr�django.forms.widgetsr	r
�django.utils.datastructuresr�django.utils.deprecationr�django.utils.functionalr
�django.utils.htmlr�django.utils.safestringrr�django.utils.translationrrA�	renderersr�__all__rrrrrrr�<module>s,`