
    h2                         S SK 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Jr  S SKJr  Sr " S	 S
\5      r\ " S S5      5       rg)    N)ValidationError)RenderableFieldMixinpretty_name)MultiWidgetTextarea	TextInput)cached_property)format_html	html_safe)gettext_lazy)
BoundFieldc                   8   \ rS rSrSrS r\S 5       rS rS r	S r
S r\S	 5       r\S
 5       rS rSS jrS S jrS S jrS S jr\S 5       rS rS rS!S jrS"S jrS S jr\S 5       r\S 5       r\S 5       r\S 5       rS S jr\S 5       r\S 5       r Sr!g)#r      zA Field plus datac                    Xl         X l        X0l        UR                  U5      U l        UR                  U5      U l        UR                  U R                  5      U l        U R                  R                  c  [        U5      U l	        OU R                  R                  U l	        UR                  =(       d    SU l        UR                  U l        g )N )formfieldname
add_prefix	html_nameadd_initial_prefixhtml_initial_nameauto_idhtml_initial_idlabelr   	help_textrenderer)selfr   r   r   s       I/var/www/html/env/lib/python3.13/site-packages/django/forms/boundfield.py__init__BoundField.__init__   s    	
	.!%!8!8!>#66t||D::#$T*DJ))DJ.B    c                    U R                   R                  R                  R                  S5      =(       d    U R                  nU(       a  SU0O0 nU R                  U5      nU R                   R                  R                  U R                  U R                  5       US9 Vs/ s H7  n[        U R                   R                  X0R                  R                  5      PM9     sn$ s  snf )z
Most widgets yield a single subwidget, but others like RadioSelect and
CheckboxSelectMultiple produce one subwidget for each choice.

This property is cached so that only one database query occurs when
rendering ModelChoiceFields.
id)attrs)r   widgetr%   getr   build_widget_attrs
subwidgetsr   valueBoundWidgetr   r   )r   id_r%   r&   s       r   r)   BoundField.subwidgets   s     jj%%))$/?4<<"s''. **++66

E 7 
 

))6993E3EF
 	
 
s    >C!c                     gNT r   s    r   __bool__BoundField.__bool__1   s    r"   c                 ,    [        U R                  5      $ N)iterr)   r1   s    r   __iter__BoundField.__iter__5   s    DOO$$r"   c                 ,    [        U R                  5      $ r5   )lenr)   r1   s    r   __len__BoundField.__len__8   s    4??##r"   c                     [        U[        [        45      (       d!  [        S[	        U5      R
                  -  5      eU R                  U   $ )Nz6BoundField indices must be integers or slices, not %s.)
isinstanceintslice	TypeErrortype__name__r)   )r   idxs     r   __getitem__BoundField.__getitem__;   sH     #U|,,Hs)$$%  s##r"   c                     U R                   R                  R                  U R                  U R                   R	                  U R                   R
                  S95      $ )zD
Return an ErrorList (empty if there are no errors) for this field.
)r   )r   errorsr'   r   error_classr   r1   s    r   rH   BoundField.errorsE   sF    
 yy##IItyy,,dii6H6H,I
 	
r"   c                 |    U R                   R                  =(       d     U R                  R                  R                  $ r5   )r   template_namer   r   field_template_namer1   s    r   rL   BoundField.template_nameN   s'    zz''Q499+=+=+Q+QQr"   c                 
    SU 0$ )Nr   r0   r1   s    r   get_contextBoundField.get_contextR   s    r"   Nc                    U=(       d    U R                   R                  nU R                   R                  (       a  SUl        U=(       d    0 nU R	                  X!5      nU R
                  (       a?  SUR                  ;  a/  UR                  SU(       a  U R                  OU R
                  5        U(       ac  U R                  U R                  R                  ;   a?  U R                  R                  U R                   R                  5       U R                  5      nOU R                  5       nUR                  U(       a  U R                  OU R                   UUU R                  R"                  S9$ )z
Render the field by rendering the passed widget, adding any HTML
attributes passed as attrs. If a widget isn't specified, use the
field's default widget.
Tr$   )r   r*   r%   r   )r   r&   localizeis_localizedr(   r   r%   
setdefaultr   r   r   data_widget_data_valuehidden_widgetr*   renderr   r   )r   r&   r%   only_initialr*   s        r   	as_widgetBoundField.as_widgetU   s    ,4::,,::"&F''6<<D4ld** D22diinnDII00

((*&&E
 JJLE}}+7''T^^YY''	  
 	
r"   c                 :    U R                   " [        5       U40 UD6$ )zJ
Return a string of HTML for representing this as an <input type="text">.
)r[   r   r   r%   kwargss      r   as_textBoundField.as_texts   s     ~~ik5;F;;r"   c                 :    U R                   " [        5       U40 UD6$ )z>Return a string of HTML for representing this as a <textarea>.)r[   r   r^   s      r   as_textareaBoundField.as_textareay   s    ~~hj%:6::r"   c                 Z    U R                   " U R                  R                  5       U40 UD6$ )zL
Return a string of HTML for representing this as an <input type="hidden">.
)r[   r   rX   r^   s      r   	as_hiddenBoundField.as_hidden}   s'     ~~djj668%J6JJr"   c                 v    U R                   R                  U R                  R                  U R                  5      $ )zB
Return the data for this BoundField, or None if it wasn't given.
)r   rW   r   r&   r   r1   s    r   rV   BoundField.data   s)    
 yy++DJJ,=,=t~~NNr"   c                     U R                   nU R                  R                  (       a&  U R                  R	                  U R
                  U5      nU R                  R                  U5      $ )zo
