mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-11-04 14:49:58 +08:00
Merge branch 'dev' into hohoTT-dev
This commit is contained in:
commit
dc67491e6e
@ -26,7 +26,7 @@ class UserRegisterSerializer(serializers.Serializer):
|
|||||||
|
|
||||||
class UserChangePasswordSerializer(serializers.Serializer):
|
class UserChangePasswordSerializer(serializers.Serializer):
|
||||||
username = serializers.CharField(max_length=30)
|
username = serializers.CharField(max_length=30)
|
||||||
old_password = serializers.CharField(max_length=30, min_length=6)
|
old_password = serializers.CharField()
|
||||||
new_password = serializers.CharField(max_length=30, min_length=6)
|
new_password = serializers.CharField(max_length=30, min_length=6)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -3,8 +3,7 @@ from __future__ import absolute_import
|
|||||||
from celery import Celery
|
from celery import Celery
|
||||||
from .settings import redis_config
|
from .settings import redis_config
|
||||||
|
|
||||||
app = Celery("judge", broker="redis://" +
|
app = Celery("judge", broker='redis://%s:%s/%s' % (redis_config["host"], redis_config["port"], redis_config["db"]),
|
||||||
redis_config["host"] + ":" +
|
|
||||||
str(redis_config["port"]) +
|
|
||||||
"/" + str(redis_config["db"]),
|
|
||||||
include=["judge.judger_controller.tasks"])
|
include=["judge.judger_controller.tasks"])
|
||||||
|
|
||||||
|
Celery().conf.update(CELERY_ACCEPT_CONTENT = ['json'])
|
||||||
@ -1,6 +1,6 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
redis_config = {
|
redis_config = {
|
||||||
"host": "121.42.196.141",
|
"host": "121.42.32.129",
|
||||||
"port": 6379,
|
"port": 6379,
|
||||||
"db": 0
|
"db": 0
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,7 +18,7 @@ DATABASES = {
|
|||||||
|
|
||||||
# 这是web 服务器连接到mongodb 的地址
|
# 这是web 服务器连接到mongodb 的地址
|
||||||
MONGODB = {
|
MONGODB = {
|
||||||
'HOST': '121.42.196.141',
|
'HOST': '121.42.32.129',
|
||||||
'USERNAME': 'root',
|
'USERNAME': 'root',
|
||||||
'PASSWORD': 'root',
|
'PASSWORD': 'root',
|
||||||
'PORT': 27017
|
'PORT': 27017
|
||||||
|
|||||||
@ -1,50 +1,6 @@
|
|||||||
require(["jquery", "bsAlert", "csrfToken", "formValidation"], function ($, bsAlert, csrfTokenHeader) {
|
require(["jquery", "bsAlert", "csrfToken", "validator"], function ($, bsAlert, csrfTokenHeader) {
|
||||||
$("#change_password-form").formValidation({
|
|
||||||
framework: "bootstrap",
|
$('form').validator().on('submit', function (e) {
|
||||||
fields: {
|
|
||||||
username: {
|
|
||||||
validators: {
|
|
||||||
notEmpty: {
|
|
||||||
message: "请填写用户名"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
password: {
|
|
||||||
validators: {
|
|
||||||
notEmpty: {
|
|
||||||
message: "请填写旧密码"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
new_password: {
|
|
||||||
validators: {
|
|
||||||
notEmpty: {
|
|
||||||
message: "请填写新密码"
|
|
||||||
},
|
|
||||||
stringLength: {
|
|
||||||
min: 6,
|
|
||||||
max: 30,
|
|
||||||
message: '密码长度必须在6到30位之间'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onSuccess: function (e, data) {
|
|
||||||
data.fv.revalidateField('confirm_password');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
confirm_password: {
|
|
||||||
validators: {
|
|
||||||
notEmpty: {
|
|
||||||
message: "请填写确认密码"
|
|
||||||
},
|
|
||||||
confirm: {
|
|
||||||
original: $("#new_password"),
|
|
||||||
message: "两次输入的密码必须一致"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
).on('success.form.fv', function (e) {
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var username = $("#username").val();
|
var username = $("#username").val();
|
||||||
var newPassword = $("#new_password ").val();
|
var newPassword = $("#new_password ").val();
|
||||||
@ -63,6 +19,7 @@ require(["jquery", "bsAlert", "csrfToken", "formValidation"], function ($, bsAle
|
|||||||
bsAlert(data.data);
|
bsAlert(data.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -1,26 +1,6 @@
|
|||||||
require(["jquery", "bsAlert", "csrfToken", "formValidation"], function ($, bsAlert, csrfTokenHeader) {
|
require(["jquery", "bsAlert", "csrfToken", "validator"], function ($, bsAlert, csrfTokenHeader) {
|
||||||
$("#login-form")
|
$('form').validator().on('submit', function (e) {
|
||||||
.formValidation({
|
if (!e.isDefaultPrevented()) {
|
||||||
framework: "bootstrap",
|
|
||||||
fields: {
|
|
||||||
username: {
|
|
||||||
validators: {
|
|
||||||
notEmpty: {
|
|
||||||
message: "请填写用户名"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
password: {
|
|
||||||
validators: {
|
|
||||||
notEmpty: {
|
|
||||||
message: "请填写密码"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
).on('success.form.fv', function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
var username = $("#username").val();
|
var username = $("#username").val();
|
||||||
var password = $("#password").val();
|
var password = $("#password").val();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -38,6 +18,8 @@ require(["jquery", "bsAlert", "csrfToken", "formValidation"], function ($, bsAle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
});
|
});
|
||||||
@ -1,83 +1,12 @@
|
|||||||
require(["jquery", "bsAlert", "csrfToken", "validation"], function ($, bsAlert, csrfTokenHeader) {
|
require(["jquery", "bsAlert", "csrfToken", "validator"], function ($, bsAlert, csrfTokenHeader) {
|
||||||
$("#register-form")
|
$('form').validator().on('submit', function (e) {
|
||||||
.formValidation({
|
if (!e.isDefaultPrevented()) {
|
||||||
framework: "bootstrap",
|
|
||||||
fields: {
|
|
||||||
username: {
|
|
||||||
validators: {
|
|
||||||
notEmpty: {
|
|
||||||
message: "请填写用户名"
|
|
||||||
},
|
|
||||||
stringLength: {
|
|
||||||
min: 3,
|
|
||||||
max: 30,
|
|
||||||
message: '用户名长度必须在3到30位之间'
|
|
||||||
},
|
|
||||||
remote: {
|
|
||||||
message: "用户名已存在",
|
|
||||||
url: "/api/username_check/",
|
|
||||||
field: 'username'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
password: {
|
|
||||||
validators: {
|
|
||||||
notEmpty: {
|
|
||||||
message: "请填写密码"
|
|
||||||
},
|
|
||||||
stringLength: {
|
|
||||||
min: 6,
|
|
||||||
max: 30,
|
|
||||||
message: '密码长度必须在6到30位之间'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onSuccess: function (e, data) {
|
|
||||||
data.fv.revalidateField('confirm_password');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
real_name: {
|
|
||||||
validators: {
|
|
||||||
notEmpty: {
|
|
||||||
message: "请填写真实姓名"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
confirm_password: {
|
|
||||||
validators: {
|
|
||||||
notEmpty: {
|
|
||||||
message: "请填写确认密码"
|
|
||||||
},
|
|
||||||
confirm: {
|
|
||||||
original: $("#password"),
|
|
||||||
message: "两次输入的密码必须一致"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
email: {
|
|
||||||
validators: {
|
|
||||||
notEmpty: {
|
|
||||||
message: "请填写电子邮箱邮箱地址"
|
|
||||||
},
|
|
||||||
emailAddress: {
|
|
||||||
message: "请填写有效的邮箱地址"
|
|
||||||
},
|
|
||||||
remote: {
|
|
||||||
message: "您已经注册过了",
|
|
||||||
url: "/api/email_check/",
|
|
||||||
field: 'email'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
).on('success.form.fv', function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
var username = $("#username").val();
|
var username = $("#username").val();
|
||||||
var realName = $("#real_name").val();
|
var realName = $("#real_name").val();
|
||||||
var password = $("#password").val();
|
var password = $("#password").val();
|
||||||
var email = $("#email").val();
|
var email = $("#email").val();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
beforeSend: csrfHeader,
|
beforeSend: csrfTokenHeader,
|
||||||
url: "/api/register/",
|
url: "/api/register/",
|
||||||
data: {username: username, real_name: realName, password: password, email: email},
|
data: {username: username, real_name: realName, password: password, email: email},
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
@ -90,6 +19,8 @@ require(["jquery", "bsAlert", "csrfToken", "validation"], function ($, bsAlert,
|
|||||||
bsAlert(data.data);
|
bsAlert(data.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
|
||||||
});
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
})
|
||||||
});
|
});
|
||||||
@ -53,7 +53,14 @@ require(["jquery", "codeMirror", "csrfToken", "bsAlert"], function ($, codeMirro
|
|||||||
return html;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var counter = 0;
|
||||||
|
|
||||||
function getResult() {
|
function getResult() {
|
||||||
|
if(counter++ > 10){
|
||||||
|
hideLoading();
|
||||||
|
bsAlert("抱歉,服务器可能出现了故障,请稍后到我的提交列表中查看");
|
||||||
|
return;
|
||||||
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/api/submission/?submission_id=" + submissionId,
|
url: "/api/submission/?submission_id=" + submissionId,
|
||||||
method: "get",
|
method: "get",
|
||||||
@ -85,7 +92,7 @@ require(["jquery", "codeMirror", "csrfToken", "bsAlert"], function ($, codeMirro
|
|||||||
showLoading();
|
showLoading();
|
||||||
|
|
||||||
if(!code.trim()){
|
if(!code.trim()){
|
||||||
bs_alert("请填写代码!");
|
bsAlert("请填写代码!");
|
||||||
hideLoading();
|
hideLoading();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,6 +19,7 @@ var require = {
|
|||||||
jqueryUI: "lib/jqueryUI/jquery-ui",
|
jqueryUI: "lib/jqueryUI/jquery-ui",
|
||||||
bootstrap: "lib/bootstrap/bootstrap",
|
bootstrap: "lib/bootstrap/bootstrap",
|
||||||
datetimePicker: "lib/datetime_picker/bootstrap-datetimepicker.zh-CN",
|
datetimePicker: "lib/datetime_picker/bootstrap-datetimepicker.zh-CN",
|
||||||
|
validator: "lib/validator/validator",
|
||||||
|
|
||||||
|
|
||||||
// ------ 下面写的都不要直接用,而是使用上面的封装版本 ------
|
// ------ 下面写的都不要直接用,而是使用上面的封装版本 ------
|
||||||
@ -55,6 +56,7 @@ var require = {
|
|||||||
shim: {
|
shim: {
|
||||||
bootstrap: {deps: ["jquery"]},
|
bootstrap: {deps: ["jquery"]},
|
||||||
_datetimePicker: {dep: ["jquery"]},
|
_datetimePicker: {dep: ["jquery"]},
|
||||||
datetimePicker: {deps: ["_datetimePicker"]}
|
datetimePicker: {deps: ["_datetimePicker"]},
|
||||||
|
validator: ["jquery"]
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
325
static/src/js/lib/validator/validator.js
Normal file
325
static/src/js/lib/validator/validator.js
Normal file
@ -0,0 +1,325 @@
|
|||||||
|
/* ========================================================================
|
||||||
|
* Bootstrap (plugin): validator.js v0.9.0
|
||||||
|
* ========================================================================
|
||||||
|
* The MIT License (MIT)
|
||||||
|
*
|
||||||
|
* Copyright (c) 2015 Cina Saffary.
|
||||||
|
* Made by @1000hz in the style of Bootstrap 3 era @fat
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
|
* in the Software without restriction, including without limitation the rights
|
||||||
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the Software is
|
||||||
|
* furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
* THE SOFTWARE.
|
||||||
|
* ======================================================================== */
|
||||||
|
|
||||||
|
|
||||||
|
+function ($) {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// VALIDATOR CLASS DEFINITION
|
||||||
|
// ==========================
|
||||||
|
|
||||||
|
var Validator = function (element, options) {
|
||||||
|
this.$element = $(element)
|
||||||
|
this.options = options
|
||||||
|
|
||||||
|
options.errors = $.extend({}, Validator.DEFAULTS.errors, options.errors)
|
||||||
|
|
||||||
|
for (var custom in options.custom) {
|
||||||
|
if (!options.errors[custom]) throw new Error('Missing default error message for custom validator: ' + custom)
|
||||||
|
}
|
||||||
|
|
||||||
|
$.extend(Validator.VALIDATORS, options.custom)
|
||||||
|
|
||||||
|
this.$element.attr('novalidate', true) // disable automatic native validation
|
||||||
|
this.toggleSubmit()
|
||||||
|
|
||||||
|
this.$element.on('input.bs.validator change.bs.validator focusout.bs.validator', $.proxy(this.validateInput, this))
|
||||||
|
this.$element.on('submit.bs.validator', $.proxy(this.onSubmit, this))
|
||||||
|
|
||||||
|
this.$element.find('[data-match]').each(function () {
|
||||||
|
var $this = $(this)
|
||||||
|
var target = $this.data('match')
|
||||||
|
|
||||||
|
$(target).on('input.bs.validator', function (e) {
|
||||||
|
$this.val() && $this.trigger('input.bs.validator')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
Validator.INPUT_SELECTOR = ':input:not([type="submit"], button):enabled:visible'
|
||||||
|
|
||||||
|
Validator.DEFAULTS = {
|
||||||
|
delay: 500,
|
||||||
|
html: false,
|
||||||
|
disable: true,
|
||||||
|
custom: {},
|
||||||
|
errors: {
|
||||||
|
match: 'Does not match',
|
||||||
|
minlength: 'Not long enough'
|
||||||
|
},
|
||||||
|
feedback: {
|
||||||
|
success: 'glyphicon-ok',
|
||||||
|
error: 'glyphicon-remove'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Validator.VALIDATORS = {
|
||||||
|
'native': function ($el) {
|
||||||
|
var el = $el[0]
|
||||||
|
return el.checkValidity ? el.checkValidity() : true
|
||||||
|
},
|
||||||
|
'match': function ($el) {
|
||||||
|
var target = $el.data('match')
|
||||||
|
return !$el.val() || $el.val() === $(target).val()
|
||||||
|
},
|
||||||
|
'minlength': function ($el) {
|
||||||
|
var minlength = $el.data('minlength')
|
||||||
|
return !$el.val() || $el.val().length >= minlength
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Validator.prototype.validateInput = function (e) {
|
||||||
|
var $el = $(e.target)
|
||||||
|
var prevErrors = $el.data('bs.validator.errors')
|
||||||
|
var errors
|
||||||
|
|
||||||
|
if ($el.is('[type="radio"]')) $el = this.$element.find('input[name="' + $el.attr('name') + '"]')
|
||||||
|
|
||||||
|
this.$element.trigger(e = $.Event('validate.bs.validator', {relatedTarget: $el[0]}))
|
||||||
|
|
||||||
|
if (e.isDefaultPrevented()) return
|
||||||
|
|
||||||
|
var self = this
|
||||||
|
|
||||||
|
this.runValidators($el).done(function (errors) {
|
||||||
|
$el.data('bs.validator.errors', errors)
|
||||||
|
|
||||||
|
errors.length ? self.showErrors($el) : self.clearErrors($el)
|
||||||
|
|
||||||
|
if (!prevErrors || errors.toString() !== prevErrors.toString()) {
|
||||||
|
e = errors.length
|
||||||
|
? $.Event('invalid.bs.validator', {relatedTarget: $el[0], detail: errors})
|
||||||
|
: $.Event('valid.bs.validator', {relatedTarget: $el[0], detail: prevErrors})
|
||||||
|
|
||||||
|
self.$element.trigger(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
self.toggleSubmit()
|
||||||
|
|
||||||
|
self.$element.trigger($.Event('validated.bs.validator', {relatedTarget: $el[0]}))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Validator.prototype.runValidators = function ($el) {
|
||||||
|
var errors = []
|
||||||
|
var deferred = $.Deferred()
|
||||||
|
var options = this.options
|
||||||
|
|
||||||
|
$el.data('bs.validator.deferred') && $el.data('bs.validator.deferred').reject()
|
||||||
|
$el.data('bs.validator.deferred', deferred)
|
||||||
|
|
||||||
|
function getErrorMessage(key) {
|
||||||
|
return $el.data(key + '-error')
|
||||||
|
|| $el.data('error')
|
||||||
|
|| key == 'native' && $el[0].validationMessage
|
||||||
|
|| options.errors[key]
|
||||||
|
}
|
||||||
|
|
||||||
|
$.each(Validator.VALIDATORS, $.proxy(function (key, validator) {
|
||||||
|
if (($el.data(key) || key == 'native') && !validator.call(this, $el)) {
|
||||||
|
var error = getErrorMessage(key)
|
||||||
|
!~errors.indexOf(error) && errors.push(error)
|
||||||
|
}
|
||||||
|
}, this))
|
||||||
|
|
||||||
|
if (!errors.length && $el.val() && $el.data('remote')) {
|
||||||
|
this.defer($el, function () {
|
||||||
|
var data = {}
|
||||||
|
data[$el.attr('name')] = $el.val()
|
||||||
|
$.get($el.data('remote'), data)
|
||||||
|
.fail(function (jqXHR, textStatus, error) { errors.push(getErrorMessage('remote') || error) })
|
||||||
|
.always(function () { deferred.resolve(errors)})
|
||||||
|
})
|
||||||
|
} else deferred.resolve(errors)
|
||||||
|
|
||||||
|
return deferred.promise()
|
||||||
|
}
|
||||||
|
|
||||||
|
Validator.prototype.validate = function () {
|
||||||
|
var delay = this.options.delay
|
||||||
|
|
||||||
|
this.options.delay = 0
|
||||||
|
this.$element.find(Validator.INPUT_SELECTOR).trigger('input.bs.validator')
|
||||||
|
this.options.delay = delay
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
Validator.prototype.showErrors = function ($el) {
|
||||||
|
var method = this.options.html ? 'html' : 'text'
|
||||||
|
|
||||||
|
this.defer($el, function () {
|
||||||
|
var $group = $el.closest('.form-group')
|
||||||
|
var $block = $group.find('.help-block.with-errors')
|
||||||
|
var $feedback = $group.find('.form-control-feedback')
|
||||||
|
var errors = $el.data('bs.validator.errors')
|
||||||
|
|
||||||
|
if (!errors.length) return
|
||||||
|
|
||||||
|
errors = $('<ul/>')
|
||||||
|
.addClass('list-unstyled')
|
||||||
|
.append($.map(errors, function (error) { return $('<li/>')[method](error) }))
|
||||||
|
|
||||||
|
$block.data('bs.validator.originalContent') === undefined && $block.data('bs.validator.originalContent', $block.html())
|
||||||
|
$block.empty().append(errors)
|
||||||
|
$group.addClass('has-error')
|
||||||
|
|
||||||
|
$feedback.length
|
||||||
|
&& $feedback.removeClass(this.options.feedback.success)
|
||||||
|
&& $feedback.addClass(this.options.feedback.error)
|
||||||
|
&& $group.removeClass('has-success')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
Validator.prototype.clearErrors = function ($el) {
|
||||||
|
var $group = $el.closest('.form-group')
|
||||||
|
var $block = $group.find('.help-block.with-errors')
|
||||||
|
var $feedback = $group.find('.form-control-feedback')
|
||||||
|
|
||||||
|
$block.html($block.data('bs.validator.originalContent'))
|
||||||
|
$group.removeClass('has-error')
|
||||||
|
|
||||||
|
$feedback.length
|
||||||
|
&& $feedback.removeClass(this.options.feedback.error)
|
||||||
|
&& $feedback.addClass(this.options.feedback.success)
|
||||||
|
&& $group.addClass('has-success')
|
||||||
|
}
|
||||||
|
|
||||||
|
Validator.prototype.hasErrors = function () {
|
||||||
|
function fieldErrors() {
|
||||||
|
return !!($(this).data('bs.validator.errors') || []).length
|
||||||
|
}
|
||||||
|
|
||||||
|
return !!this.$element.find(Validator.INPUT_SELECTOR).filter(fieldErrors).length
|
||||||
|
}
|
||||||
|
|
||||||
|
Validator.prototype.isIncomplete = function () {
|
||||||
|
function fieldIncomplete() {
|
||||||
|
return this.type === 'checkbox' ? !this.checked :
|
||||||
|
this.type === 'radio' ? !$('[name="' + this.name + '"]:checked').length :
|
||||||
|
$.trim(this.value) === ''
|
||||||
|
}
|
||||||
|
|
||||||
|
return !!this.$element.find(Validator.INPUT_SELECTOR).filter('[required]').filter(fieldIncomplete).length
|
||||||
|
}
|
||||||
|
|
||||||
|
Validator.prototype.onSubmit = function (e) {
|
||||||
|
this.validate()
|
||||||
|
if (this.isIncomplete() || this.hasErrors()) e.preventDefault()
|
||||||
|
}
|
||||||
|
|
||||||
|
Validator.prototype.toggleSubmit = function () {
|
||||||
|
if(!this.options.disable) return
|
||||||
|
|
||||||
|
var $btn = $('button[type="submit"], input[type="submit"]')
|
||||||
|
.filter('[form="' + this.$element.attr('id') + '"]')
|
||||||
|
.add(this.$element.find('input[type="submit"], button[type="submit"]'))
|
||||||
|
|
||||||
|
$btn.toggleClass('disabled', this.isIncomplete() || this.hasErrors())
|
||||||
|
}
|
||||||
|
|
||||||
|
Validator.prototype.defer = function ($el, callback) {
|
||||||
|
callback = $.proxy(callback, this)
|
||||||
|
if (!this.options.delay) return callback()
|
||||||
|
window.clearTimeout($el.data('bs.validator.timeout'))
|
||||||
|
$el.data('bs.validator.timeout', window.setTimeout(callback, this.options.delay))
|
||||||
|
}
|
||||||
|
|
||||||
|
Validator.prototype.destroy = function () {
|
||||||
|
this.$element
|
||||||
|
.removeAttr('novalidate')
|
||||||
|
.removeData('bs.validator')
|
||||||
|
.off('.bs.validator')
|
||||||
|
|
||||||
|
this.$element.find(Validator.INPUT_SELECTOR)
|
||||||
|
.off('.bs.validator')
|
||||||
|
.removeData(['bs.validator.errors', 'bs.validator.deferred'])
|
||||||
|
.each(function () {
|
||||||
|
var $this = $(this)
|
||||||
|
var timeout = $this.data('bs.validator.timeout')
|
||||||
|
window.clearTimeout(timeout) && $this.removeData('bs.validator.timeout')
|
||||||
|
})
|
||||||
|
|
||||||
|
this.$element.find('.help-block.with-errors').each(function () {
|
||||||
|
var $this = $(this)
|
||||||
|
var originalContent = $this.data('bs.validator.originalContent')
|
||||||
|
|
||||||
|
$this
|
||||||
|
.removeData('bs.validator.originalContent')
|
||||||
|
.html(originalContent)
|
||||||
|
})
|
||||||
|
|
||||||
|
this.$element.find('input[type="submit"], button[type="submit"]').removeClass('disabled')
|
||||||
|
|
||||||
|
this.$element.find('.has-error').removeClass('has-error')
|
||||||
|
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
// VALIDATOR PLUGIN DEFINITION
|
||||||
|
// ===========================
|
||||||
|
|
||||||
|
|
||||||
|
function Plugin(option) {
|
||||||
|
return this.each(function () {
|
||||||
|
var $this = $(this)
|
||||||
|
var options = $.extend({}, Validator.DEFAULTS, $this.data(), typeof option == 'object' && option)
|
||||||
|
var data = $this.data('bs.validator')
|
||||||
|
|
||||||
|
if (!data && option == 'destroy') return
|
||||||
|
if (!data) $this.data('bs.validator', (data = new Validator(this, options)))
|
||||||
|
if (typeof option == 'string') data[option]()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
var old = $.fn.validator
|
||||||
|
|
||||||
|
$.fn.validator = Plugin
|
||||||
|
$.fn.validator.Constructor = Validator
|
||||||
|
|
||||||
|
|
||||||
|
// VALIDATOR NO CONFLICT
|
||||||
|
// =====================
|
||||||
|
|
||||||
|
$.fn.validator.noConflict = function () {
|
||||||
|
$.fn.validator = old
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// VALIDATOR DATA-API
|
||||||
|
// ==================
|
||||||
|
|
||||||
|
$(window).on('load', function () {
|
||||||
|
$('form[data-toggle="validator"]').each(function () {
|
||||||
|
var $form = $(this)
|
||||||
|
Plugin.call($form, $form.data())
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
}(jQuery);
|
||||||
@ -44,7 +44,12 @@ class SubmissionAPIView(APIView):
|
|||||||
return error_response(u"题目不存在")
|
return error_response(u"题目不存在")
|
||||||
collection = _create_mongodb_connection()
|
collection = _create_mongodb_connection()
|
||||||
submission_id = str(collection.insert_one(data).inserted_id)
|
submission_id = str(collection.insert_one(data).inserted_id)
|
||||||
|
|
||||||
|
try:
|
||||||
judge.delay(submission_id, problem.time_limit, problem.memory_limit, problem.test_case_id)
|
judge.delay(submission_id, problem.time_limit, problem.memory_limit, problem.test_case_id)
|
||||||
|
except Exception:
|
||||||
|
return error_response(u"提交判题任务失败")
|
||||||
|
|
||||||
return success_response({"submission_id": submission_id})
|
return success_response({"submission_id": submission_id})
|
||||||
else:
|
else:
|
||||||
return serializer_invalid_response(serializer)
|
return serializer_invalid_response(serializer)
|
||||||
|
|||||||
@ -7,22 +7,23 @@
|
|||||||
<form id="change_password-form">
|
<form id="change_password-form">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="username">用户名</label>
|
<label for="username">用户名</label>
|
||||||
<input type="text" class="form-control input-lg" id="username" name="username" placeholder="用户名"
|
<input type="text" class="form-control input-lg" id="username" name="username" placeholder="用户名" data-error="请填写用户名" maxlength="30" autofocus required>
|
||||||
autofocus>
|
<div class="help-block with-errors"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="password">旧密码</label>
|
<label for="password">旧密码</label>
|
||||||
<input type="password" class="form-control input-lg" id="password" name="password" placeholder="密码">
|
<input type="password" class="form-control input-lg" id="password" name="password" placeholder="密码" data-error="请填写旧密码" maxlength="30" required>
|
||||||
|
<div class="help-block with-errors"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="new_password">新密码</label>
|
<label for="new_password">新密码</label>
|
||||||
<input type="password" class="form-control input-lg" id="new_password" name="new_password"
|
<input type="password" class="form-control input-lg" id="new_password" name="new_password" placeholder="新密码" maxlength="30" data-minlength="6" data-error="密码不得少于6位" required>
|
||||||
placeholder="新密码">
|
<div class="help-block with-errors"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="confirm_password">确认密码</label>
|
<label for="confirm_password">确认密码</label>
|
||||||
<input type="password" class="form-control input-lg" id="confirm_password" name="confirm_password"
|
<input type="password" class="form-control input-lg" id="confirm_password" name="confirm_password" placeholder="确认密码" maxlength="30" data-match="#new_password" data-match-error="两个密码不一致" require>
|
||||||
placeholder="确认密码">
|
<div class="help-block with-errors"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button type="submit" class="btn btn-primary">提交</button>
|
<button type="submit" class="btn btn-primary">提交</button>
|
||||||
|
|||||||
@ -7,12 +7,13 @@
|
|||||||
<form id="login-form">
|
<form id="login-form">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="username">用户名</label>
|
<label for="username">用户名</label>
|
||||||
<input type="text" class="form-control input-lg" id="username" name="username" placeholder="用户名"
|
<input type="text" class="form-control input-lg" id="username" name="username" maxlength="30" data-error="请填写用户名" placeholder="用户名" autofocus required>
|
||||||
autofocus>
|
<div class="help-block with-errors"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="password">密码</label>
|
<label for="password">密码</label>
|
||||||
<input type="password" class="form-control input-lg" id="password" name="password" placeholder="密码">
|
<input type="password" class="form-control input-lg" id="password" name="password" maxlength="30" data-error="请填写密码" placeholder="密码" required>
|
||||||
|
<div class="help-block with-errors"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button type="submit" class="btn btn-primary">提交</button>
|
<button type="submit" class="btn btn-primary">提交</button>
|
||||||
|
|||||||
@ -7,25 +7,29 @@
|
|||||||
<form id="register-form">
|
<form id="register-form">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="username">用户名</label>
|
<label for="username">用户名</label>
|
||||||
<input type="text" class="form-control input-lg" id="username" name="username" placeholder="用户名"
|
<input type="text" class="form-control input-lg" id="username" name="username" placeholder="用户名" data-error="请输入用户名" required autofocus>
|
||||||
autofocus>
|
<div class="help-block with-errors"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="real_name">真实姓名</label>
|
<label for="real_name">真实姓名</label>
|
||||||
<input type="text" class="form-control input-lg" id="real_name" name="real_name" placeholder="真实姓名">
|
<input type="text" class="form-control input-lg" id="real_name" name="real_name" placeholder="真实姓名" data-error="请输入姓名" required>
|
||||||
|
<div class="help-block with-errors"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="email">邮箱地址</label>
|
<label for="email">邮箱地址</label>
|
||||||
<input type="email" class="form-control input-lg" id="email" name="email" placeholder="邮箱地址">
|
<input type="email" class="form-control input-lg" id="email" name="email" placeholder="邮箱地址" data-error="请填写邮箱" required>
|
||||||
|
<div class="help-block with-errors"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="password">密码</label>
|
<label for="password">密码</label>
|
||||||
<input type="password" class="form-control input-lg" id="password" name="password" placeholder="密码">
|
<input type="password" class="form-control input-lg" id="password" name="password" placeholder="密码" data-minlength="6" data-minlength-error="密码不得少于6位" required>
|
||||||
|
<div class="help-block with-errors"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="confirm_password">确认密码</label>
|
<label for="confirm_password">确认密码</label>
|
||||||
<input type="password" class="form-control input-lg" id="confirm_password" name="confirm_password"
|
<input type="password" class="form-control input-lg" id="confirm_password" name="confirm_password"
|
||||||
placeholder="确认密码">
|
placeholder="确认密码" data-match="#password" data-match-error="两个密码不一致" required>
|
||||||
|
<div class="help-block with-errors"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button type="submit" class="btn btn-primary">提交</button>
|
<button type="submit" class="btn btn-primary">提交</button>
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
{% block css_block %}{% endblock %}
|
{% block css_block %}{% endblock %}
|
||||||
<!-- custom css end -->
|
<!-- custom css end -->
|
||||||
</head>
|
</head>
|
||||||
|
{% load website_info %}
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
@ -38,7 +38,7 @@
|
|||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
<span class="icon-bar"></span>
|
<span class="icon-bar"></span>
|
||||||
</button>
|
</button>
|
||||||
<a class="navbar-brand" href="/">qduoj</a>
|
<a class="navbar-brand" href="/">{% show_website_info "website_name" %}</a>
|
||||||
</div>
|
</div>
|
||||||
<div id="navbar" class="navbar-collapse collapse">
|
<div id="navbar" class="navbar-collapse collapse">
|
||||||
<ul class="nav navbar-nav">
|
<ul class="nav navbar-nav">
|
||||||
@ -88,7 +88,7 @@
|
|||||||
{% block js_block %}{% endblock %}
|
{% block js_block %}{% endblock %}
|
||||||
<!-- footer begin -->
|
<!-- footer begin -->
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<p class="text-muted text-center">Copyright © 2015 青岛大学信息工程学院 创新实验室</p>
|
<p class="text-muted text-center">Copyright © 2015 {% show_website_info "website_footer" %}</p>
|
||||||
</div>
|
</div>
|
||||||
<!-- footer end -->
|
<!-- footer end -->
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
|
from django import template
|
||||||
|
|
||||||
|
|
||||||
def translate_result(value):
|
def translate_result(value):
|
||||||
@ -27,14 +28,11 @@ def translate_language(value):
|
|||||||
def translate_result_class(value):
|
def translate_result_class(value):
|
||||||
if value == 0:
|
if value == 0:
|
||||||
return "success"
|
return "success"
|
||||||
elif value == "8":
|
elif value == 8:
|
||||||
return "info"
|
return "info"
|
||||||
return "danger"
|
return "danger"
|
||||||
|
|
||||||
|
|
||||||
from django import template
|
|
||||||
|
|
||||||
|
|
||||||
register = template.Library()
|
register = template.Library()
|
||||||
register.filter("translate_result", translate_result)
|
register.filter("translate_result", translate_result)
|
||||||
register.filter("translate_id", translate_id)
|
register.filter("translate_id", translate_id)
|
||||||
|
|||||||
8
utils/templatetags/website_info.py
Normal file
8
utils/templatetags/website_info.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# coding=utf-8
|
||||||
|
from django import template
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
|
||||||
|
@register.simple_tag
|
||||||
|
def show_website_info(name):
|
||||||
|
return {"website_name": "qduoj", "website_footer": u"青岛大学信息工程学院 创新实验室"}[name]
|
||||||
Loading…
Reference in New Issue
Block a user