
    i                         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
n# e$ r d dlmZ dZ
Y nw xY wd	Zd
 Zd Zd Zd Zd Zd Zd Zd Zd ZdS )    )CaptchaField)forms)User)HttpResponse)enginesT)loaderFar  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<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                 x    t           r t          d                             |           S t          j        |           S )Ndjango)__is_18r   from_stringr   get_template_from_string)template_strings    K/srv/django_bis/venv311/lib/python3.11/site-packages/captcha/tests/views.py_get_templater   )   s5     @x ,,_===.???    c                    d}| j         r' || j                   }|                                rd}n
 |            }t          t                    }t	          |                    t          ||          |                     S )NFT)passedform)contextrequest)POSTis_validr   TEST_TEMPLATEr   renderdict)r   
form_classr   r   ts        r   _testr   0   s|    F| z',''==?? 	Fz||m$$AV$)G)G)GQXYYZZZr   c                 R     G d dt           j                  }t          | |          S )Nc                   f    e Zd Z ej        d          Z ej                    Z ed          Z	dS )test.<locals>.CaptchaTestFormd   
max_lengthasdasd	help_textN)
__name__
__module____qualname__r   	CharFieldsubject
EmailFieldsenderr   captcha r   r   CaptchaTestFormr!   ?   sD        !%/S111!!##,222r   r1   r   Formr   r   r1   s     r   testr5   >   s@    3 3 3 3 3%* 3 3 3
 /***r   c                 R     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
dS )-test_model_form.<locals>.CaptchaTestModelFormr"   r#   r%   r&   c                       e Zd ZeZdZdS )2test_model_form.<locals>.CaptchaTestModelForm.Metar,   r.   r/   Nr(   r)   r*   r   modelfieldsr0   r   r   Metar:   M           E5FFFr   r?   Nr(   r)   r*   r   r+   r,   r-   r.   r   r/   r?   r0   r   r   CaptchaTestModelFormr8   H   sr        !%/S111!!##,222	6 	6 	6 	6 	6 	6 	6 	6 	6 	6r   rB   r   	ModelFormr   r   rB   s     r   test_model_formrF   G   A    6 6 6 6 6u 6 6 6 .///r   c                 R     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
dS )3test_custom_generator.<locals>.CaptchaTestModelFormr"   r#   c                      dS )N)111111rL   r0   r0   r   r   <lambda>z<test_custom_generator.<locals>.CaptchaTestModelForm.<lambda>X   s    1E r   )	generatorc                       e Zd ZeZdZdS )8test_custom_generator.<locals>.CaptchaTestModelForm.Metar;   Nr<   r0   r   r   r?   rP   Z   r@   r   r?   NrA   r0   r   r   rB   rJ   U   sv        !%/S111!!##,)E)EFFF	6 	6 	6 	6 	6 	6 	6 	6 	6 	6r   rB   rC   rE   s     r   test_custom_generatorrQ   T   rG   r   c                 R     G d dt           j                  }t          | |          S )Nc                   <    e Zd Z ed ed                    ZdS )>test_custom_error_message.<locals>.CaptchaTestErrorMessageFormr%   TEST CUSTOM ERROR MESSAGEinvalid)r'   error_messagesNr(   r)   r*   r   r   r/   r0   r   r   CaptchaTestErrorMessageFormrT   b   s7        ,tt<W/X/X/X
 
 
r   rZ   r2   )r   rZ   s     r   test_custom_error_messager[   a   sA    
 
 
 
 
ej 
 
 

 5666r   c                 R     G d dt           j                  }t          | |          S )Nc                   >    e Zd Z ed ed          d          ZdS )3test_per_form_format.<locals>.CaptchaTestFormatFormr%   rU   rV   zH%(image)s testPerFieldCustomFormatString %(hidden_field)s %(text_field)s)r'   rX   output_formatNrY   r0   r   r   CaptchaTestFormatFormr^   k   s=        ,4(CDDD2	
 
 
r   r`   r2   )r   r`   s     r   test_per_form_formatra   j   sA    
 
 
 
 

 
 
 
 /000r   c                 R     G d dt           j                  }t          | |          S )Nc                   h    e Zd Z ej                    Z ej        d          Z edd          Z	dS )*test_non_required.<locals>.CaptchaTestFormr"   r#   r%   F)r'   requiredN)
r(   r)   r*   r   r-   r.   r+   r,   r   r/   r0   r   r   r1   rd   y   sF        !!##!%/S111,EBBBr   r1   r2   r4   s     r   test_non_requiredrf   x   sH    C C C C C%* C C C
 /***r   c                 R     G d dt           j                  }t          | |          S )Nc                   ~    e Zd Z ej                    Z ej        d          Z ed          Z	 ed          Z
dS )'test_id_prefix.<locals>.CaptchaTestFormr"   r#   form1)	id_prefixform2N)r(   r)   r*   r   r-   r.   r+   r,   r   captcha1captcha2r0   r   r   r1   ri      sV        !!##!%/S111<'222<'222r   r1   r2   r4   s     r   test_id_prefixro      s@    3 3 3 3 3%* 3 3 3 /***r   N)captcha.fieldsr   r
   r   django.contrib.auth.modelsr   django.httpr   django.templater   r   ImportErrorr   r   r   r   r5   rF   rQ   r[   ra   rf   ro   r0   r   r   <module>ru      s?   ' ' ' ' ' '       + + + + + + $ $ $ $ $ $''''''GG   &&&&&&GGG2@ @ @[ [ [+ + +
0 
0 
0
0 
0 
07 7 71 1 1+ + ++ + + + +s   # 33