
    T@9i                     t    d dl mZ d dlmZ d dlmZ d dlmZ d dlm	Z	 dZ
d Zd Zd	 Zd
 Zd Zd Zd Zd Zy)    )forms)User)HttpResponse)engines)CaptchaFielda  
<!doctype html>
<html>
    <head>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8">
        <title>captcha test</title>
    </head>
    <body>
        {% if passed %}
        <p style="color:green">Form validated</p>
        {% endif %}
        {% if form.errors %}
        {{form.errors}}
        {% endif %}

        <form action="{% url 'captcha-test' %}" method="post">
            {{form.as_p}}
            <p><input type="submit" value="Continue &rarr;"></p>
        </form>
    </body>
</html>
c                 2    t         d   j                  |       S )Ndjango)r   from_string)template_strings    J/var/www/apihucms/venv/lib/python3.12/site-packages/captcha/tests/views.py_get_templater   !   s    8((99    c                     d}| j                   r% || j                         }|j                         r
d}n |       }t        t              }t	        |j                  t        ||      |             S )NFT)passedform)contextrequest)POSTis_validr   TEST_TEMPLATEr   renderdict)r   
form_classr   r   ts        r   _testr   %   s_    F||',,'==?F|m$A	V$7I r   c                 L     G d dt         j                        }t        | |      S )Nc                   f    e Zd Z ej                  d      Z ej                         Z ed      Z	y)test.<locals>.CaptchaTestFormd   
max_lengthasdasd	help_textN)
__name__
__module____qualname__r   	CharFieldsubject
EmailFieldsenderr   captcha r   r   CaptchaTestFormr   6   s,    !%//S1!!!#2r   r.   r   Formr   r   r.   s     r   testr2   5   s!    3%** 3
 /**r   c                 L     G d dt         j                        }t        | |      S )Nc                   z    e Zd Z ej                  d      Z ej                         Z ed      Z	 G d d      Z
y)-test_model_form.<locals>.CaptchaTestModelFormr   r    r"   r#   c                       e Zd ZeZdZy)2test_model_form.<locals>.CaptchaTestModelForm.Metar)   r+   r,   Nr%   r&   r'   r   modelfieldsr-   r   r   Metar7   D       E5Fr   r<   Nr%   r&   r'   r   r(   r)   r*   r+   r   r,   r<   r-   r   r   CaptchaTestModelFormr5   ?   s6    !%//S1!!!#2	6 	6r   r?   r   	ModelFormr   r   r?   s     r   test_model_formrC   >   "    6u 6 .//r   c                 L     G d dt         j                        }t        | |      S )Nc                   |    e Zd Z ej                  d      Z ej                         Z ed       Z	 G d d      Z
y)3test_custom_generator.<locals>.CaptchaTestModelFormr   r    c                       y)N)111111rI   r-   r-   r   r   <lambda>z<test_custom_generator.<locals>.CaptchaTestModelForm.<lambda>O   s    r   )	generatorc                       e Zd ZeZdZy)8test_custom_generator.<locals>.CaptchaTestModelForm.Metar8   Nr9   r-   r   r   r<   rM   Q   r=   r   r<   Nr>   r-   r   r   r?   rG   L   s7    !%//S1!!!#)EF	6 	6r   r?   r@   rB   s     r   test_custom_generatorrN   K   rD   r   c                 L     G d dt         j                        }t        | |      S )Nc                   .    e Zd Z ed ed            Zy)>test_custom_error_message.<locals>.CaptchaTestErrorMessageFormr"   zTEST CUSTOM ERROR MESSAGE)invalid)r$   error_messagesN)r%   r&   r'   r   r   r,   r-   r   r   CaptchaTestErrorMessageFormrQ   Y   s    t<W/X
r   rT   r/   )r   rT   s     r   test_custom_error_messagerU   X   s"    
ejj 

 566r   c                 L     G d dt         j                        }t        | |      S )Nc                   h    e Zd Z ej                         Z ej                  d      Z edd      Z	y)*test_non_required.<locals>.CaptchaTestFormr   r    r"   F)r$   requiredN)
r%   r&   r'   r   r*   r+   r(   r)   r   r,   r-   r   r   r.   rX   b   s.    !!!#!%//S1EBr   r.   r/   r1   s     r   test_non_requiredrZ   a   s#    C%** C
 /**r   c                 L     G d dt         j                        }t        | |      S )Nc                   x    e Zd Z ej                         Z ej                  d      Z ed      Z	 ed      Z
y)'test_id_prefix.<locals>.CaptchaTestFormr   r    form1)	id_prefixform2N)r%   r&   r'   r   r*   r+   r(   r)   r   captcha1captcha2r-   r   r   r.   r]   k   s6    !!!#!%//S1'2'2r   r.   r/   r1   s     r   test_id_prefixrc   j   s!    3%** 3 /**r   N)r	   r   django.contrib.auth.modelsr   django.httpr   django.templater   captcha.fieldsr   r   r   r   r2   rC   rN   rU   rZ   rc   r-   r   r   <module>rh      sC     + $ # '0: +
0
07++r   