This commit is contained in:
undefined committed 2024-04-10 18:21:18 +08:00
1 parent 803400822c
commit 9f302e7b71
3 files changed
+16 -14

No files matched your search

+14 -12
View File
@@ -261,21 +261,23 @@ export class ContestProblemListHandler extends ContestDetailBaseHandler {
}
this.response.body.psdict = this.tsdoc.detail || {};
const psdocs: any[] = Object.values(this.response.body.psdict);
if (contest.canShowSelfRecord.call(this, this.tdoc)) {
[this.response.body.rdict, this.response.body.rdocs] = await Promise.all([
const canViewRecord = contest.canShowSelfRecord.call(this, this.tdoc);
this.response.body.canViewRecord = canViewRecord;
[this.response.body.rdict, this.response.body.rdocs] = canViewRecord
? await Promise.all([
record.getList(domainId, psdocs.map((i: any) => i.rid)),
await record.getMulti(domainId, { contest: tid, uid: this.user._id })
record.getMulti(domainId, { contest: tid, uid: this.user._id })
.sort({ _id: -1 }).toArray(),
]);
if (!this.user.own(this.tdoc) && !this.user.hasPerm(PERM.PERM_EDIT_CONTEST)) {
this.response.body.rdocs = this.response.body.rdocs.map((rdoc) => contest.applyProjection(this.tdoc, rdoc, this.user));
for (const psdoc of psdocs) {
this.response.body.rdict[psdoc.rid] = contest.applyProjection(this.tdoc, this.response.body.rdict[psdoc.rid], this.user);
}
])
: [Object.fromEntries(psdocs.map((i) => [i.rid, { _id: i.rid }])), []];
if (!this.user.own(this.tdoc) && !this.user.hasPerm(PERM.PERM_EDIT_CONTEST)) {
this.response.body.rdocs = this.response.body.rdocs.map((rdoc) => contest.applyProjection(this.tdoc, rdoc, this.user));
for (const psdoc of psdocs) {
this.response.body.rdict[psdoc.rid] = contest.applyProjection(this.tdoc, this.response.body.rdict[psdoc.rid], this.user);
}
for (const key in this.response.body.psdict) {
this.response.body.psdict[key] = contest.applyProjection(this.tdoc, this.response.body.psdict[key], this.user);
}
this.response.body.canViewRecord = true;
} else {
for (const i of psdocs) this.response.body.rdict[i.rid] = { _id: i.rid };
}
}
+1 -1
View File
@@ -549,7 +549,7 @@ export class ProblemSubmitHandler extends ProblemDetailHandler {
}
if (tid && !pretest && !contest.canShowSelfRecord.call(this, this.tdoc)) {
this.response.body = { tid };
this.response.redirect = this.url(this.tdoc.rule === 'homework' ? 'homework_detail' : 'contest_detail', { tid });
this.response.redirect = this.url(this.tdoc.rule === 'homework' ? 'homework_detail' : 'contest_problemlist', { tid });
} else {
this.response.body = { rid };
this.response.redirect = this.url('record_detail', { rid });