From e4a5e4155b206e71cf31c2c5e298627afc44daeb Mon Sep 17 00:00:00 2001 From: esp Date: Wed, 2 Sep 2015 20:26:55 +0800 Subject: [PATCH 01/18] =?UTF-8?q?=E4=B8=BA=E4=BA=86=E5=9C=A8qduoj.cf?= =?UTF-8?q?=E4=B8=8A=E8=BF=90=E8=A1=8C=E5=81=9A=E4=BA=86=E6=94=B9=E5=8A=A8?= =?UTF-8?q?=EF=BC=8C=E5=9B=A0=E4=B8=BA=E5=88=A4=E9=A2=98=E5=92=8Cweb?= =?UTF-8?q?=E9=83=BD=E5=9C=A8=E4=B8=80=E5=8F=B0=E6=9C=BA=E5=99=A8=E4=B8=8A?= =?UTF-8?q?=EF=BC=8C=E8=BF=99=E4=B8=AAdocker=20image=E6=98=AF=E4=BB=8Edigi?= =?UTF-8?q?talOcean=E4=B8=8Adownload=E4=B8=8B=E6=9D=A5=E7=9A=84[CI=20SKIP]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- judge/judger_controller/settings.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/judge/judger_controller/settings.py b/judge/judger_controller/settings.py index aff08b1..6ee3a0c 100644 --- a/judge/judger_controller/settings.py +++ b/judge/judger_controller/settings.py @@ -1,7 +1,7 @@ # coding=utf-8 # 这个redis 是 celery 使用的,包括存储队列信息还有部分统计信息 redis_config = { - "host": "121.42.32.129", + "host": "127.0.0.1", "port": 6379, "db": 0 } @@ -9,7 +9,7 @@ redis_config = { # 判题的 docker 容器的配置参数 docker_config = { - "image_name": "3da0e526934e", + "image_name": "5453975e94c4", "docker_path": "docker", "shell": True } From 655b18421edd304c2c8c5a47f998356e80d8c3d6 Mon Sep 17 00:00:00 2001 From: esp Date: Wed, 2 Sep 2015 22:26:58 +0800 Subject: [PATCH 02/18] =?UTF-8?q?=E8=BF=99=E6=98=AF=E4=B8=BA=E4=BA=86?= =?UTF-8?q?=E8=83=BD=E4=BB=A5root=E8=BA=AB=E4=BB=BD=E8=BF=90=E8=A1=8Cceler?= =?UTF-8?q?y[CI=20SKIP]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- judge/judger_controller/celery.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/judge/judger_controller/celery.py b/judge/judger_controller/celery.py index 18cf886..51f923f 100644 --- a/judge/judger_controller/celery.py +++ b/judge/judger_controller/celery.py @@ -4,4 +4,6 @@ from celery import Celery from .settings import redis_config app = Celery("judge", broker='redis://%s:%s/%s' % (redis_config["host"], redis_config["port"], redis_config["db"]), - include=["judge.judger_controller.tasks"]) \ No newline at end of file + include=["judge.judger_controller.tasks"]) + +platforms.C_FORCE_ROOT =True \ No newline at end of file From eb376c49fc2ee7e166cf8e4103a373ea5f432695 Mon Sep 17 00:00:00 2001 From: lsxwxs Date: Wed, 2 Sep 2015 22:59:43 +0800 Subject: [PATCH 03/18] =?UTF-8?q?=E6=BC=8F=E4=BA=86=E4=B8=80=E4=B8=AAimpor?= =?UTF-8?q?t[CI=20SKIP]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- judge/judger_controller/celery.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/judge/judger_controller/celery.py b/judge/judger_controller/celery.py index 51f923f..4c64ab0 100644 --- a/judge/judger_controller/celery.py +++ b/judge/judger_controller/celery.py @@ -1,9 +1,9 @@ # coding=utf-8 from __future__ import absolute_import -from celery import Celery +from celery import Celery, platforms from .settings import redis_config app = Celery("judge", broker='redis://%s:%s/%s' % (redis_config["host"], redis_config["port"], redis_config["db"]), include=["judge.judger_controller.tasks"]) -platforms.C_FORCE_ROOT =True \ No newline at end of file +platforms.C_FORCE_ROOT =True From 5000bbc38fa57cff89e15708eada93cc0d02ae3e Mon Sep 17 00:00:00 2001 From: lsxwxs Date: Wed, 2 Sep 2015 23:03:05 +0800 Subject: [PATCH 04/18] =?UTF-8?q?=E5=8E=9F=E6=9D=A5=E7=9A=84dockerimage?= =?UTF-8?q?=E9=87=8C=E6=B2=A1=E6=9C=89MySQL-python,=E6=89=80=E4=BB=A5?= =?UTF-8?q?=E5=8F=88=E6=94=B9=E4=BA=86=E4=B8=8B[CI=20SKIP]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- judge/judger_controller/settings.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/judge/judger_controller/settings.py b/judge/judger_controller/settings.py index 6ee3a0c..93673bd 100644 --- a/judge/judger_controller/settings.py +++ b/judge/judger_controller/settings.py @@ -9,7 +9,8 @@ redis_config = { # 判题的 docker 容器的配置参数 docker_config = { - "image_name": "5453975e94c4", + + "image_name": " 819d3da18dc1", "docker_path": "docker", "shell": True } @@ -28,4 +29,4 @@ submission_db = { "db": "oj_submission", "user": "root", "password": "root" -} \ No newline at end of file +} From 69cc85eb01e69b2ded52a15c69972da4aebf23c5 Mon Sep 17 00:00:00 2001 From: esp Date: Thu, 3 Sep 2015 00:28:34 +0800 Subject: [PATCH 05/18] correct the path of test case in judger --- judge/judger_controller/settings.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/judge/judger_controller/settings.py b/judge/judger_controller/settings.py index 6ee3a0c..ea6a006 100644 --- a/judge/judger_controller/settings.py +++ b/judge/judger_controller/settings.py @@ -16,7 +16,7 @@ docker_config = { # 测试用例的路径,是主机上的实际路径 -test_case_dir = "/var/mnt/source/test_case/" +test_case_dir = "/root/test_case/" # 源代码路径,也就是 manage.py 所在的实际路径 source_code_dir = "/var/mnt/source/OnlineJudge/" From fc7f4ae3b7a82cfef584bb8bc7e6c2abf947eb9c Mon Sep 17 00:00:00 2001 From: lsxwxs Date: Thu, 3 Sep 2015 00:41:36 +0800 Subject: [PATCH 06/18] =?UTF-8?q?=E5=AF=B9=E7=9B=98=E9=A2=98=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E9=92=88=E5=AF=B9=E6=96=B0=E6=B5=8B=E8=AF=95=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=99=A8=E8=BF=9B=E8=A1=8C=E8=B0=83=E6=95=B4,?= =?UTF-8?q?=E8=AF=A5=E5=88=86=E6=94=AF=E5=B0=86=E4=B8=8D=E4=BC=9A=E5=B9=B6?= =?UTF-8?q?=E5=85=A5=E4=B8=BB=E5=88=86=E6=94=AF[CI=20SKIP]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- judge/judger/client.py | 2 +- judge/judger/settings.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/judge/judger/client.py b/judge/judger/client.py index fc7d0b9..4b0ec02 100644 --- a/judge/judger/client.py +++ b/judge/judger/client.py @@ -170,4 +170,4 @@ class JudgeClient(object): # http://stackoverflow.com/questions/25382455/python-notimplementederror-pool-objects-cannot-be-passed-between-processes self_dict = self.__dict__.copy() del self_dict['_pool'] - return self_dict \ No newline at end of file + return self_dict diff --git a/judge/judger/settings.py b/judge/judger/settings.py index 1f15b96..5f8d7ce 100644 --- a/judge/judger/settings.py +++ b/judge/judger/settings.py @@ -17,7 +17,7 @@ judger_workspace = "/var/judger/" # 这个是在docker 中访问数据库 ip 不一定和web服务器还有celery的一样 submission_db = { - "host": "192.168.42.1", + "host": "10.172.22.50",#"192.168.42.1", "port": 3306, "db": "oj_submission", "user": "root", From 49644a462baa7f3e783d10e983fffa6529377f39 Mon Sep 17 00:00:00 2001 From: lsxwxs Date: Thu, 3 Sep 2015 21:44:02 +0800 Subject: [PATCH 07/18] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BF=90=E8=A1=8C?= =?UTF-8?q?=E5=88=A4=E4=BD=93=E8=84=9A=E6=9C=AC[CI=20SKIP]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- runJudge.sh | 1 + 1 file changed, 1 insertion(+) create mode 100755 runJudge.sh diff --git a/runJudge.sh b/runJudge.sh new file mode 100755 index 0000000..ba25da8 --- /dev/null +++ b/runJudge.sh @@ -0,0 +1 @@ +nohup celery -A judge.judger_controller worker -l DEBUG & From 59fd241053e01a343a93b29e3f7962cc75c22d43 Mon Sep 17 00:00:00 2001 From: esp Date: Sat, 5 Sep 2015 16:03:55 +0800 Subject: [PATCH 08/18] update contest_problem.html --- template/src/oj/contest/contest_problem.html | 7 ------- 1 file changed, 7 deletions(-) diff --git a/template/src/oj/contest/contest_problem.html b/template/src/oj/contest/contest_problem.html index f5b3cb1..5c18a90 100644 --- a/template/src/oj/contest/contest_problem.html +++ b/template/src/oj/contest/contest_problem.html @@ -48,13 +48,6 @@ {{ item.output }} {% endfor %} - {% if problem.hint %} -
- - -

