|
|
@ -89,6 +89,9 @@ app.post('/contest/:id/edit', async (req, res) => { |
|
|
|
let ranklist = await ContestRanklist.create(); |
|
|
|
let ranklist = await ContestRanklist.create(); |
|
|
|
await ranklist.save(); |
|
|
|
await ranklist.save(); |
|
|
|
contest.ranklist_id = ranklist.id; |
|
|
|
contest.ranklist_id = ranklist.id; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Only new contest can be set type
|
|
|
|
|
|
|
|
contest.type = req.body.type; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!req.body.title.trim()) throw new ErrorMessage('比赛名不能为空。'); |
|
|
|
if (!req.body.title.trim()) throw new ErrorMessage('比赛名不能为空。'); |
|
|
@ -97,7 +100,6 @@ app.post('/contest/:id/edit', async (req, res) => { |
|
|
|
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('无效的赛制。'); |
|
|
|
if (!['noi', 'ioi', 'acm'].includes(req.body.type)) throw new ErrorMessage('无效的赛制。'); |
|
|
|
contest.type = req.body.type; |
|
|
|
|
|
|
|
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); |
|
|
|