Return the value for this BoundField, using the initial value if
the form is not bound or the data otherwise.
)initialr   is_boundr   
bound_datarV   prepare_value)r   rV   s     r   r*   BoundField.value   sI    
 ||99::((D9Dzz''--r"   c                 <   U R                   nUR                  (       aI  UR                  5       nU R                  R	                  UU R
                  5      n UR                  U5      nOU R                  nUR                  X0R                  5      $ ! [         a     gf = fr/   )r   show_hidden_initialrX   r   rW   r   	to_pythonr   rk   has_changedrV   )r   r   rX   initial_values       r   _has_changedBoundField._has_changed   s    

$$!//1M II88&&M % >
 !LLM  		:: # s   B 
BBc                    U=(       d    U R                   nUcC  U R                  R                  b  U R                  R                  OU R                  R                  nU(       a%  U(       a  US   [	        S5      ;  a  [        SX5      nU R                  R                  nUR                  R                  S5      =(       d    U R                  nU(       a  UR                  U5      nU(       a  0 U=(       d    0 ESU0EnU R                  R                  (       aj  [        U R                  S5      (       aO  U=(       d    0 nSU;   a%  US==   SU R                  R                  -   -  ss'   OU R                  R                  US'   U UU[        U5      U=(       d    S	S
.nU R                  R                  U R                  R                   U5      $ )a4  
Wrap the given contents in a <label>, if the field has an ID attribute.
contents should be mark_safe'd to avoid HTML escaping. If contents
aren't given, use the field's HTML-escaped label.

If attrs are given, use them as HTML attributes on the <label> tag.

label_suffix overrides the form's label_suffix.
z:?.!z{}{}r$   forrequired_css_classclass r   )r   r   r%   use_tagtag)r   r   label_suffixr   _r
   r&   r%   r'   r   id_for_labelrequiredhasattrrz   boolrY   template_name_label)	r   contentsr%   r   r~   r&   r,   r   contexts	            r   	label_tagBoundField.label_tag   sd    )tzz ::**6 

''YY++  H"QvY)F"68BH""llt$4!..s3L>EKR>%>zz""wtyy:N'O'Oe#'NcDII,H,H&HHN%)YY%A%AE'NCy>'
 yy		 = =wGGr"   c                 $    U R                  XUSS9$ )a6  
Wrap the given contents in a <legend>, if the field has an ID
attribute. Contents should be mark_safe'd to avoid HTML escaping. If
contents aren't given, use the field's HTML-escaped label.

If attrs are given, use them as HTML attributes on the <legend> tag.

label_suffix overrides the form's label_suffix.
legendr~   )r   )r   r   r%   r   s       r   
legend_tagBoundField.legend_tag   s     ~~h|~JJr"   c                    [        US5      (       a  UR                  5       n[        U=(       d    / 5      nU R                  (       a@  [        U R                  S5      (       a%  UR                  U R                  R                  5        U R                  R                  (       a@  [        U R                  S5      (       a%  UR                  U R                  R                  5        SR                  U5      $ )z@
Return a string of space-separated CSS classes for this field.
spliterror_css_classrz   r|   )r   r   setrH   r   addr   r   r   rz   join)r   extra_classess     r   css_classesBoundField.css_classes   s     ='**)//1MM/R0;;7499.?@@dii778::74996J#K#Kdii::;xx&&r"   c                 B    U R                   R                  R                  $ )z2Return True if this BoundField's widget is hidden.)r   r&   	is_hiddenr1   s    r   r   BoundField.is_hidden   s     zz  ***r"   c                     U R                   R                  nU(       a  S[        U5      ;   a  XR                  -  $ U(       a  U R                  $ g)z
Calculate and return the ID attribute for this BoundField, if the
associated Form has specified auto_id. Return an empty string otherwise.
z%sr   )r   r   strr   )r   r   s     r   r   BoundField.auto_id   s>     ))##ts7|+^^++>>!r"   c                     U R                   R                  nUR                  R                  S5      =(       d    U R                  nUR                  U5      $ )z
Wrapper around the field widget's `id_for_label` method.
Useful, for example, for focusing on this field regardless of whether
it has a single widget or a MultiWidget.
r$   )r   r&   r%   r'   r   r   )r   r&   r,   s      r   r   BoundField.id_for_label   sA     ""llt$4""3''r"   c                 b    U R                   R                  U R                  U R                  5      $ r5   )r   get_initial_for_fieldr   r   r1   s    r   rk   BoundField.initial  s!    yy..tzz499EEr"   c                 h   U=(       d    U R                   R                  n[        U5      nUR                  U R                  5      (       Ga	  U R                   R
                  (       a  U R                  R                  (       a  [        U R                   S5      (       a  U R                   R                  (       d  [        U R                   R                  [        5      (       ao  [        U R                   R                  UR                  5       H@  u  p4UR                  U R                  5      =(       a    UR
                  UR                  S'   MB     OSUS'   U R                   R                  (       a  SUS'   UR                   (       d  U R"                  (       a  SUS'   UR%                  S5      (       d  UR                  R%                  S5      (       d`  U R                   R&                  (       aE  U R(                  (       d4  U R*                  (       a#  U R                   (       d  U R*                   S3US'   U$ )	Nrequire_all_fieldsr   Tdisabledtruezaria-invalidzaria-describedby	_helptext)r   r&   dictuse_required_attributerk   r   r   r   r   r>   r   zipfieldswidgetsr%   r   r   rH   r'   r   use_fieldsetr   )r   r%   r&   subfield	subwidgets        r   r(   BoundField.build_widget_attrs
  sz   ,4::,,U))$,,77

##		00
 

$899

55tzz00+>>+.tzz/@/@&..+Q'H!88F .$-- OOJ/ ,R %)j!:: $E*DKK$*E.!
 		,--LL$$%788

$$%%NN+/<<.	(BE$%r"   c                     [         R                  " SSU R                  R                  R                  R
                  R                  5       5      $ )Nzwidget$|input$r   )resubr   r&   	__class__rC   lowerr1   s    r   widget_typeBoundField.widget_type2  s9    vvr4::#4#4#>#>#G#G#M#M#O
 	
r"   c                 B    U R                   R                  R                  $ )zF
Return the value of this BoundField widget's use_fieldset attribute.
)r   r&   r   r1   s    r   r   BoundField.use_fieldset8  s    
 zz  ---r"   )	r   r   r   r   r   r   r   r   r   )NNFr5   )NNNN)NNN)"rC   
__module____qualname____firstlineno____doc__r    r	   r)   r2   r7   r;   rE   propertyrH   rL   rP   r[   r`   rc   rf   rV   r*   ru   r   r   r   r   r   r   rk   r(   r   r   __static_attributes__r0   r"   r   r   r      s(   & 
 
$%$$ 
 
 R R
<<;K O O.;")HV
K' + + 
 
 ( ( F F&P 
 

 . .r"   r   c                   ^    \ rS rSrSrS rS rSS jr\S 5       r	\S 5       r
\S 5       rS	rg
)r+   i@  aH  
A container class used for iterating over widgets. This is useful for
widgets that have choices. For example, the following can be used in a
template:

{% for radio in myform.beatles %}
  <label for="{{ radio.id_for_label }}">
    {{ radio.choice_label }}
    <span class="radio">{{ radio.tag }}</span>
  </label>
{% endfor %}
c                 (    Xl         X l        X0l        g r5   )parent_widgetrV   r   )r   r   rV   r   s       r   r    BoundWidget.__init__O  s    *	 r"   c                      U R                  SS9$ )NT)
wrap_labelr   r1   s    r   __str__BoundWidget.__str__T  s    xx4x((r"   c                     S0 U R                   ESU0E0nU R                  R                  U R                  X R                  5      $ )Nr&   r   )rV   r   _renderrL   r   )r   r   r   s      r   r~   BoundWidget.tagW  s@    D		D<DE!!))$*<*<g}}UUr"   c                 l    SU R                   ;   a  U R                   S   $ U R                  R                  $ )NrL   )rV   r   rL   r1   s    r   rL   BoundWidget.template_name[  s/    dii'99_--!!///r"   c                 >    U R                   S   R                  S5      $ )Nr%   r$   )rV   r'   r1   s    r   r   BoundWidget.id_for_labela  s    yy!%%d++r"   c                      U R                   S   $ )Nr   )rV   r1   s    r   choice_labelBoundWidget.choice_labele  s    yy!!r"   )rV   r   r   N)F)rC   r   r   r   r   r    r   r~   r   rL   r   r   r   r0   r"   r   r+   r+   @  sS    !
)V 0 0
 , , " "r"   r+   )r   django.core.exceptionsr   django.forms.utilsr   r   django.forms.widgetsr   r   r   django.utils.functionalr	   django.utils.htmlr
   r   django.utils.translationr   r   __all__r   r+   r0   r"   r   <module>r      sK    	 2 @ A A 3 4 6
p.% p.f	 &" &" &"r"   