Browse Source

Fix invalid type when modify contest

pull/6/head
Menci 8 years ago
parent
commit
15d6b61b4d
  1. 2
      modules/contest.js

2
modules/contest.js

@ -91,6 +91,7 @@ app.post('/contest/:id/edit', async (req, res) => {
contest.ranklist_id = ranklist.id; contest.ranklist_id = ranklist.id;
// Only new contest can be set type // Only new contest can be set type
if (!['noi', 'ioi', 'acm'].includes(req.body.type)) throw new ErrorMessage('无效的赛制。');
contest.type = req.body.type; contest.type = req.body.type;
} }
@ -99,7 +100,6 @@ app.post('/contest/:id/edit', async (req, res) => {
contest.subtitle = req.body.subtitle; contest.subtitle = req.body.subtitle;
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('|');
if (!['noi', 'ioi', 'acm'].includes(req.body.type)) throw new ErrorMessage('无效的赛制。');
contest.information = req.body.information; contest.information = req.body.information;
contest.start_time = syzoj.utils.parseDate(req.body.start_time); contest.start_time = syzoj.utils.parseDate(req.body.start_time);
contest.end_time = syzoj.utils.parseDate(req.body.end_time); contest.end_time = syzoj.utils.parseDate(req.body.end_time);

Loading…
Cancel
Save