{{ contest_problem.hint|safe }}

-
- {% endif %} {% if contest_problem.hint %}
From aef3c45dfaa624b4247d86f30623bb50df9a0f72 Mon Sep 17 00:00:00 2001 From: esp Date: Sat, 5 Sep 2015 16:09:43 +0800 Subject: [PATCH 09/18] update contest_problem.html --- template/src/oj/contest/contest_problem.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/src/oj/contest/contest_problem.html b/template/src/oj/contest/contest_problem.html index 5c18a90..8ce7a10 100644 --- a/template/src/oj/contest/contest_problem.html +++ b/template/src/oj/contest/contest_problem.html @@ -49,7 +49,7 @@
{% endfor %} {% if contest_problem.hint %} -
+

{{ contest_problem.hint|safe }}

From dc50b8e71f45d1c34eba7011c0f0afbe5f58b6ef Mon Sep 17 00:00:00 2001 From: hohoTT <609029365@qq.com> Date: Sat, 5 Sep 2015 19:04:57 +0800 Subject: [PATCH 10/18] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=AF=94=E8=B5=9B?= =?UTF-8?q?=E5=8D=95=E4=B8=AA=E9=A2=98=E7=9B=AE=E5=88=97=E8=A1=A8=E7=9A=84?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/src/oj/contest/my_submissions_list.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/template/src/oj/contest/my_submissions_list.html b/template/src/oj/contest/my_submissions_list.html index fb24bef..97bc7c3 100644 --- a/template/src/oj/contest/my_submissions_list.html +++ b/template/src/oj/contest/my_submissions_list.html @@ -25,10 +25,12 @@ {% for item in submissions %} - + {{ forloop.counter }} {{ item.create_time }} - {{ item.result|translate_result }} + + {{ item.language|translate_language }} + {% if item.accepted_answer_time %} {{ item.accepted_answer_time }}ms @@ -36,8 +38,8 @@ -- {% endif %} - - {{ item.language|translate_language }} + + {{ item.result|translate_result }} {% endfor %} From 3df06adbaa58bb0e4bae6cab3f0b585e5e51b6eb Mon Sep 17 00:00:00 2001 From: hohoTT <609029365@qq.com> Date: Sat, 5 Sep 2015 19:06:41 +0800 Subject: [PATCH 11/18] =?UTF-8?q?Revert=20"=E4=BF=AE=E6=94=B9=E6=AF=94?= =?UTF-8?q?=E8=B5=9B=E5=8D=95=E4=B8=AA=E9=A2=98=E7=9B=AE=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E6=A0=B7=E5=BC=8F"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit dc50b8e71f45d1c34eba7011c0f0afbe5f58b6ef. --- template/src/oj/contest/my_submissions_list.html | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/template/src/oj/contest/my_submissions_list.html b/template/src/oj/contest/my_submissions_list.html index 97bc7c3..fb24bef 100644 --- a/template/src/oj/contest/my_submissions_list.html +++ b/template/src/oj/contest/my_submissions_list.html @@ -25,12 +25,10 @@ {% for item in submissions %} - + {{ forloop.counter }} {{ item.create_time }} - - {{ item.language|translate_language }} - + {{ item.result|translate_result }} {% if item.accepted_answer_time %} {{ item.accepted_answer_time }}ms @@ -38,8 +36,8 @@ -- {% endif %} - - {{ item.result|translate_result }} + + {{ item.language|translate_language }} {% endfor %} From c717ae5a83c944ec0ba4676299c6ad38e27b6882 Mon Sep 17 00:00:00 2001 From: hohoTT <609029365@qq.com> Date: Sat, 5 Sep 2015 19:24:59 +0800 Subject: [PATCH 12/18] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/src/oj/contest/my_submissions_list.html | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/template/src/oj/contest/my_submissions_list.html b/template/src/oj/contest/my_submissions_list.html index fb24bef..97bc7c3 100644 --- a/template/src/oj/contest/my_submissions_list.html +++ b/template/src/oj/contest/my_submissions_list.html @@ -25,10 +25,12 @@ {% for item in submissions %} - + {{ forloop.counter }} {{ item.create_time }} - {{ item.result|translate_result }} + + {{ item.language|translate_language }} + {% if item.accepted_answer_time %} {{ item.accepted_answer_time }}ms @@ -36,8 +38,8 @@ -- {% endif %} - - {{ item.language|translate_language }} + + {{ item.result|translate_result }} {% endfor %} From 0066c04be680844f93f9fd868a6e6d660b53fcc7 Mon Sep 17 00:00:00 2001 From: hohoTT <609029365@qq.com> Date: Sat, 5 Sep 2015 19:32:45 +0800 Subject: [PATCH 13/18] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=A1=BA=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/src/oj/contest/my_submissions_list.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template/src/oj/contest/my_submissions_list.html b/template/src/oj/contest/my_submissions_list.html index 97bc7c3..8c8aa5a 100644 --- a/template/src/oj/contest/my_submissions_list.html +++ b/template/src/oj/contest/my_submissions_list.html @@ -18,9 +18,9 @@ # 提交时间 - 结果 - 运行时间 语言 + 运行时间 + 结果 From 18a31e41d6b2a2c94799b101ae72e3e73409dd7d Mon Sep 17 00:00:00 2001 From: hohoTT <609029365@qq.com> Date: Sat, 5 Sep 2015 19:37:32 +0800 Subject: [PATCH 14/18] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- template/src/oj/contest/submissions_list.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/template/src/oj/contest/submissions_list.html b/template/src/oj/contest/submissions_list.html index 336e9c3..a0560d1 100644 --- a/template/src/oj/contest/submissions_list.html +++ b/template/src/oj/contest/submissions_list.html @@ -28,15 +28,14 @@ # 用户 提交时间 - 结果 - 运行时间 语言 + 运行时间 + 结果 {% for item in submissions %} - - + {% ifequal item.user_id request.user.id %} {{ forloop.counter |add:start_id }} @@ -45,9 +44,10 @@ {% endifequal %} {{ item.user_id|get_username }} - {{ item.create_time }} - {{ item.result|translate_result }} + + {{ item.language|translate_language }} + {% if item.accepted_answer_time %} {{ item.accepted_answer_time }}ms @@ -55,8 +55,8 @@ -- {% endif %} - - {{ item.language|translate_language }} + + {{ item.result|translate_result }} {% endfor %} From eeeaeddc08df30485a236d449e84ab9223df9851 Mon Sep 17 00:00:00 2001 From: uzi Date: Thu, 29 Oct 2015 17:00:13 +0800 Subject: [PATCH 15/18] =?UTF-8?q?=E6=B7=BB=E5=8A=A0admin=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E6=AF=94=E8=B5=9B=E9=A1=B5=E9=9D=A2=E4=BB=A5=E5=8F=8Ajs[CI=20S?= =?UTF-8?q?KIP]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/js/app/admin/contest/editContest.js | 180 ++++++++++++++++++ template/src/admin/contest/edit_contest.html | 107 +++++++++++ 2 files changed, 287 insertions(+) create mode 100644 static/src/js/app/admin/contest/editContest.js create mode 100644 template/src/admin/contest/edit_contest.html diff --git a/static/src/js/app/admin/contest/editContest.js b/static/src/js/app/admin/contest/editContest.js new file mode 100644 index 0000000..bce5b9a --- /dev/null +++ b/static/src/js/app/admin/contest/editContest.js @@ -0,0 +1,180 @@ +require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "datetimePicker", + "validator", "editorComponent"], + function ($, avalon, editor, uploader, bsAlert, csrfTokenHeader) { + + $("#edit-contest-form").validator().on('submit', function (e) { + if (!e.isDefaultPrevented()) { + e.preventDefault(); + var ajaxData = { + id: avalon.vmodels.admin.contestId, + title: vm.title, + description: avalon.vmodels.contestDescriptionEditor.content, + contest_type: 0, + real_time_rank: vm.realTimeRank, + start_time: vm.startTime, + end_time: vm.endTime, + visible: vm.visible + }; + + 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.password; + ajaxData.contest_type = 2; + } + else + ajaxData.contest_type = 1; + } + if (!vm.isGlobal && !selectedGroups.length) { + bsAlert("你没有选择参赛用户!"); + return false; + } + if (ajaxData.description.trim() == "") { + bsAlert("比赛描述不能为空!"); + return false; + } + $.ajax({ + url: "/api/admin/contest/", + dataType: "json", + contentType: "application/json;charset=UTF-8", + data: JSON.stringify(ajaxData), + method: "put", + success: function (data) { + if (!data.code) { + bsAlert("修改成功!"); + vm.showContestListPage(); + } + else { + bsAlert(data.data); + } + } + }); + } + return false; + }); + + if (avalon.vmodels.edit_contest) + var vm = avalon.vmodels.edit_contest; + else + var vm = avalon.define({ + $id: "edit_contest", + title: "", + startTime: "", + endTime: "", + password: "", + isGlobal: true, + allGroups: [], + showGlobalViewRadio: true, + realTimeRank: true, + visible: false, + showContestListPage: function() { + avalon.vmodels.admin.template_url = "template/contest/contest_list.html"; + }, + + contestDescriptionEditor: { + editorId: "contest-description-editor", + placeholder: "比赛介绍内容" + } + }); + + $.ajax({ + url: "/api/user/", + method: "get", + dataType: "json", + success: function (data) { + if (!data.code) { + var admin_type = data.data.admin_type; + if (data.data.admin_type == 1) { + vm.isGlobal = false; + vm.showGlobalViewRadio = false; + } + } + $.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; + } + vm.allGroups = []; + 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); + } + } + }); + } + }); + + + $.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, + weekStart: 1, + language: "zh-CN" + }); + $("#contest_end_time").datetimepicker({ + format: "yyyy-mm-dd hh:ii", + minuteStep: 5, + weekStart: 1, + language: "zh-CN" + }); + }); \ No newline at end of file diff --git a/template/src/admin/contest/edit_contest.html b/template/src/admin/contest/edit_contest.html new file mode 100644 index 0000000..2afc849 --- /dev/null +++ b/template/src/admin/contest/edit_contest.html @@ -0,0 +1,107 @@ +
+
+ +
+ +
+
+
+ + +
+
+
+
+ +
+
+
+ +
+
+
+ + +
+ + +
+
+
+
+ + +
+ + +
+
+
+
+
+ + +
+ + + + + + +
+ +
+
+
+ + +
+ +
+
+
+ +
+   {{ el.name }} +
+
+ +
+ + +
+ +
+
+
+ + +
+ +
+
+
+ +
+
+
+ + From 0bac0da9795333f9986258d80901a3a31c3cbdc1 Mon Sep 17 00:00:00 2001 From: uzi Date: Thu, 29 Oct 2015 17:02:57 +0800 Subject: [PATCH 16/18] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E5=B0=8F=E9=97=AE=E9=A2=98=EF=BC=8C=E4=B8=BB=E8=A6=81=E6=98=AF?= =?UTF-8?q?=E5=9C=A8=E9=9D=9E=E7=AE=A1=E7=90=86=E5=91=98=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E4=BC=9A=E8=B0=83=E7=94=A8models=E7=9A=84?= =?UTF-8?q?=E5=AD=97=E5=85=B8=E5=AF=B9=E8=B1=A1=E7=9A=84get=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E5=AE=9E=E9=99=85=E4=B8=8A=E8=BF=99=E4=B8=AA?= =?UTF-8?q?=E5=AD=97=E5=85=B8=E6=B2=A1=E6=9C=89get=E6=96=B9=E6=B3=95?= =?UTF-8?q?=EF=BC=8C=E4=BC=9A=E5=BC=95=E5=8F=91500=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=88=90=E4=BA=86=E5=88=A4=E6=96=AD=E6=AF=94=E8=B5=9B?= =?UTF-8?q?=EF=BC=88=E6=88=96=E8=80=85=E6=AF=94=E8=B5=9B=E9=A2=98=E7=9B=AE?= =?UTF-8?q?=EF=BC=89=E7=9A=84=E5=88=9B=E5=BB=BA=E8=80=85=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E7=AD=89=E4=BA=8Erequest.user=EF=BC=9B=20=20=20=E5=8F=A6?= =?UTF-8?q?=E5=A4=96=E4=BB=BF=E7=85=A7problem=E6=B7=BB=E5=8A=A0=E4=BA=86?= =?UTF-8?q?=E5=AF=B9=E5=8D=95=E4=B8=AA=E6=AF=94=E8=B5=9B=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E7=9A=84GETapi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contest/views.py | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/contest/views.py b/contest/views.py index 29c943a..d2a22b2 100644 --- a/contest/views.py +++ b/contest/views.py @@ -90,8 +90,8 @@ class ContestAdminAPIView(APIView): try: # 超级管理员可以编辑所有的 contest = Contest.objects.get(id=data["id"]) - if request.user.admin_type != SUPER_ADMIN: - contest = contest.get(created_by=request.user) + if request.user.admin_type != SUPER_ADMIN and contest.created_by != request.user: + return error_response(u"无权访问!") except Contest.DoesNotExist: return error_response(u"该比赛不存在!") try: @@ -144,6 +144,18 @@ class ContestAdminAPIView(APIView): --- response_serializer: ContestSerializer """ + contest_id = request.GET.get("contest_id", None) + if contest_id: + try: + # 普通管理员只能获取自己创建的题目 + # 超级管理员可以获取全部的题目 + contest = Contest.objects.get(id=contest_id) + if request.user.admin_type != SUPER_ADMIN and contest.created_by != request.user: + return error_response(u"题目不存在") + return success_response(ContestSerializer(contest).data) + except Contest.DoesNotExist: + return error_response(u"题目不存在") + if request.user.admin_type == SUPER_ADMIN: contest = Contest.objects.all().order_by("-create_time") else: @@ -171,8 +183,8 @@ class ContestProblemAdminAPIView(APIView): data = serializer.data try: contest = Contest.objects.get(id=data["contest_id"]) - if request.user.admin_type != SUPER_ADMIN: - contest = contest.get(created_by=request.user) + if request.user.admin_type != SUPER_ADMIN and contest.created_by != request.user: + return error_response(u"比赛不存在") except Contest.DoesNotExist: return error_response(u"比赛不存在") contest_problem = ContestProblem.objects.create(title=data["title"], @@ -238,8 +250,8 @@ class ContestProblemAdminAPIView(APIView): if contest_problem_id: try: contest_problem = ContestProblem.objects.get(id=contest_problem_id) - if request.user.admin_type != SUPER_ADMIN: - contest_problem = contest_problem.get(created_by=request.user) + if request.user.admin_type != SUPER_ADMIN and contest_problem.created_by != request.user: + return error_response(u"比赛题目不存在") return success_response(ContestProblemSerializer(contest_problem).data) except ContestProblem.DoesNotExist: return error_response(u"比赛题目不存在") From dec10f1391fabdcad8920991710e7d96c5f914d4 Mon Sep 17 00:00:00 2001 From: uzi Date: Thu, 29 Oct 2015 17:04:52 +0800 Subject: [PATCH 17/18] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E8=BF=9B=E5=85=A5=E9=A1=B5=E9=9D=A2=E5=AF=BC=E8=87=B4=E5=B0=8F?= =?UTF-8?q?=E7=BB=84=E5=88=97=E8=A1=A8=E4=B8=8D=E6=96=AD=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C=E6=AF=8F=E6=AC=A1=E5=85=88?= =?UTF-8?q?=E6=B8=85=E7=A9=BA[CI=20SKIP]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/src/js/app/admin/contest/addContest.js | 1 + 1 file changed, 1 insertion(+) diff --git a/static/src/js/app/admin/contest/addContest.js b/static/src/js/app/admin/contest/addContest.js index b05ba4e..9cbd57d 100644 --- a/static/src/js/app/admin/contest/addContest.js +++ b/static/src/js/app/admin/contest/addContest.js @@ -104,6 +104,7 @@ require(["jquery", "avalon", "editor", "uploader", "bsAlert", "csrfToken", "date bsAlert("您的用户权限只能创建小组内比赛,但是您还没有创建过小组"); return; } + vm.allGroups = []; for (var i = 0; i < data.data.length; i++) { var item = data.data[i]; item["isSelected"] = false; From 118fd45e3e9e571fc944e48bbfe62f36e982d7a6 Mon Sep 17 00:00:00 2001 From: sxw Date: Thu, 29 Oct 2015 17:07:08 +0800 Subject: [PATCH 18/18] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=B0=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E6=AF=94=E8=B5=9B=E9=A1=B5=E7=9A=84=E5=85=A5=E5=8F=A3?= =?UTF-8?q?[CI=20SKIP]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- static/src/js/app/admin/contest/contestList.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/static/src/js/app/admin/contest/contestList.js b/static/src/js/app/admin/contest/contestList.js index f362927..ac24057 100644 --- a/static/src/js/app/admin/contest/contestList.js +++ b/static/src/js/app/admin/contest/contestList.js @@ -24,7 +24,7 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker", editContest: function(contestId){ avalon.vmodels.admin.contestId = contestId; - // todo 修改template_url + avalon.vmodels.admin.template_url = "template/contest/edit_contest.html"; }, showContestProblems: function(contestId){ // todo @@ -50,7 +50,6 @@ require(["jquery", "avalon", "csrfToken", "bsAlert", "editor", "datetimePicker", success: function (data) { if (!data.code) { vm.contestList = data.data.results; - vm.announcementList = data.data.results; avalon.vmodels.contestListPager.totalPage = data.data.total_page; } else {