core: 修复contest_record题号显示错误的问题

This commit is contained in:
undefined committed 2021-07-03 16:20:38 +08:00
1 parent 82e33ac958
commit 74cd467bfa
6 files changed
+21 -9

No files matched your search

+1 -1
View File
@@ -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",
+13 -4
View File
@@ -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<RecordDoc> = { '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,
}),
});
}
}
}
+2 -1
View File
@@ -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) {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/ui-default",
"version": "4.12.7",
"version": "4.12.8",
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0",
"main": "hydro.js",
@@ -86,7 +86,7 @@
<tbody>
{%- 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 -%}
</tbody>
@@ -13,7 +13,9 @@
</button> |
</form>
{% 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 %}
*