diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index 5f42d6817..054b51648 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "2.29.14", + "version": "2.29.15", "bin": "bin/hydrooj.js", "main": "dist/loader.js", "typings": "dist/loader.d.ts", diff --git a/packages/hydrooj/src/handler/record.ts b/packages/hydrooj/src/handler/record.ts index 675c1427b..3767c0a25 100644 --- a/packages/hydrooj/src/handler/record.ts +++ b/packages/hydrooj/src/handler/record.ts @@ -31,11 +31,12 @@ class RecordListHandler extends Handler { domainId: string, page = 1, pid?: string, tid?: ObjectID, uidOrName?: string, status?: number, full = false, all = false, ) { + let tdoc = null; this.response.template = 'record_main.html'; const q: FilterQuery = { 'contest.tid': tid, hidden: false }; if (full) uidOrName = this.user._id.toString(); if (tid) { - const tdoc = await contest.get(domainId, tid, -1); + tdoc = await contest.get(domainId, tid, -1); if (!tdoc) throw new ContestNotFoundError(domainId, pid); if (!contest.canShowScoreboard.call(this, tdoc, true)) throw new PermissionError(PERM.PERM_VIEW_CONTEST_HIDDEN_SCOREBOARD); } @@ -65,12 +66,13 @@ class RecordListHandler extends Handler { canViewProblem ? problem.getList(domainId, rdocs.map( (rdoc) => (rdoc.domainId === domainId ? rdoc.pid : `${rdoc.pdomain}:${rdoc.pid}`), - ), canViewProblemHidden || this.user._id, false) + ), (!!tid) || canViewProblemHidden || this.user._id, false) : Object.fromEntries([rdocs.map((rdoc) => [rdoc.pid, { ...problem.default, pid: rdoc.pid }])]), ]); this.response.body = { page, rdocs, + tdoc, pdict, udict, filterPid: pid, @@ -232,12 +234,19 @@ class RecordMainConnectionHandler extends ConnectionHandler { user.getById(this.domainId, rdoc.uid), problem.get(this.domainId, rdoc.pid), ]); - if (pdoc) { + const tdoc = this.tid ? contest.get(this.domainId, new ObjectID(this.tid)) : null; + if (pdoc && !rdoc.contest) { if (pdoc.hidden && !this.user.own(pdoc) && !this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN)) pdoc = null; if (!this.user.hasPerm(PERM.PERM_VIEW_PROBLEM)) pdoc = null; } if (this.pretest) this.send({ rdoc }); - else this.send({ html: await this.renderHTML('record_main_tr.html', { rdoc, udoc, pdoc }) }); + else { + this.send({ + html: await this.renderHTML('record_main_tr.html', { + rdoc, udoc, pdoc, tdoc, + }), + }); + } } } diff --git a/packages/hydrooj/src/model/record.ts b/packages/hydrooj/src/model/record.ts index df8ff8568..d0e756947 100644 --- a/packages/hydrooj/src/model/record.ts +++ b/packages/hydrooj/src/model/record.ts @@ -21,7 +21,8 @@ class RecordModel { static PROJECTION_LIST: (keyof RecordDoc)[] = [ '_id', 'score', 'time', 'memory', 'lang', 'uid', 'pid', 'rejudged', 'hidden', 'progress', - 'contest', 'judger', 'judgeAt', 'status', 'pdomain', + 'contest', 'judger', 'judgeAt', 'status', 'domainId', + 'pdomain', ]; static async submissionPriority(uid: number, base: number = 0) { diff --git a/packages/ui-default/package.json b/packages/ui-default/package.json index 5f2d9b9b6..b98faf413 100644 --- a/packages/ui-default/package.json +++ b/packages/ui-default/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/ui-default", - "version": "4.12.7", + "version": "4.12.8", "author": "undefined ", "license": "AGPL-3.0", "main": "hydro.js", diff --git a/packages/ui-default/templates/record_main.html b/packages/ui-default/templates/record_main.html index 9eca8d3c9..1021e2a5d 100644 --- a/packages/ui-default/templates/record_main.html +++ b/packages/ui-default/templates/record_main.html @@ -86,7 +86,7 @@ {%- for rdoc in rdocs -%} {% set udoc = udict[rdoc['uid']] %} - {% set pdoc = pdict[rdoc['pid']] %} + {% set pdoc = pdict[rdoc['pid']] or pdict[rdoc.pdomain + ':' + rdoc.pid] %} {% include 'record_main_tr.html' %} {%- endfor -%} diff --git a/packages/ui-default/templates/record_main_tr.html b/packages/ui-default/templates/record_main_tr.html index 065454d1d..973b03bbb 100644 --- a/packages/ui-default/templates/record_main_tr.html +++ b/packages/ui-default/templates/record_main_tr.html @@ -13,7 +13,9 @@ | {% endif %} - {% if pdoc and (not pdoc.hidden or handler.user.hasPerm(perm.PERM_VIEW_PROBLEM_HIDDEN) or handler.user.own(pdoc)) %} + {% if pdoc and rdoc.contest %} + {{ problem.render_problem_title(pdoc, tdoc=tdoc, show_tags=false, show_invisible_flag=false) }} + {% elif pdoc and (not pdoc.hidden or handler.user.hasPerm(perm.PERM_VIEW_PROBLEM_HIDDEN) or handler.user.own(pdoc)) %} {{ problem.render_problem_title(pdoc, show_tags=false) }} {% else %} *