From 1d4af5cc7cbffbba38ea9bd6ed951e6e10317f3d Mon Sep 17 00:00:00 2001 From: sxw Date: Tue, 4 Aug 2015 19:18:56 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86windows=E4=B8=8B?= =?UTF-8?q?=E7=9A=84runserver=E5=92=8Cruntest=E8=84=9A=E6=9C=AC=20[ci=20si?= =?UTF-8?q?kp]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tools/runserver.cmd | 5 +++++ tools/runtest.cmd | 12 ++++++++++++ tools/runtest.sh | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tools/runserver.cmd create mode 100644 tools/runtest.cmd diff --git a/tools/runserver.cmd b/tools/runserver.cmd new file mode 100644 index 00000000..b458e559 --- /dev/null +++ b/tools/runserver.cmd @@ -0,0 +1,5 @@ +@echo off +python manage.py runserver +cls +cd.. +python manage.py runserver \ No newline at end of file diff --git a/tools/runtest.cmd b/tools/runtest.cmd new file mode 100644 index 00000000..e6d9ad7b --- /dev/null +++ b/tools/runtest.cmd @@ -0,0 +1,12 @@ +@echo off +coverage run --source='.' manage.py test +coverage html +cd htmlcov +index.html +cls +cd.. +coverage run --source='.' manage.py test +coverage html +cd htmlcov +index.html + diff --git a/tools/runtest.sh b/tools/runtest.sh index 2fc4d4a9..87399cc1 100644 --- a/tools/runtest.sh +++ b/tools/runtest.sh @@ -1,4 +1,4 @@ #!/usr/bin/env bash coverage run --source='.' manage.py test -nose html +coverage html open htmlcov/index.html From 0b55f6bbf79bf8f66c1ea81931165c5e3464feef Mon Sep 17 00:00:00 2001 From: sxw Date: Tue, 4 Aug 2015 19:54:44 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E5=AF=86=E7=A0=81=E9=AA=8C=E8=AF=81=E7=9A=84js?= =?UTF-8?q?=EF=BC=8C=E7=B2=BE=E7=AE=80=E4=BB=A3=E7=A0=81=E9=87=8F=EF=BC=8C?= =?UTF-8?q?=E5=87=8F=E5=B0=91=E4=BA=86=E9=87=8D=E5=A4=8D=E7=9A=84=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=EF=BC=8C=E5=87=8F=E5=B0=91=E4=BA=86valuedator?= =?UTF-8?q?=E4=B8=ADconfirm=E7=9A=84=E5=8F=82=E6=95=B0=20[ci=20skip]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/js/app/oj/account/change_password.js | 23 +------------------ static/src/js/app/oj/account/register.js | 23 ++----------------- .../lib/formValidation/validator/confirm.js | 10 ++++---- .../formValidation/validator/usernameCheck.js | 21 ++++++----------- static/src/js/utils/validation.js | 1 - 5 files changed, 14 insertions(+), 64 deletions(-) diff --git a/static/src/js/app/oj/account/change_password.js b/static/src/js/app/oj/account/change_password.js index ff9bf74e..e3e907fa 100644 --- a/static/src/js/app/oj/account/change_password.js +++ b/static/src/js/app/oj/account/change_password.js @@ -1,7 +1,4 @@ - require(["jquery", "bs_alert", "csrf", "validation"], function($, bs_alert, csrfHeader){ - - $("#change_password-form").formValidation({ framework: "bootstrap", fields: { @@ -28,20 +25,11 @@ require(["jquery", "bs_alert", "csrf", "validation"], function($, bs_alert, csrf min: 6, max: 30, message: '密码长度必须在6到30位之间' - }, - confirm: { - firstPassword: $("#new_password"), - secondPassword: $("#confirm_password"), - message: "两次输入的密码必须一致" } }, onSuccess: function(e, data) { - - if (!data.fv.isValidField('confirm_password')) { data.fv.revalidateField('confirm_password'); - } } - }, confirm_password: { validators: { @@ -49,17 +37,10 @@ require(["jquery", "bs_alert", "csrf", "validation"], function($, bs_alert, csrf message: "请填写确认密码" }, confirm: { - firstPassword: $("#new_password"), - secondPassword: $("#confirm_password"), + original: $("#new_password"), message: "两次输入的密码必须一致" } }, - onSuccess: function(e, data) { - - if (!data.fv.isValidField('new_password')) { - data.fv.revalidateField('new_password'); - } - } } } } @@ -83,8 +64,6 @@ require(["jquery", "bs_alert", "csrf", "validation"], function($, bs_alert, csrf bs_alert(data.data); } } - }) }); - }); \ No newline at end of file diff --git a/static/src/js/app/oj/account/register.js b/static/src/js/app/oj/account/register.js index 4baf3349..e6b4deb5 100644 --- a/static/src/js/app/oj/account/register.js +++ b/static/src/js/app/oj/account/register.js @@ -1,5 +1,4 @@ require(["jquery", "bs_alert", "csrf", "validation"], function($, bs_alert, csrfHeader){ - $("#register-form") .formValidation({ framework: "bootstrap", @@ -28,18 +27,10 @@ require(["jquery", "bs_alert", "csrf", "validation"], function($, bs_alert, csrf min: 6, max: 30, message: '密码长度必须在6到30位之间' - }, - confirm: { - firstPassword: $("#password"), - secondPassword: $("#confirm_password"), - message: "两次输入的密码必须一致" - } + } }, onSuccess: function(e, data) { - - if (!data.fv.isValidField('confirm_password')) { data.fv.revalidateField('confirm_password'); - } } }, real_name: { @@ -48,7 +39,6 @@ require(["jquery", "bs_alert", "csrf", "validation"], function($, bs_alert, csrf message: "请填写真实姓名" } }, - }, confirm_password: { validators: { @@ -56,18 +46,9 @@ require(["jquery", "bs_alert", "csrf", "validation"], function($, bs_alert, csrf message: "请填写确认密码" }, confirm: { - firstPassword: $("#password"), - secondPassword: $("#confirm_password"), + original: $("#password"), message: "两次输入的密码必须一致" } - - }, - - onSuccess: function(e, data) { - - if (!data.fv.isValidField('password')) { - data.fv.revalidateField('password'); - } } } } diff --git a/static/src/js/lib/formValidation/validator/confirm.js b/static/src/js/lib/formValidation/validator/confirm.js index 5d491ee6..db5ad3a3 100644 --- a/static/src/js/lib/formValidation/validator/confirm.js +++ b/static/src/js/lib/formValidation/validator/confirm.js @@ -22,13 +22,11 @@ } } }); - FormValidation.Validator.confirm = { - validate: function(validator, $field, options) { - if (options.firstPassword.val() == options.secondPassword.val() ||options.secondPassword.val()== '') - return true; - return false; - } + if (options.original.val() == $field.val() || $field.val()== '') + return true; + return false; + } }; })); diff --git a/static/src/js/lib/formValidation/validator/usernameCheck.js b/static/src/js/lib/formValidation/validator/usernameCheck.js index 116c1dc5..36a77626 100644 --- a/static/src/js/lib/formValidation/validator/usernameCheck.js +++ b/static/src/js/lib/formValidation/validator/usernameCheck.js @@ -1,7 +1,6 @@ /** * usernameCheck validator */ - (function(root, factory) { "use strict"; @@ -13,7 +12,6 @@ // planted over the root! factory(root.jQuery, root.FormValidation); } - }(this, function ($, FormValidation, csrfHeader) { FormValidation.I18n = $.extend(true, FormValidation.I18n || {}, { 'en_US': { @@ -22,23 +20,18 @@ } } }); - FormValidation.Validator.usernameCheck = { - validate: function(validator, $field, options) { if ($field.val() == '') return true; return !$.ajax({ - async: false, - beforeSend: csrfHeader, - url: "/api/username_check/", - data: {username: $field.val()}, - dataType: "json", - method: "post", - - - }).responseJSON.data; - + async: false, + beforeSend: csrfHeader, + url: "/api/username_check/", + data: {username: $field.val()}, + dataType: "json", + method: "post", + }).responseJSON.data; } }; })); diff --git a/static/src/js/utils/validation.js b/static/src/js/utils/validation.js index 38788f7a..5fe792f0 100644 --- a/static/src/js/utils/validation.js +++ b/static/src/js/utils/validation.js @@ -11,5 +11,4 @@ define("validation", 'validator/confirm', 'validator/usernameCheck'], function () { - }); \ No newline at end of file