mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2025-01-04 03:22:06 +00:00
Merge branch 'dev-s' into virusdefender-dev
* dev-s: 小调整,修改addContest的小bug, 修复小bug,仿照problem GET添加获取单个比赛信息的API 添加后台编辑比赛页面[CI SKIP] Conflicts: static/src/js/app/admin/contest/contestList.js static/src/js/app/admin/contest/editContest.js
This commit is contained in:
commit
c295d5d032
@ -136,8 +136,8 @@ class ProblemAdminAPIView(APIView):
|
||||
# 普通管理员只能获取自己创建的题目
|
||||
# 超级管理员可以获取全部的题目
|
||||
problem = Problem.objects.get(id=problem_id)
|
||||
if request.user.admin_type != SUPER_ADMIN:
|
||||
problem = problem.get(created_by=request.user)
|
||||
if request.user.admin_type != SUPER_ADMIN and problem.created_by != request.user:
|
||||
return error_response(u"题目不存在")
|
||||
return success_response(ProblemSerializer(problem).data)
|
||||
except Problem.DoesNotExist:
|
||||
return error_response(u"题目不存在")
|
||||
|
@ -75,7 +75,7 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "date
|
||||
showGlobalViewRadio: true,
|
||||
realTimeRank: true,
|
||||
visible: false,
|
||||
showContestListPage: function() {
|
||||
showContestListPage: function () {
|
||||
avalon.vmodels.admin.template_url = "template/contest/contest_list.html";
|
||||
},
|
||||
|
||||
@ -84,7 +84,7 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "date
|
||||
placeholder: "比赛介绍内容"
|
||||
}
|
||||
});
|
||||
|
||||
avalon.scan();
|
||||
$.ajax({
|
||||
url: "/api/user/",
|
||||
method: "get",
|
||||
@ -111,9 +111,46 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "date
|
||||
vm.allGroups = [];
|
||||
for (var i = 0; i < data.data.length; i++) {
|
||||
var item = data.data[i];
|
||||
item["isSelected"] = false;
|
||||
item.isSelected = false;
|
||||
vm.allGroups.push(item);
|
||||
}
|
||||
$.ajax({
|
||||
url: "/api/admin/contest/?contest_id=" + avalon.vmodels.admin.contestId,
|
||||
method: "get",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code) {
|
||||
bsAlert(data.data);
|
||||
}
|
||||
else {
|
||||
var contest = data.data;
|
||||
vm.title = contest.title;
|
||||
avalon.vmodels.contestDescriptionEditor.content = contest.description;
|
||||
vm.visible = contest.visible;
|
||||
vm.realTimeRank = contest.real_time_rank;
|
||||
vm.startTime = contest.start_time.substring(0, 16).replace("T", " ");
|
||||
vm.endTime = contest.end_time.substring(0, 16).replace("T", " ");
|
||||
if (contest.contest_type == 0) { //contest_type == 0, 小组内比赛
|
||||
vm.isGlobal = false;
|
||||
for (var i = 0; i < vm.allGroups.length; i++) {
|
||||
vm.allGroups[i].isSelected = false;
|
||||
}
|
||||
for (var i = 0; i < contest.groups.length; i++) {
|
||||
var id = contest.groups[i];
|
||||
for (var index = 0; vm.allGroups[index]; index++) {
|
||||
if (vm.allGroups[index].id == id) {
|
||||
vm.allGroups[index].isSelected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
vm.isGlobal = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
bsAlert(data.data);
|
||||
@ -123,48 +160,6 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "date
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: "/api/admin/contest/?contest_id=" + avalon.vmodels.admin.contestId,
|
||||
method: "get",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
if (data.code) {
|
||||
bsAlert(data.data);
|
||||
}
|
||||
else {
|
||||
var contest = data.data;
|
||||
vm.title = contest.title;
|
||||
avalon.vmodels.contestDescriptionEditor.content = contest.description;
|
||||
vm.visible = contest.visible;
|
||||
vm.realTimeRank = contest.real_time_rank;
|
||||
vm.startTime = contest.start_time.substring(0, 16).replace("T", " ");
|
||||
vm.endTime = contest.end_time.substring(0, 16).replace("T", " ");
|
||||
if (contest.contest_type == 0) { //contest_type == 0, 小组内比赛
|
||||
vm.isGlobal = false;
|
||||
for (var i = 0; i < vm.allGroups.length; i++) {
|
||||
vm.allGroups[i].isSelected = false;
|
||||
}
|
||||
for (var i = 0; i < contest.groups.length; i++) {
|
||||
var id = parseInt(contest.groups[i]);
|
||||
console.log(id);
|
||||
for (var index = 0; vm.allGroups[index]; index++) {
|
||||
if (vm.allGroups[index].id == id) {
|
||||
vm.allGroups[index].isSelected = true;
|
||||
console.log(id+"asdf");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
vm.isGlobal = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
avalon.scan();
|
||||
|
||||
$("#contest_start_time").datetimepicker({
|
||||
format: "yyyy-mm-dd hh:ii",
|
||||
minuteStep: 5,
|
||||
|
@ -59,7 +59,7 @@
|
||||
{{ request.user.username }}
|
||||
<span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
{% if request.user.admin_type == 2 %}
|
||||
{% if request.user.admin_type > 0 %}
|
||||
<li><a href="/admin/">后台管理</a></li>
|
||||
{% endif %}
|
||||
<li><a href="/submissions/">我的提交</a></li>
|
||||
|
Loading…
Reference in New Issue
Block a user