
     +h                     h    d Z ddlmZ  G d d          Z G d de          Z G d de          Zd	S )
z$Select2 field implementation module.    )ChoiceFieldc                       e Zd ZdZd Zd ZdS )ChoiceCallablez/Choices wrapper that supports callable choices.c                     || _         dS )z0Instanciate with a callable or iterable choices.N)choices)selfr   s     V/var/www/html/e360mart/e360mart_env/lib/python3.11/site-packages/dal_select2/fields.py__init__zChoiceCallable.__init__	   s        c                    g }t          | j                  r|                                 n| j        }|pg D ]K}t          |t          t          f          r|                    |           4|                    ||f           L|S )z2Call the callable if necessary and return choices.)callabler   
isinstancelisttupleappend)r   resultr   choices       r	   __call__zChoiceCallable.__call__   s    $,T\$:$:L$,,...m 	0 	0F&4-00 0f%%%%vv.////r   N)__name__
__module____qualname____doc__r
   r    r   r	   r   r      s8        99  	 	 	 	 	r   r   c                   (     e Zd ZdZ	 	 d fd	Z xZS )Select2ListChoiceFieldzAllows a list of values to be used with a ChoiceField.

    Avoids unusual things that can happen if Select2ListView is used for
    a form where the text and value for choices are not the same.
    NT c           
      t    t          |          }	 t          t          |           j        ||	|||||d| dS )zUse a list to generate choices in a ChoiceField.

        .. py:param choice_list: The list to use to generate choices or a
        function that returns a list.
        )r   requiredwidgetlabelinitial	help_textN)r   superr   r
   )r   choice_listr   r   r    r!   r"   argskwargsr   	__class__s             r	   r
   zSelect2ListChoiceField.__init__    s^     !--4$d++437 hvUy	
 	
;A	
 	
 	
 	
 	
r   )NTNNNr   )r   r   r   r   r
   __classcell__r'   s   @r	   r   r      sQ          @D57
 
 
 
 
 
 
 
 
 
r   r   c                   "     e Zd ZdZ fdZ xZS )Select2ListCreateChoiceFieldz5Skips validation of choices so any value can be used.c                 X    t          t          |                               |           dS )z,Do not validate choices but check for empty.N)r#   r   validate)r   valuer'   s     r	   r-   z%Select2ListCreateChoiceField.validate2   s'    k4  ))%00000r   )r   r   r   r   r-   r(   r)   s   @r	   r+   r+   /   s>        ??1 1 1 1 1 1 1 1 1r   r+   N)r   django.formsr   r   r   r+   r   r   r	   <module>r0      s    * * $ $ $ $ $ $       &
 
 
 
 
[ 
 
 
,1 1 1 1 1#9 1 1 1 1 1r   