添加后台超级管理员把比赛题目添加到题目列表的功能,利用problemAdminAPIView的post实现,默认隐藏题目
This commit is contained in:
@@ -114,7 +114,7 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker",
|
|||||||
isGlobal: true,
|
isGlobal: true,
|
||||||
allGroups: [],
|
allGroups: [],
|
||||||
showGlobalViewRadio: true,
|
showGlobalViewRadio: true,
|
||||||
|
admin_type: 1,
|
||||||
getNext: function () {
|
getNext: function () {
|
||||||
if (!vm.nextPage)
|
if (!vm.nextPage)
|
||||||
return;
|
return;
|
||||||
@@ -211,6 +211,39 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker",
|
|||||||
if (el)
|
if (el)
|
||||||
problemId = el.id;
|
problemId = el.id;
|
||||||
vm.$fire("up!showContestSubmissionPage", problemId, vm.contestList[vm.editingProblemContestIndex - 1].id, vm.editMode);
|
vm.$fire("up!showContestSubmissionPage", problemId, vm.contestList[vm.editingProblemContestIndex - 1].id, vm.editMode);
|
||||||
|
},
|
||||||
|
addToProblemList: function (problem) {
|
||||||
|
var ajaxData = {
|
||||||
|
title: problem.title,
|
||||||
|
description: problem.description,
|
||||||
|
time_limit: problem.time_limit,
|
||||||
|
memory_limit: problem.memory_limit,
|
||||||
|
samples: problem.samples,
|
||||||
|
test_case_id: problem.test_case_id,
|
||||||
|
hint: problem.hint,
|
||||||
|
source: problem.contest.title,
|
||||||
|
visible: false,
|
||||||
|
tags: [],
|
||||||
|
input_description: problem.input_description,
|
||||||
|
output_description: problem.output_description,
|
||||||
|
difficulty: 0
|
||||||
|
};
|
||||||
|
$.ajax({
|
||||||
|
beforeSend: csrfTokenHeader,
|
||||||
|
url: "/api/admin/problem/",
|
||||||
|
dataType: "json",
|
||||||
|
data: JSON.stringify(ajaxData),
|
||||||
|
method: "post",
|
||||||
|
contentType: "application/json",
|
||||||
|
success: function (data) {
|
||||||
|
if (!data.code) {
|
||||||
|
bsAlert("题目添加成功!题目现在处于隐藏状态,请到题目列表手动修改,并添加分类和难度信息!");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bsAlert(data.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
vm.$watch("showVisibleOnly", function () {
|
vm.$watch("showVisibleOnly", function () {
|
||||||
@@ -266,6 +299,7 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker",
|
|||||||
success: function (data) {
|
success: function (data) {
|
||||||
if (!data.code) {
|
if (!data.code) {
|
||||||
var admin_type = data.data.admin_type;
|
var admin_type = data.data.admin_type;
|
||||||
|
vm.admin_type = admin_type;
|
||||||
if (data.data.admin_type == 1) {
|
if (data.data.admin_type == 1) {
|
||||||
vm.isGlobal = false;
|
vm.isGlobal = false;
|
||||||
vm.showGlobalViewRadio = false;
|
vm.showGlobalViewRadio = false;
|
||||||
@@ -278,6 +312,7 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker",
|
|||||||
success: function (data) {
|
success: function (data) {
|
||||||
if (!data.code) {
|
if (!data.code) {
|
||||||
if (!data.data.length) {
|
if (!data.data.length) {
|
||||||
|
|
||||||
if (admin_type != 2)
|
if (admin_type != 2)
|
||||||
bsAlert("您的用户权限只能创建小组内比赛,但是您还没有创建过小组");
|
bsAlert("您的用户权限只能创建小组内比赛,但是您还没有创建过小组");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -178,6 +178,8 @@
|
|||||||
ms-click="showProblemEditPage(el)">编辑</a>
|
ms-click="showProblemEditPage(el)">编辑</a>
|
||||||
<a href="javascript:void(0)" class="btn-sm btn-info"
|
<a href="javascript:void(0)" class="btn-sm btn-info"
|
||||||
ms-click="showSubmissionPage(el)">提交</a>
|
ms-click="showSubmissionPage(el)">提交</a>
|
||||||
|
<a href="javascript:void(0)" class="btn-sm btn-info"
|
||||||
|
ms-click="addToProblemList(el)" ms-visible="admin_type=='2'">添加到前台</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Reference in New Issue
Block a user