From 7b3c14343b07fd0013736e937157f50f279b0a41 Mon Sep 17 00:00:00 2001 From: virusdefender <1670873886@qq.com> Date: Sat, 22 Aug 2015 22:16:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=A3=E7=A0=81=E5=86=B2?= =?UTF-8?q?=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contest/views.py | 3 +- static/src/css/admin.css | 38 ++++-- .../src/js/app/admin/contest/contest_list.js | 113 +++++++----------- 3 files changed, 75 insertions(+), 79 deletions(-) diff --git a/contest/views.py b/contest/views.py index 283f23ea..f6f6824e 100644 --- a/contest/views.py +++ b/contest/views.py @@ -293,7 +293,8 @@ def contest_list_page(request, page=1): # 筛选我能参加的比赛 join = request.GET.get("join", None) if join: - contests = Contest.objects.filter(Q(contest_type__in=[1, 2]) | Q(groups__in=request.user.group_set.all())) + contests = Contest.objects.filter(Q(contest_type__in=[1, 2]) | Q(groups__in=request.user.group_set.all())).\ + filter(end_time__gt=datetime.datetime.now(), start_time__lt=datetime.datetime.now()) paginator = Paginator(contests, 20) try: diff --git a/static/src/css/admin.css b/static/src/css/admin.css index 37ebdfb3..f7e75810 100644 --- a/static/src/css/admin.css +++ b/static/src/css/admin.css @@ -6,36 +6,52 @@ @import url("webuploader/webuploader.css"); @import url("datetime_picker/bootstrap-datetimepicker.css"); @import url("tagEditor/jquery.tag-editor.css"); -@import url("contest/add_contest.css"); -#loading-gif{ +#loading-gif { width: 40px; height: 40px; margin: auto; position: absolute; - top: 0; left: 0; bottom: 0; right: 0; + top: 0; + left: 0; + bottom: 0; + right: 0; } -.line-chart{ - min-width:100%; +.line-chart { + min-width: 100%; max-height: 300px; } -.pie-chart{ - min-width:100%; +.pie-chart { + min-width: 100%; max-height: 300px; } -.chart-description{ +.chart-description { text-align: center; } -.pie-chart-container{ +.pie-chart-container { width: 50%; float: left; } -.tag-editor{ +.tag-editor { border: 1px solid #d9d9d9; border-top-color: silver; -} \ No newline at end of file +} + +.group-tag { + color: #46799b; + background: #e0eaf1; + white-space: nowrap; + overflow: hidden; + cursor: pointer; + border-radius: 2px 0 0 2px; + float: left; + padding: 0 4px; + box-sizing: border-box; + list-style-type: none; + margin: 5px; +} diff --git a/static/src/js/app/admin/contest/contest_list.js b/static/src/js/app/admin/contest/contest_list.js index 0be9cfb9..1b2de7a9 100644 --- a/static/src/js/app/admin/contest/contest_list.js +++ b/static/src/js/app/admin/contest/contest_list.js @@ -1,9 +1,9 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker"], function ($, avalon, csrfTokenHeader, bsAlert, editor) { avalon.ready(function () { - if(avalon.vmodels.contestList){ + if (avalon.vmodels.contestList) { vm = avalon.vmodels.contestList; - vm.editingContest = 0; + vm.editingContest = 0; } else { var vm = avalon.define({ @@ -16,11 +16,11 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker"] group: "-1", groupList: [], keyword: "", - editingContestId: 0, - editTitle: "", - editProblemList: [], - editPassword: "", - editStartTime: "", + editingContestId: 0, + editTitle: "", + editProblemList: [], + editPassword: "", + editStartTime: "", editEndTime: "", editMode: "", editShowRank: false, @@ -30,8 +30,8 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker"] editSamples: [], editTestCaseList: [], editChoseGroupList: [], - modelNameList: ["ACM", "AC总数", "分数"], - contestTypeNameList: ["小组赛", "公开赛", "有密码保护的公开赛"], + modelNameList: ["ACM", "AC总数", "分数"], + contestTypeNameList: ["小组赛", "公开赛", "有密码保护的公开赛"], getNext: function () { if (!vm.nextPage) return; @@ -54,32 +54,32 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker"] getPageData(page_index); }, showEditContestArea: function (contestId) { - if (contestId == vm.editingContestId) - vm.editingContestId = 0; - else { - vm.editingContestId = contestId; - vm.editTitle = vm.contestList[contestId-1].title; - vm.editEndTime = vm.contestList[contestId-1].end_time; - vm.editPassword = vm.contestList[contestId-1].password; - vm.editStartTime = vm.contestList[contestId-1].start_time; - vm.editMode = vm.contestList[contestId-1].mode; - vm.editChoseGroupList = []; - //= vm.contestList[contestId-1].group;// - /*for (var key in vm.contestList[contestId-1].groups){ - var id = parseInt(vm.contestList[contestId-1].groups); - for () - vm.editChoseGroupList.push({ - name:vm.groupList[vm.group].name, - index:index, - id:parseInt(vm.contestList[contestId-1].groups) - }); - }*/ - vm.editShowRank = vm.contestList[contestId-1].show_rank; - vm.editShowSubmission = vm.contestList[contestId-1].show_user_submission; - //vm.editProblemList = vm.contestList[contestId-1].problems - editor("#editor").setValue(vm.contestList[contestId-1].description); - vm.editingProblemList = vm.contestList[contestId-1].problemList; - } + if (contestId == vm.editingContestId) + vm.editingContestId = 0; + else { + vm.editingContestId = contestId; + vm.editTitle = vm.contestList[contestId - 1].title; + vm.editEndTime = vm.contestList[contestId - 1].end_time; + vm.editPassword = vm.contestList[contestId - 1].password; + vm.editStartTime = vm.contestList[contestId - 1].start_time; + vm.editMode = vm.contestList[contestId - 1].mode; + vm.editChoseGroupList = []; + //= vm.contestList[contestId-1].group;// + /*for (var key in vm.contestList[contestId-1].groups){ + var id = parseInt(vm.contestList[contestId-1].groups); + for () + vm.editChoseGroupList.push({ + name:vm.groupList[vm.group].name, + index:index, + id:parseInt(vm.contestList[contestId-1].groups) + }); + }*/ + vm.editShowRank = vm.contestList[contestId - 1].show_rank; + vm.editShowSubmission = vm.contestList[contestId - 1].show_user_submission; + //vm.editProblemList = vm.contestList[contestId-1].problems + editor("#editor").setValue(vm.contestList[contestId - 1].description); + vm.editingProblemList = vm.contestList[contestId - 1].problemList; + } } }); @@ -112,7 +112,7 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker"] var isSuperAdmin = true; - $.ajax({ //用于获取该用户创建的所有小组的ajax请求 + $.ajax({ //用于获取该用户创建的所有小组的ajax请求 url: "/api/admin/group/", method: "get", @@ -120,41 +120,20 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker"] success: function (data) { if (!data.code) { if (!data.data.length) { - bsAlert("您的用户权限只能创建组内比赛,但是您还没有创建过小组"); - return; + bsAlert("您的用户权限只能创建组内比赛,但是您还没有创建过小组"); + return; } for (var i = 0; i < data.data.length; i++) { - var item = data.data[i]; - item["chose"] = false; - vm.groupList.push(item); - } - } - else { - bsAlert(data.data); + var item = data.data[i]; + item["chose"] = false; + vm.groupList.push(item); } } - - - beforeSend: csrfTokenHeader, - url: url, - dataType: "json", - method: "get", - contentType: "application/json", - success: function (data) { - if (!data.code) { - if (isSuperAdmin) - vm.groupList.push({id:0, name:"所有人", chose: false}); - for (var key in data.data) { - data.data[key].chose = false; - vm.groupList.push(data.data[key]); - } - } - else { - bsAlert(data.data); - console.log(data); - } - } - }); + else { + bsAlert(data.data); + } + } + }); }); avalon.scan(); });