mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: fix #781
This commit is contained in:
3 files changed
+16
-14
No files matched your search
@@ -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 };
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 });
|
||||
|
||||
Reference in new issue
Block a user