From 7119dfd2ab527e7a828c6b299b638fab2c9ab380 Mon Sep 17 00:00:00 2001 From: gnemoug Date: Sat, 23 Mar 2013 11:07:42 +0800 Subject: [PATCH 1/9] Check whether the input is right for ajax verify request --- captcha/urls.py | 1 + captcha/views.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/captcha/urls.py b/captcha/urls.py index 7de753f6..d3dfee14 100644 --- a/captcha/urls.py +++ b/captcha/urls.py @@ -7,4 +7,5 @@ url(r'image/(?P\w+)/$', 'captcha_image', name='captcha-image'), url(r'audio/(?P\w+)/$', 'captcha_audio', name='captcha-audio'), url(r'refresh/$', 'captcha_refresh', name='captcha-refresh'), + url(r'verify/$','captcha_verify',name='captcha-verify'), ) diff --git a/captcha/views.py b/captcha/views.py index b24fdfc5..4cb95186 100644 --- a/captcha/views.py +++ b/captcha/views.py @@ -119,3 +119,21 @@ def captcha_refresh(request): return HttpResponse(json.dumps(to_json_responce), content_type='application/json') raise Http404 + +def captcha_verify(request): + """ + Check whether the input is right for ajax verify request + """ + + if request.is_ajax(): + try: + response = request.GET.get('verify_data') + key = request.GET.get('key') + except Exception,e: + traceback.print_stack() + raise Http404 + store = get_object_or_404(CaptchaStore, hashkey=key) + result = 'true' if store.response == response else 'false' + + return HttpResponse(json.dumps([result]), mimetype='application/json') + raise Http404 From 5910aad8baba025f667795c9690663fd3b24a11c Mon Sep 17 00:00:00 2001 From: gnemoug Date: Sat, 23 Mar 2013 11:16:41 +0800 Subject: [PATCH 2/9] Update README.rst --- README.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.rst b/README.rst index 8a7ed318..88fead3f 100644 --- a/README.rst +++ b/README.rst @@ -35,3 +35,8 @@ Documentation +++++++++++++ Read the `documentation online `_. +
+增加了ajax验证用户输入字符是否正确的功能,使用方法:
+  ajax发送信息包括:verify_data = $('#id_captcha_1').val()  key = $('#id_captcha_0').val(),如果返回结果为"true",则正确,
+若返回"false"则表示错误.
+
From e9b6fc2bd4bc007c791e37703bd6955103c4f8cb Mon Sep 17 00:00:00 2001 From: gnemoug Date: Sat, 23 Mar 2013 11:17:22 +0800 Subject: [PATCH 3/9] Update README.rst --- README.rst | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 88fead3f..b64cee65 100644 --- a/README.rst +++ b/README.rst @@ -35,8 +35,9 @@ Documentation +++++++++++++ Read the `documentation online `_. -
+
+
 增加了ajax验证用户输入字符是否正确的功能,使用方法:
   ajax发送信息包括:verify_data = $('#id_captcha_1').val()  key = $('#id_captcha_0').val(),如果返回结果为"true",则正确,
 若返回"false"则表示错误.
-
+ From 895dd2606c449ccffcabcd02c7344fd5fcfcf379 Mon Sep 17 00:00:00 2001 From: gnemoug Date: Mon, 1 Apr 2013 06:43:44 +0800 Subject: [PATCH 4/9] Update README.rst --- README.rst | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index b64cee65..805b6900 100644 --- a/README.rst +++ b/README.rst @@ -36,8 +36,12 @@ Documentation Read the `documentation online `_. +add the method through ajax verify what the user input whether right,how to use: +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -增加了ajax验证用户输入字符是否正确的功能,使用方法: - ajax发送信息包括:verify_data = $('#id_captcha_1').val() key = $('#id_captcha_0').val(),如果返回结果为"true",则正确, -若返回"false"则表示错误. + ajax send messages: + * verify_data = $('#id_captcha_1').val() + * key = $('#id_captcha_0').val(), + + if the return result is "true",right,or "false" then not true. From b8b1aeba6161e130dc64e75432c110e4d5028443 Mon Sep 17 00:00:00 2001 From: gnemoug Date: Mon, 1 Apr 2013 06:45:21 +0800 Subject: [PATCH 5/9] Update README.rst --- README.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.rst b/README.rst index 805b6900..6e6cfcb9 100644 --- a/README.rst +++ b/README.rst @@ -38,10 +38,10 @@ Read the `documentation online ajax send messages: - * verify_data = $('#id_captcha_1').val() - * key = $('#id_captcha_0').val(), + verify_data = $('#id_captcha_1').val() + key = $('#id_captcha_0').val(), if the return result is "true",right,or "false" then not true. - + From d54ba9c4ce42ff2acfc201790d2485965036db45 Mon Sep 17 00:00:00 2001 From: gnemoug Date: Mon, 1 Apr 2013 06:45:49 +0800 Subject: [PATCH 6/9] Update README.rst --- README.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/README.rst b/README.rst index 6e6cfcb9..44dbef5c 100644 --- a/README.rst +++ b/README.rst @@ -38,6 +38,7 @@ Read the `documentation online ajax send messages: verify_data = $('#id_captcha_1').val() From ef864c8e8f483d7531b51c19fc11a160be9f8c39 Mon Sep 17 00:00:00 2001 From: gnemoug Date: Mon, 1 Apr 2013 06:46:12 +0800 Subject: [PATCH 7/9] Update README.rst --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 44dbef5c..4b21508c 100644 --- a/README.rst +++ b/README.rst @@ -39,10 +39,10 @@ Read the `documentation online + ajax send messages: verify_data = $('#id_captcha_1').val() key = $('#id_captcha_0').val(), if the return result is "true",right,or "false" then not true. - + From 310c8ffaa9a68c1c5a8e818777b00f6736bb076d Mon Sep 17 00:00:00 2001 From: gnemoug Date: Mon, 1 Apr 2013 06:46:48 +0800 Subject: [PATCH 8/9] Update README.rst --- README.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 4b21508c..80217e60 100644 --- a/README.rst +++ b/README.rst @@ -41,8 +41,8 @@ add the method through ajax verify what the user input whether right,how to use: ajax send messages: - verify_data = $('#id_captcha_1').val() - key = $('#id_captcha_0').val(), + verify_data = $('#id_captcha_1').val(), + key = $('#id_captcha_0').val(), if the return result is "true",right,or "false" then not true. From 0c458e1f59b9a1ccef4e562af56a43b7198f9f19 Mon Sep 17 00:00:00 2001 From: gnemoug Date: Mon, 1 Apr 2013 06:49:24 +0800 Subject: [PATCH 9/9] Update README.rst --- README.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index 80217e60..d459c0af 100644 --- a/README.rst +++ b/README.rst @@ -36,10 +36,10 @@ Documentation Read the `documentation online `_. -add the method through ajax verify what the user input whether right,how to use: -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - +add the method through ajax verify what the user input whether right +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +how to use: ajax send messages: verify_data = $('#id_captcha_1').val(), key = $('#id_captcha_0').val(),