Merge branch 'dev' into virusdefender-dev
* dev: (38 commits) with open() as 语句添加try&except,返回上传错误 添加缓存用redis的配置 [后台-前端]修改添加比赛,编辑比赛页面,添加封榜功能(在页面中被称作实时排名)若设置比赛非实时排名那么前端rank页面缓存将停止刷新,从而实现封榜功能[CI SKIP] migrate:contest.models字段改名----show_rank => real_time_rank 添加控制比赛排名更新的字段 统一创建比赛,编辑比赛的时候小组可见的交互逻辑和界面[CI SKIP] 修正server_setting中typo和urls里别扭的拼写 修改.gitignore,忽略富文本编辑器上传的图片,删掉刚刚不小心commit的图片[CI SKIP] 新建存放富文本编辑器上传的图片的文件夹[CI SKIP] 添加了富文本编辑器上传图片的功能,上传路径在setting_loacl和server里暂时在static/src/upload_image/ 修复冲突,忘记去掉冲突标志了。。。 [后台-前端]主要修改了添加比赛和修改比赛的部分,去掉比赛结束前开放排名这一选项,添加封榜时间字段[CI SKIP] [后台-前端]去掉了比赛中的是否开放排名选 项,天加封榜时间字段[CI SKIP] 添加前台比赛提交列表中管理员可见比赛提交详情 刚刚不小心把两个文件粘一起了,原来的忘清了。。。 修复超级管理员比赛提交页面的样式“ 合并dev,添加管理员在前台可见比赛所有提交详情,修改措辞,修改提示形式,以便于提交列表筛选功能的使用 修复题目,比赛题目列表里描述和提示的内容没有包裹在 problem-detail里的问题,实际上源代码里他们被包裹在<p clas s='problem-detail'>里但是实际显示的却是在标签外部,不理解.把p改成div就好了~ 其实没有更改,跟origin dev-sxw保持一致,因为刚刚git pull的时候出错了 修改了宽松判题模式中对超时的处理,否则超时将被判为runTimeError[CI SKIP] ... Conflicts: judge/judger/loose_client.py
This commit is contained in:
@@ -2,40 +2,46 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "date
|
||||
"validator"],
|
||||
function ($, avalon, editor, uploader, bsAlert, csrfTokenHeader) {
|
||||
|
||||
//avalon.vmodels.add_contest = null;
|
||||
$("#add-contest-form").validator().on('submit', function (e) {
|
||||
if (!e.isDefaultPrevented()){
|
||||
if (!e.isDefaultPrevented()) {
|
||||
e.preventDefault();
|
||||
var ajaxData = {
|
||||
title: vm.title,
|
||||
description: vm.description,
|
||||
mode: vm.mode,
|
||||
contest_type: 0,
|
||||
show_rank: vm.showRank,
|
||||
real_time_rank: vm.realTimeRank,
|
||||
show_user_submission: vm.showSubmission,
|
||||
start_time: vm.startTime,
|
||||
end_time: vm.endTime,
|
||||
visible: false
|
||||
};
|
||||
if (vm.choseGroupList.length == 0) {
|
||||
bsAlert("你没有选择参赛用户!");
|
||||
return false;
|
||||
|
||||
var selectedGroups = [];
|
||||
if (!vm.isGlobal) {
|
||||
for (var i = 0; i < vm.allGroups.length; i++) {
|
||||
if (vm.allGroups[i].isSelected) {
|
||||
selectedGroups.push(vm.allGroups[i].id);
|
||||
}
|
||||
}
|
||||
ajaxData.groups = selectedGroups;
|
||||
}
|
||||
if (vm.choseGroupList[0].id == 0) { //everyone | public contest
|
||||
else {
|
||||
if (vm.password) {
|
||||
ajaxData.password = vm.password;
|
||||
ajaxData.contest_type = 2;
|
||||
}
|
||||
else{
|
||||
else
|
||||
ajaxData.contest_type = 1;
|
||||
}
|
||||
}
|
||||
else { // Add groups info
|
||||
ajaxData.groups = [];
|
||||
for (var i = 0; vm.choseGroupList[i]; i++)
|
||||
ajaxData.groups.push(parseInt(vm.choseGroupList[i].id))
|
||||
if (!vm.isGlobal && !selectedGroups.length) {
|
||||
bsAlert("你没有选择参赛用户!");
|
||||
return false;
|
||||
}
|
||||
if (vm.editDescription == "") {
|
||||
bsAlert("比赛描述不能为空!");
|
||||
return false;
|
||||
}
|
||||
|
||||
$.ajax({ // Add contest
|
||||
beforeSend: csrfTokenHeader,
|
||||
url: "/api/admin/contest/",
|
||||
@@ -45,20 +51,18 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "date
|
||||
method: "post",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
bsAlert("添加成功!将转到比赛列表页以便为比赛添加问题(注意比赛当前状态为:隐藏)");
|
||||
vm.title = "";
|
||||
vm.description = "";
|
||||
vm.startTime = "";
|
||||
vm.endTime = "";
|
||||
vm.password = "";
|
||||
vm.mode = "";
|
||||
vm.showRank = false;
|
||||
vm.showSubmission = false;
|
||||
vm.group = "-1";
|
||||
vm.groupList = [];
|
||||
vm.choseGroupList = [];
|
||||
vm.passwordUsable = false;
|
||||
location.hash = "#contest/contest_list";
|
||||
bsAlert("添加成功!将转到比赛列表页以便为比赛添加问题(注意比赛当前状态为:隐藏)");
|
||||
vm.title = "";
|
||||
vm.description = "";
|
||||
vm.startTime = "";
|
||||
vm.endTime = "";
|
||||
vm.password = "";
|
||||
vm.mode = "0";
|
||||
vm.showSubmission = true;
|
||||
location.hash = "#contest/contest_list";
|
||||
vm.isGlobal = true;
|
||||
vm.allGroups = [];
|
||||
vm.showGlobalViewRadio = true;
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
@@ -70,80 +74,59 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "date
|
||||
});
|
||||
|
||||
editor("#editor");
|
||||
if (avalon.vmodels.add_contest)
|
||||
var vm = avalon.vmodels.add_contest;
|
||||
else
|
||||
var vm = avalon.define({
|
||||
$id: "add_contest",
|
||||
title: "",
|
||||
description: "",
|
||||
startTime: "",
|
||||
endTime: "",
|
||||
password: "",
|
||||
mode: "",
|
||||
showRank: false,
|
||||
showSubmission: false,
|
||||
group: "-1",
|
||||
groupList: [],
|
||||
choseGroupList: [],
|
||||
passwordUsable: false,
|
||||
addGroup: function() {
|
||||
if (vm.group == -1) return;
|
||||
if (vm.groupList[vm.group].id == 0){
|
||||
vm.passwordUsable = true;
|
||||
vm.choseGroupList = [];
|
||||
for (var key in vm.groupList){
|
||||
vm.groupList[key].chose = true;
|
||||
}
|
||||
}
|
||||
vm.groupList[vm.group]. chose = true;
|
||||
vm.choseGroupList.push({name:vm.groupList[vm.group].name, index:vm.group, id:vm.groupList[vm.group].id});
|
||||
vm.group = -1;
|
||||
},
|
||||
removeGroup: function(groupIndex){
|
||||
if (vm.groupList[vm.choseGroupList[groupIndex].index].id == 0){
|
||||
vm.passwordUsable = false;
|
||||
for (key in vm.groupList){
|
||||
vm.groupList[key].chose = false;
|
||||
}
|
||||
}
|
||||
vm.groupList[vm.choseGroupList[groupIndex].index].chose = false;
|
||||
vm.choseGroupList.remove(vm.choseGroupList[groupIndex]);
|
||||
}
|
||||
});
|
||||
if (avalon.vmodels.add_contest)
|
||||
var vm = avalon.vmodels.add_contest;
|
||||
else
|
||||
var vm = avalon.define({
|
||||
$id: "add_contest",
|
||||
title: "",
|
||||
description: "",
|
||||
startTime: "",
|
||||
endTime: "",
|
||||
password: "",
|
||||
mode: "0",
|
||||
showSubmission: true,
|
||||
isGlobal: true,
|
||||
allGroups: [],
|
||||
showGlobalViewRadio: true,
|
||||
realTimeRank: true
|
||||
});
|
||||
|
||||
$.ajax({ // Get current user type
|
||||
$.ajax({
|
||||
url: "/api/user/",
|
||||
method: "get",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
if (data.data.admin_type == 2) { // Is super user
|
||||
vm.isGlobal = true;
|
||||
vm.groupList.push({id:0,name:"所有人",chose:false});
|
||||
var admin_type = data.data.admin_type;
|
||||
if (data.data.admin_type == 1) {
|
||||
vm.isGlobal = false;
|
||||
vm.showGlobalViewRadio = false;
|
||||
|
||||
}
|
||||
$.ajax({ // Get the group list of current user
|
||||
beforeSend: csrfTokenHeader,
|
||||
url: "/api/admin/group/",
|
||||
method: "get",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
if (!data.data.length) {
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < data.data.length; i++) {
|
||||
var item = data.data[i];
|
||||
item["chose"] = false;
|
||||
vm.groupList.push(item);
|
||||
}
|
||||
}
|
||||
$.ajax({
|
||||
url: "/api/admin/group/",
|
||||
method: "get",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
if (!data.data.length) {
|
||||
if (admin_type != 2)
|
||||
bsAlert("您的用户权限只能创建小组内比赛,但是您还没有创建过小组");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
for (var i = 0; i < data.data.length; i++) {
|
||||
var item = data.data[i];
|
||||
item["isSelected"] = false;
|
||||
vm.allGroups.push(item);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -3,21 +3,39 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker",
|
||||
avalon.ready(function () {
|
||||
|
||||
$("#edit-contest-form").validator().on('submit', function (e) {
|
||||
if (!e.isDefaultPrevented()){
|
||||
if (!e.isDefaultPrevented()) {
|
||||
e.preventDefault();
|
||||
var ajaxData = {
|
||||
id: vm.contestList[vm.editingContestId-1].id,
|
||||
title: vm.editTitle,
|
||||
description: vm.editDescription,
|
||||
mode: vm.editMode,
|
||||
contest_type: 0,
|
||||
show_rank: vm.editShowRank,
|
||||
id: vm.contestList[vm.editingContestId - 1].id,
|
||||
title: vm.editTitle,
|
||||
description: vm.editDescription,
|
||||
mode: vm.editMode,
|
||||
contest_type: 0,
|
||||
real_time_rank: vm.editRealTimeRank,
|
||||
show_user_submission: vm.editShowSubmission,
|
||||
start_time: vm.editStartTime,
|
||||
end_time: vm.editEndTime,
|
||||
visible: vm.editVisible
|
||||
start_time: vm.editStartTime,
|
||||
end_time: vm.editEndTime,
|
||||
visible: vm.editVisible
|
||||
};
|
||||
if (vm.choseGroupList.length == 0) {
|
||||
|
||||
var selectedGroups = [];
|
||||
if (!vm.isGlobal) {
|
||||
for (var i = 0; i < vm.allGroups.length; i++) {
|
||||
if (vm.allGroups[i].isSelected) {
|
||||
selectedGroups.push(vm.allGroups[i].id);
|
||||
}
|
||||
}
|
||||
ajaxData.groups = selectedGroups;
|
||||
}
|
||||
else {
|
||||
if (vm.password) {
|
||||
ajaxData.password = vm.editPassword;
|
||||
ajaxData.contest_type = 2;
|
||||
}
|
||||
else
|
||||
ajaxData.contest_type = 1;
|
||||
}
|
||||
if (!vm.isGlobal && !selectedGroups.length) {
|
||||
bsAlert("你没有选择参赛用户!");
|
||||
return false;
|
||||
}
|
||||
@@ -25,22 +43,8 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker",
|
||||
bsAlert("比赛描述不能为空!");
|
||||
return false;
|
||||
}
|
||||
if (vm.choseGroupList[0].id == 0) { //everyone | public contest
|
||||
if (vm.editPassword) {
|
||||
ajaxData.password = vm.editPassword;
|
||||
ajaxData.contest_type = 2;
|
||||
}
|
||||
else{
|
||||
ajaxData.contest_type = 1;
|
||||
}
|
||||
}
|
||||
else { // Add groups info
|
||||
ajaxData.groups = [];
|
||||
for (var i = 0; vm.choseGroupList[i]; i++)
|
||||
ajaxData.groups.push(parseInt(vm.choseGroupList[i].id))
|
||||
}
|
||||
|
||||
$.ajax({ // Add contest
|
||||
$.ajax({ // modify contest info
|
||||
beforeSend: csrfTokenHeader,
|
||||
url: "/api/admin/contest/",
|
||||
dataType: "json",
|
||||
@@ -52,7 +56,7 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker",
|
||||
if (!data.code) {
|
||||
bsAlert("修改成功!");
|
||||
vm.editingContestId = 0; // Hide the editor
|
||||
vm.getPage(1); // Refresh the contest list
|
||||
vm.getPage(1); // Refresh the contest list
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
@@ -63,138 +67,124 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker",
|
||||
return false;
|
||||
});
|
||||
|
||||
if(avalon.vmodels.contestList){
|
||||
// this page has been loaded before, so set the default value
|
||||
var vm = avalon.vmodels.contestList;
|
||||
vm.contestList= [];
|
||||
vm.previousPage= 0;
|
||||
vm.nextPage= 0;
|
||||
vm.page= 1;
|
||||
vm.totalPage= 1;
|
||||
vm.group= "-1";
|
||||
vm.groupList= [];
|
||||
vm.choseGroupList= [];
|
||||
vm.passwordUsable= false;
|
||||
vm.keyword= "";
|
||||
vm.editingContestId= 0;
|
||||
vm.editTitle= "";
|
||||
vm.editDescription= "";
|
||||
vm.editProblemList= [];
|
||||
vm.editPassword= "";
|
||||
vm.editStartTime= "";
|
||||
vm.editEndTime= "";
|
||||
vm.editMode= "";
|
||||
vm.editShowRank= false;
|
||||
vm.editShowSubmission= false;
|
||||
vm.editProblemList= [];
|
||||
vm.editVisible= false;
|
||||
vm.editChoseGroupList= [];
|
||||
vm.editingProblemContestIndex= 0;
|
||||
}
|
||||
else {
|
||||
var vm = avalon.define({
|
||||
$id: "contestList",
|
||||
contestList: [],
|
||||
previousPage: 0,
|
||||
nextPage: 0,
|
||||
page: 1,
|
||||
totalPage: 1,
|
||||
showVisibleOnly: false,
|
||||
group: "-1",
|
||||
groupList: [],
|
||||
choseGroupList: [],
|
||||
passwordUsable: false,
|
||||
keyword: "",
|
||||
editingContestId: 0,
|
||||
editTitle: "",
|
||||
editDescription: "",
|
||||
editProblemList: [],
|
||||
editPassword: "",
|
||||
editStartTime: "",
|
||||
editEndTime: "",
|
||||
editMode: "",
|
||||
editShowRank: false,
|
||||
editShowSubmission: false,
|
||||
editProblemList: [],
|
||||
editVisible: false,
|
||||
editChoseGroupList: [],
|
||||
editingProblemContestIndex: 0,
|
||||
getNext: function () {
|
||||
if (!vm.nextPage)
|
||||
return;
|
||||
getPageData(vm.page + 1);
|
||||
},
|
||||
getPrevious: function () {
|
||||
if (!vm.previousPage)
|
||||
return;
|
||||
getPageData(vm.page - 1);
|
||||
},
|
||||
getBtnClass: function (btn) {
|
||||
if (btn == "next") {
|
||||
return vm.nextPage ? "btn btn-primary" : "btn btn-primary disabled";
|
||||
}
|
||||
else {
|
||||
return vm.previousPage ? "btn btn-primary" : "btn btn-primary disabled";
|
||||
}
|
||||
},
|
||||
getPage: function (page_index) {
|
||||
getPageData(page_index);
|
||||
},
|
||||
showEditContestArea: function (contestId) {
|
||||
if (vm.editingContestId && !confirm("如果继续将丢失未保存的信息,是否继续?"))
|
||||
return;
|
||||
if (contestId == vm.editingContestId)
|
||||
vm.editingContestId = 0;
|
||||
else {
|
||||
vm.editingContestId = contestId;
|
||||
vm.editTitle = vm.contestList[contestId-1].title;
|
||||
vm.editPassword = vm.contestList[contestId-1].password;
|
||||
vm.editStartTime = vm.contestList[contestId-1].start_time.substring(0,16).replace("T"," ");
|
||||
vm.editEndTime = vm.contestList[contestId-1].end_time.substring(0,16).replace("T"," ");
|
||||
vm.editMode = vm.contestList[contestId-1].mode;
|
||||
vm.editVisible = vm.contestList[contestId-1].visible;
|
||||
if (vm.contestList[contestId-1].contest_type == 0) { //contest type == 0, contest in group
|
||||
//Clear the choseGroupList
|
||||
while (vm.choseGroupList.length) {
|
||||
vm.removeGroup(0);
|
||||
}
|
||||
if (avalon.vmodels.contestList) {
|
||||
// this page has been loaded before, so set the default value
|
||||
var vm = avalon.vmodels.contestList;
|
||||
vm.contestList = [];
|
||||
vm.previousPage = 0;
|
||||
vm.nextPage = 0;
|
||||
vm.page = 1;
|
||||
vm.totalPage = 1;
|
||||
vm.keyword = "";
|
||||
vm.editingContestId = 0;
|
||||
vm.editTitle = "";
|
||||
vm.editDescription = "";
|
||||
vm.editProblemList = [];
|
||||
vm.editPassword = "";
|
||||
vm.editStartTime = "";
|
||||
vm.editEndTime = "";
|
||||
vm.editMode = "";
|
||||
vm.editShowSubmission = false;
|
||||
vm.editVisible = false;
|
||||
vm.editingProblemContestIndex = 0;
|
||||
vm.editRealTimeRank = true;
|
||||
}
|
||||
else {
|
||||
var vm = avalon.define({
|
||||
$id: "contestList",
|
||||
contestList: [],
|
||||
previousPage: 0,
|
||||
nextPage: 0,
|
||||
page: 1,
|
||||
totalPage: 1,
|
||||
showVisibleOnly: false,
|
||||
keyword: "",
|
||||
editingContestId: 0,
|
||||
editTitle: "",
|
||||
editDescription: "",
|
||||
editProblemList: [],
|
||||
editPassword: "",
|
||||
editStartTime: "",
|
||||
editEndTime: "",
|
||||
editMode: "",
|
||||
editShowSubmission: false,
|
||||
editVisible: false,
|
||||
editRealTimeRank: true,
|
||||
editingProblemContestIndex: 0,
|
||||
isGlobal: true,
|
||||
allGroups: [],
|
||||
showGlobalViewRadio: true,
|
||||
|
||||
for (var i = 0; i < vm.contestList[contestId-1].groups.length; i++){
|
||||
var id = parseInt(vm.contestList[contestId-1].groups[i]);
|
||||
var index = 0;
|
||||
for (; vm.groupList[index]; index++) {
|
||||
if (vm.groupList[index].id == id)
|
||||
break;
|
||||
getNext: function () {
|
||||
if (!vm.nextPage)
|
||||
return;
|
||||
getPageData(vm.page + 1);
|
||||
},
|
||||
getPrevious: function () {
|
||||
if (!vm.previousPage)
|
||||
return;
|
||||
getPageData(vm.page - 1);
|
||||
},
|
||||
getBtnClass: function (btn) {
|
||||
if (btn == "next") {
|
||||
return vm.nextPage ? "btn btn-primary" : "btn btn-primary disabled";
|
||||
}
|
||||
else {
|
||||
return vm.previousPage ? "btn btn-primary" : "btn btn-primary disabled";
|
||||
}
|
||||
},
|
||||
getPage: function (page_index) {
|
||||
getPageData(page_index);
|
||||
},
|
||||
showEditContestArea: function (contestId) {
|
||||
if (vm.editingContestId && !confirm("如果继续将丢失未保存的信息,是否继续?"))
|
||||
return;
|
||||
if (contestId == vm.editingContestId)
|
||||
vm.editingContestId = 0;
|
||||
else {
|
||||
vm.editingContestId = contestId;
|
||||
vm.editTitle = vm.contestList[contestId - 1].title;
|
||||
vm.editPassword = vm.contestList[contestId - 1].password;
|
||||
vm.editStartTime = vm.contestList[contestId - 1].start_time.substring(0, 16).replace("T", " ");
|
||||
vm.editEndTime = vm.contestList[contestId - 1].end_time.substring(0, 16).replace("T", " ");
|
||||
vm.editMode = vm.contestList[contestId - 1].mode;
|
||||
vm.editVisible = vm.contestList[contestId - 1].visible;
|
||||
vm.editRealTimeRank = vm.contestList[contestId - 1].real_time_rank;
|
||||
if (vm.contestList[contestId - 1].contest_type == 0) { //contest type == 0, contest in group
|
||||
vm.isGlobal = false;
|
||||
for (var i = 0; i < vm.allGroups.length; i++) {
|
||||
vm.allGroups[i].isSelected = false;
|
||||
}
|
||||
for (var i = 0; i < vm.contestList[contestId - 1].groups.length; i++) {
|
||||
var id = parseInt(vm.contestList[contestId - 1].groups[i]);
|
||||
|
||||
for (var index = 0; vm.allGroups[index]; index++) {
|
||||
if (vm.allGroups[index].id == id) {
|
||||
vm.allGroups[index].isSelected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
vm.groupList[index].chose = true;
|
||||
vm.choseGroupList.push({
|
||||
name:vm.groupList[index].name,
|
||||
index:index,
|
||||
id:id
|
||||
});
|
||||
}
|
||||
else {
|
||||
vm.isGlobal = true;
|
||||
}
|
||||
vm.editShowSubmission = vm.contestList[contestId - 1].show_user_submission;
|
||||
editor("#editor").setValue(vm.contestList[contestId - 1].description);
|
||||
vm.editingProblemContestIndex = 0;
|
||||
}
|
||||
else{
|
||||
vm.group = "0";
|
||||
vm.addGroup()//vm.editChoseGroupList = [0]; id 0 is for the group of everyone~
|
||||
},
|
||||
showEditProblemArea: function (contestId) {
|
||||
if (vm.editingProblemContestIndex == contestId) {
|
||||
vm.editingProblemContestIndex = 0;
|
||||
return;
|
||||
}
|
||||
vm.editShowRank = vm.contestList[contestId-1].show_rank;
|
||||
vm.editShowSubmission = vm.contestList[contestId-1].show_user_submission;
|
||||
editor("#editor").setValue(vm.contestList[contestId-1].description);
|
||||
vm.editingProblemContestIndex = 0;
|
||||
}
|
||||
},
|
||||
showEditProblemArea: function(contestId) {
|
||||
if (vm.editingProblemContestIndex == contestId) {
|
||||
vm.editingProblemContestIndex = 0;
|
||||
return;
|
||||
}
|
||||
if (vm.editingContestId&&!confirm("如果继续将丢失未保存的信息,是否继续?")){
|
||||
return;
|
||||
}
|
||||
$.ajax({ // Get the problem list of current contest
|
||||
if (vm.editingContestId && !confirm("如果继续将丢失未保存的信息,是否继续?")) {
|
||||
return;
|
||||
}
|
||||
$.ajax({ // Get the problem list of current contest
|
||||
beforeSend: csrfTokenHeader,
|
||||
url: "/api/admin/contest_problem/?contest_id=" + vm.contestList[contestId-1].id,
|
||||
url: "/api/admin/contest_problem/?contest_id=" + vm.contestList[contestId - 1].id,
|
||||
method: "get",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
@@ -206,51 +196,27 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker",
|
||||
}
|
||||
}
|
||||
});
|
||||
vm.editingContestId = 0;
|
||||
vm.editingProblemContestIndex = contestId;
|
||||
vm.editMode = vm.contestList[contestId-1].mode;
|
||||
},
|
||||
addGroup: function() {
|
||||
if (vm.group == -1) return;
|
||||
if (vm.groupList[vm.group].id == 0){
|
||||
vm.passwordUsable = true;
|
||||
vm.choseGroupList = [];
|
||||
for (var i = 0; i < vm.groupList.length; i++) {
|
||||
vm.groupList[i].chose = true;
|
||||
}
|
||||
}
|
||||
vm.groupList[vm.group]. chose = true;
|
||||
// index of the group is relative. It is related to user
|
||||
vm.choseGroupList.push({name:vm.groupList[vm.group].name, index:vm.group, id:vm.groupList[vm.group].id});
|
||||
vm.group = -1;
|
||||
},
|
||||
removeGroup: function(groupIndex){
|
||||
if (vm.groupList[vm.choseGroupList[groupIndex].index].id == 0){
|
||||
vm.passwordUsable = false;
|
||||
for (var i = 0; i < vm.groupList.length; i++) {
|
||||
vm.groupList[i].chose = false;
|
||||
}
|
||||
}
|
||||
vm.groupList[vm.choseGroupList[groupIndex].index].chose = false;
|
||||
vm.choseGroupList.remove(vm.choseGroupList[groupIndex]);
|
||||
vm.editingContestId = 0;
|
||||
vm.editingProblemContestIndex = contestId;
|
||||
vm.editMode = vm.contestList[contestId - 1].mode;
|
||||
},
|
||||
addProblem: function () {
|
||||
vm.$fire("up!showContestProblemPage", 0, vm.contestList[vm.editingProblemContestIndex-1].id, vm.editMode);
|
||||
},
|
||||
showProblemEditPage: function(el) {
|
||||
vm.$fire("up!showContestProblemPage", el.id, vm.contestList[vm.editingProblemContestIndex-1].id, vm.editMode);
|
||||
},
|
||||
showSubmissionPage: function(el) {
|
||||
var problemId = 0
|
||||
if (el)
|
||||
problemId = el.id;
|
||||
vm.$fire("up!showContestSubmissionPage", problemId, vm.contestList[vm.editingProblemContestIndex-1].id, vm.editMode);
|
||||
}
|
||||
});
|
||||
vm.$watch("showVisibleOnly", function() {
|
||||
getPageData(1);
|
||||
})
|
||||
}
|
||||
addProblem: function () {
|
||||
vm.$fire("up!showContestProblemPage", 0, vm.contestList[vm.editingProblemContestIndex - 1].id, vm.editMode);
|
||||
},
|
||||
showProblemEditPage: function (el) {
|
||||
vm.$fire("up!showContestProblemPage", el.id, vm.contestList[vm.editingProblemContestIndex - 1].id, vm.editMode);
|
||||
},
|
||||
showSubmissionPage: function (el) {
|
||||
var problemId = 0
|
||||
if (el)
|
||||
problemId = el.id;
|
||||
vm.$fire("up!showContestSubmissionPage", problemId, vm.contestList[vm.editingProblemContestIndex - 1].id, vm.editMode);
|
||||
}
|
||||
});
|
||||
vm.$watch("showVisibleOnly", function () {
|
||||
getPageData(1);
|
||||
})
|
||||
}
|
||||
getPageData(1);
|
||||
|
||||
//init time picker
|
||||
@@ -293,39 +259,40 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker",
|
||||
}
|
||||
|
||||
// Get group list
|
||||
$.ajax({ // Get current user type
|
||||
$.ajax({
|
||||
url: "/api/user/",
|
||||
method: "get",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
if (data.data.admin_type == 2) { // Is super user
|
||||
vm.isGlobal = true;
|
||||
vm.groupList.push({id:0,name:"所有人",chose:false});
|
||||
var admin_type = data.data.admin_type;
|
||||
if (data.data.admin_type == 1) {
|
||||
vm.isGlobal = false;
|
||||
vm.showGlobalViewRadio = false;
|
||||
}
|
||||
$.ajax({ // Get the group list of current user
|
||||
beforeSend: csrfTokenHeader,
|
||||
url: "/api/admin/group/",
|
||||
method: "get",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
if (!data.data.length) {
|
||||
//this user have no group can use
|
||||
return;
|
||||
}
|
||||
for (var i = 0; i < data.data.length; i++) {
|
||||
var item = data.data[i];
|
||||
item["chose"] = false;
|
||||
vm.groupList.push(item);
|
||||
}
|
||||
}
|
||||
$.ajax({
|
||||
url: "/api/admin/group/",
|
||||
method: "get",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (!data.code) {
|
||||
if (!data.data.length) {
|
||||
if (admin_type != 2)
|
||||
bsAlert("您的用户权限只能创建小组内比赛,但是您还没有创建过小组");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
for (var i = 0; i < data.data.length; i++) {
|
||||
var item = data.data[i];
|
||||
item["isSelected"] = false;
|
||||
vm.allGroups.push(item);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
({
|
||||
// RequireJS 通过一个相对的路径 baseUrl来加载所有代码。baseUrl通常被设置成data-main属性指定脚本的同级目录。
|
||||
baseUrl: "js/",
|
||||
baseUrl: "/static/js/",
|
||||
// 第三方脚本模块的别名,jquery比libs/jquery-1.11.1.min.js简洁明了;
|
||||
paths: {
|
||||
|
||||
jquery: "lib/jquery/jquery",
|
||||
avalon: "lib/avalon/avalon",
|
||||
editor: "utils/editor",
|
||||
@@ -37,12 +38,12 @@
|
||||
webUploader: "lib/webuploader/webuploader",
|
||||
|
||||
"_datetimePicker": "lib/datetime_picker/bootstrap-datetimepicker"
|
||||
|
||||
},
|
||||
shim: {
|
||||
"bootstrap": {"deps": ['jquery']},
|
||||
"_datetimepicker": {"deps": ["jquery"]},
|
||||
"datetimepicker": {"deps": ["_datetimepicker"]}
|
||||
bootstrap: {deps: ["jquery"]},
|
||||
_datetimePicker: {dep: ["jquery"]},
|
||||
datetimePicker: {deps: ["_datetimePicker"]},
|
||||
validator: ["jquery"]
|
||||
},
|
||||
findNestedDependencies: true,
|
||||
appDir: "../",
|
||||
|
||||
@@ -143,6 +143,16 @@ Uploader = (function(superClass) {
|
||||
processData: false,
|
||||
contentType: false,
|
||||
type: 'POST',
|
||||
beforeSend: function(){
|
||||
var name = "csrftoken=";
|
||||
var ca = document.cookie.split(';');
|
||||
for (var i = 0; i < ca.length; i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0) == ' ') c = c.substring(1);
|
||||
if (c.indexOf(name) != -1) name = c.substring(name.length, c.length);
|
||||
}
|
||||
arguments[0].setRequestHeader("X-CSRFToken", name);
|
||||
},
|
||||
headers: {
|
||||
'X-File-Name': encodeURIComponent(file.name)
|
||||
},
|
||||
|
||||
@@ -8,7 +8,7 @@ define("editor", ["simditor"], function(Simditor){
|
||||
toolbarFloat: false,
|
||||
defaultImage: null,
|
||||
upload: {
|
||||
url: "",
|
||||
url: "/api/admin/upload_image/",
|
||||
params: null,
|
||||
fileKey: "image",
|
||||
connectionCount: 3,
|
||||
|
||||
Reference in New Issue
Block a user