Browse Source

Fix error message on empty title

pull/6/head
Menci 8 years ago
parent
commit
f342c27102
  1. 2
      modules/contest.js
  2. 1
      modules/discussion.js
  3. 4
      modules/problem.js

2
modules/contest.js

@ -87,7 +87,7 @@ app.post('/contest/:id/edit', async (req, res) => {
contest.ranklist_id = ranklist.id; contest.ranklist_id = ranklist.id;
} }
if (!req.body.trim()) throw new ErrorMessage('比赛名不能为空。'); if (!req.body.title.trim()) throw new ErrorMessage('比赛名不能为空。');
contest.title = req.body.title; contest.title = req.body.title;
if (!Array.isArray(req.body.problems)) req.body.problems = [req.body.problems]; if (!Array.isArray(req.body.problems)) req.body.problems = [req.body.problems];
contest.problems = req.body.problems.join('|'); contest.problems = req.body.problems.join('|');

1
modules/discussion.js

@ -120,6 +120,7 @@ app.post('/article/:id/edit', async (req, res) => {
if (!await article.isAllowedEditBy(res.locals.user)) throw new ErrorMessage('您没有权限进行此操作。'); if (!await article.isAllowedEditBy(res.locals.user)) throw new ErrorMessage('您没有权限进行此操作。');
} }
if (!req.body.title.trim()) throw new ErrorMessage('标题不能为空。');
article.title = req.body.title; article.title = req.body.title;
article.content = req.body.content; article.content = req.body.content;
article.update_time = time; article.update_time = time;

4
modules/problem.js

@ -256,7 +256,7 @@ app.post('/problem/:id/edit', async (req, res) => {
} }
} }
if (!req.body.trim()) throw new ErrorMessage('题目名不能为空。'); if (!req.body.title.trim()) throw new ErrorMessage('题目名不能为空。');
problem.title = req.body.title; problem.title = req.body.title;
problem.description = req.body.description; problem.description = req.body.description;
problem.input_format = req.body.input_format; problem.input_format = req.body.input_format;
@ -345,7 +345,7 @@ app.post('/problem/:id/import', async (req, res) => {
if (!json.success) throw new ErrorMessage('题目加载失败。', null, json.error); if (!json.success) throw new ErrorMessage('题目加载失败。', null, json.error);
if (!json.obj.trim()) throw new ErrorMessage('题目名不能为空。'); if (!json.obj.title.trim()) throw new ErrorMessage('题目名不能为空。');
problem.title = json.obj.title; problem.title = json.obj.title;
problem.description = json.obj.description; problem.description = json.obj.description;
problem.input_format = json.obj.input_format; problem.input_format = json.obj.input_format;

Loading…
Cancel
Save