Browse Source

分享代码

pull/6/head
richie 6 years ago
parent
commit
187ad7c30b
  1. 7
      models-built/judge_state.js
  2. 2
      models-built/judge_state.js.map
  3. 6
      models/judge_state.ts
  4. 2
      modules/submission.js

7
models-built/judge_state.js

@ -271,7 +271,7 @@ var JudgeState = /** @class */ (function (_super) {
return __generator(this, function (_a) { return __generator(this, function (_a) {
switch (_a.label) { switch (_a.label) {
case 0: case 0:
this.is_public = true; this.is_share = true;
_a.label = 1; _a.label = 1;
case 1: case 1:
_a.trys.push([1, 3, , 4]); _a.trys.push([1, 3, , 4]);
@ -367,6 +367,11 @@ var JudgeState = /** @class */ (function (_super) {
TypeORM.Column({ nullable: true, type: "boolean" }), TypeORM.Column({ nullable: true, type: "boolean" }),
__metadata("design:type", Boolean) __metadata("design:type", Boolean)
], JudgeState.prototype, "is_public"); ], JudgeState.prototype, "is_public");
__decorate([
TypeORM.Index(),
TypeORM.Column({ nullable: true, type: "boolean" }),
__metadata("design:type", Boolean)
], JudgeState.prototype, "is_share");
JudgeState = __decorate([ JudgeState = __decorate([
TypeORM.Entity(), TypeORM.Entity(),
TypeORM.Index(['type', 'type_info']), TypeORM.Index(['type', 'type_info']),

2
models-built/judge_state.js.map

File diff suppressed because one or more lines are too long

6
models/judge_state.ts

@ -102,6 +102,10 @@ export default class JudgeState extends Model {
@TypeORM.Column({ nullable: true, type: "boolean" }) @TypeORM.Column({ nullable: true, type: "boolean" })
is_public: boolean; is_public: boolean;
@TypeORM.Index()
@TypeORM.Column({ nullable: true, type: "boolean" })
is_share:boolean;
user?: User; user?: User;
problem?: Problem; problem?: Problem;
@ -190,7 +194,7 @@ export default class JudgeState extends Model {
} }
async share() { async share() {
this.is_public = true; this.is_share = true;
try { try {
await this.save(); await this.save();
} catch (err) { } catch (err) {

2
modules/submission.js

@ -198,7 +198,7 @@ app.get('/submission/:id', async (req, res) => {
if (isAdmin || isAuthor) { if (isAdmin || isAuthor) {
currentConfig.showShare = true; currentConfig.showShare = true;
} }
if (isAdmin || isAuthor || judge.is_public) { if (isAdmin || isAuthor || judge.is_share) {
judge.code = (judge.problem.type !== 'submit-answer') ? judge.code.toString("utf8") : ''; judge.code = (judge.problem.type !== 'submit-answer') ? judge.code.toString("utf8") : '';
} else { } else {
judge.code = "作者没有开放此题代码,请联系作者分享。"; judge.code = "作者没有开放此题代码,请联系作者分享。";

Loading…
Cancel
Save