From a36dd1d267f73f2ef8134f69a99ef00e118ce44e Mon Sep 17 00:00:00 2001 From: hohoTT <609029365@qq.com> Date: Thu, 13 Aug 2015 18:03:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=89=8D=E7=AB=AF=E5=88=9B=E5=BB=BA=E9=A2=98?= =?UTF-8?q?=E7=9B=AE=E7=95=8C=E9=9D=A2=E5=A2=9E=E5=8A=A0=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E6=8F=8F=E8=BF=B0=E5=92=8C=E8=BE=93=E5=87=BA=E6=8F=8F=E8=BF=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- problem/migrations/0004_auto_20150813_1459.py | 26 +++++++++++++++++ .../src/js/app/admin/problem/add_problem.js | 28 ++++++++++++++----- template/admin/problem/add_problem.html | 14 ++++++++-- 3 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 problem/migrations/0004_auto_20150813_1459.py diff --git a/problem/migrations/0004_auto_20150813_1459.py b/problem/migrations/0004_auto_20150813_1459.py new file mode 100644 index 00000000..387a87c6 --- /dev/null +++ b/problem/migrations/0004_auto_20150813_1459.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('problem', '0003_auto_20150810_2233'), + ] + + operations = [ + migrations.AddField( + model_name='problem', + name='description_input', + field=models.CharField(default='hello', max_length=10000), + preserve_default=False, + ), + migrations.AddField( + model_name='problem', + name='description_output', + field=models.CharField(default='hello', max_length=10000), + preserve_default=False, + ), + ] diff --git a/static/src/js/app/admin/problem/add_problem.js b/static/src/js/app/admin/problem/add_problem.js index d2eda564..ebb661ed 100644 --- a/static/src/js/app/admin/problem/add_problem.js +++ b/static/src/js/app/admin/problem/add_problem.js @@ -53,10 +53,17 @@ require(["jquery", "avalon", "editor", "uploader", "bs_alert", "csrf", "tagEdito } } }, - source: { + input_description: { validators: { notEmpty: { - message: "请输入题目来源" + message: "请填写输入描述" + } + } + }, + output_description: { + validators: { + notEmpty: { + message: "请填写输出描述" } } } @@ -72,10 +79,6 @@ require(["jquery", "avalon", "editor", "uploader", "bs_alert", "csrf", "tagEdito bs_alert("题目描述不能为空!"); return; } - if (vm.hint == '') { - bs_alert("提示不能为空!"); - return; - } var ajaxData = { title: vm.title, description: vm.description, @@ -86,6 +89,8 @@ require(["jquery", "avalon", "editor", "uploader", "bs_alert", "csrf", "tagEdito hint: vm.hint, source: vm.source, tags: $("#tags").tagEditor("getTags")[0].tags, + input_description: vm.input_description, + output_description: vm.output_description, difficulty: vm.difficulty }; if (vm.samples.length == 0) { @@ -93,6 +98,13 @@ require(["jquery", "avalon", "editor", "uploader", "bs_alert", "csrf", "tagEdito return; } + for(var i = 0; i < vm.samples.length; i++){ + if (vm.samples[i].input == "" || vm.samples[i].output == ""){ + bs_alert("样例输入与样例输出不能为空!"); + return; + } + } + if (tags.length == 0) { bs_alert("请至少添加一个标签,这将有利于用户发现你的题目!"); return; @@ -147,12 +159,14 @@ require(["jquery", "avalon", "editor", "uploader", "bs_alert", "csrf", "tagEdito description: "", cpu: 1000, memory: 256, - samples: [], + samples: [{input: "", output: "", "visible": true}], hint: "", visible: true, difficulty: 0, tags: [], tag: "", + input_description: "", + output_description: "", test_case_id: "", testCaseList: [], uploadSuccess: false, diff --git a/template/admin/problem/add_problem.html b/template/admin/problem/add_problem.html index 0b952c9a..a6cf14ca 100644 --- a/template/admin/problem/add_problem.html +++ b/template/admin/problem/add_problem.html @@ -3,12 +3,12 @@
- +
- + 请填写题目描述
@@ -38,6 +38,16 @@
+
+
+ +
+
+
+ +

添加