
    Q%i                     T    d Z ddlmZ  G d d      Z G d de      Z G d de      Zy	)
z$Select2 field implementation module.    )ChoiceFieldc                       e Zd ZdZd Zd Zy)ChoiceCallablez/Choices wrapper that supports callable choices.c                     || _         y)z0Instanciate with a callable or iterable choices.N)choices)selfr   s     p/var/www/html/navyabakers_fullstack/navyabakers_prod/venv_new/lib/python3.12/site-packages/dal_select2/fields.py__init__zChoiceCallable.__init__	   s	        c                     g }t        | j                        r| j                         n| j                  }|xs g D ]=  }t        |t        t        f      r|j                  |       +|j                  ||f       ? |S )z2Call the callable if necessary and return choices.)callabler   
isinstancelisttupleappend)r   resultr   choices       r	   __call__zChoiceCallable.__call__   sh    $,T\\$:$,,.m 	0F&4-0f%vv./		0
 r   N)__name__
__module____qualname____doc__r
   r    r   r	   r   r      s    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.
    c           
      P    t        |      }	t        t        |   ||	|||||d| y)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:     !-$d437 hvUy	
;A	
r   )NTNNN )r   r   r   r   r
   __classcell__r&   s   @r	   r   r      s     @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                 ,    t         t        |   |       y)z,Do not validate choices but check for empty.N)r"   r   validate)r   valuer&   s     r	   r-   z%Select2ListCreateChoiceField.validate2   s    k4)%0r   )r   r   r   r   r-   r(   r)   s   @r	   r+   r+   /   s    ?1 1r   r+   N)r   django.formsr   r   r   r+   r   r   r	   <module>r0      s.    * $ &
[ 
,1#9 1r   