From 09b2047f963b791e082209d9318ff50d3466c449 Mon Sep 17 00:00:00 2001 From: Pisces000221 <1786762946@qq.com> Date: Thu, 6 Jul 2017 22:24:54 +0800 Subject: [PATCH 1/4] Fix link to additional files during contests --- modules/contest.js | 1 + modules/problem.js | 13 ++++++++++++- views/problem.ejs | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/contest.js b/modules/contest.js index 9c7b042..d291552 100644 --- a/modules/contest.js +++ b/modules/contest.js @@ -337,6 +337,7 @@ app.get('/contest/:id/:pid', async (req, res) => { let problem_id = problems_id[pid - 1]; let problem = await Problem.fromID(problem_id); + await problem.loadRelationships(); contest.ended = await contest.isEnded(); if (!(await contest.isRunning() || contest.ended)) { diff --git a/modules/problem.js b/modules/problem.js index 9961334..873e29f 100644 --- a/modules/problem.js +++ b/modules/problem.js @@ -749,7 +749,18 @@ app.get('/problem/:id/download/additional_file', async (req, res) => { let problem = await Problem.fromID(id); if (!problem) throw new ErrorMessage('无此题目。'); - if (!await problem.isAllowedUseBy(res.locals.user)) throw new ErrorMessage('您没有权限进行此操作。'); + + // XXX: Reduce duplication (see the '/problem/:id/submit' handler) + let contest_id = parseInt(req.query.contest_id); + if (contest_id) { + let contest = await Contest.fromID(contest_id); + if (!contest) throw new ErrorMessage('无此比赛。'); + if (!await contest.isRunning()) throw new ErrorMessage('比赛未开始或已结束。'); + let problems_id = await contest.getProblems(); + if (!problems_id.includes(id)) throw new ErrorMessage('无此题目。'); + } else { + if (!await problem.isAllowedUseBy(res.locals.user)) throw new ErrorMessage('您没有权限进行此操作。'); + } await problem.loadRelationships(); diff --git a/views/problem.ejs b/views/problem.ejs index c85bd62..62b8191 100644 --- a/views/problem.ejs +++ b/views/problem.ejs @@ -91,7 +91,7 @@ div[class*=ace_br] { 统计 测试数据 <% } %> - <% if (problem.additional_file) { %>附加文件<% } %> + <% if (problem.additional_file) { %>附加文件<% } %> <% if (!contest) { %>
From 105419492ce6b48370afe000bb6a513f04d7da3f Mon Sep 17 00:00:00 2001 From: Pisces000221 <1786762946@qq.com> Date: Thu, 6 Jul 2017 22:31:56 +0800 Subject: [PATCH 2/4] Update README --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index eafb630..6ae8f51 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,9 @@ git clone https://github.com/syzoj/syzoj cd syzoj ``` -Install dependencies with `npm install` or `yarn`. +Install dependencies with `npm install` or `yarn`. Also, follow the instructions [here](https://www.npmjs.com/package/node-7z#installation) to install `7z` executable used by the `node-7z` package. -Copy the `config-example.json` file to `config.json`, and change the configures. +Copy `config-example.json` to `config.json`, and make necessary changes. ## Database SYZOJ 2 uses [Sequelize](http://sequelizejs.com), which supports many database systems, including MySQL and Sqlite. From eb44ec7786dda8f62c74ee58315fd7d7ef538ff4 Mon Sep 17 00:00:00 2001 From: Pisces000221 <1786762946@qq.com> Date: Thu, 6 Jul 2017 22:39:52 +0800 Subject: [PATCH 3/4] Fix link to additional files after contest ends --- views/problem.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/problem.ejs b/views/problem.ejs index 62b8191..43cb34d 100644 --- a/views/problem.ejs +++ b/views/problem.ejs @@ -91,7 +91,7 @@ div[class*=ace_br] { 统计 测试数据 <% } %> - <% if (problem.additional_file) { %>附加文件<% } %> + <% if (problem.additional_file) { %>附加文件<% } %>
<% if (!contest) { %>
From b5d987f97c3d1890fd4778a9f68040e8a379f17a Mon Sep 17 00:00:00 2001 From: Pisces000221 <1786762946@qq.com> Date: Mon, 24 Jul 2017 13:38:19 +0800 Subject: [PATCH 4/4] Fix incorrect default value for type_info --- models/judge_state.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/judge_state.js b/models/judge_state.js index 27ae41a..d4369fd 100644 --- a/models/judge_state.js +++ b/models/judge_state.js @@ -83,7 +83,7 @@ class JudgeState extends Model { submit_time: parseInt((new Date()).getTime() / 1000), type: 0, - type_info: '', + type_info: 0, pending: true,