mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core&ui: support /record?all=1
This commit is contained in:
3 files changed
+22
-10
No files matched your search
@@ -34,11 +34,12 @@ class RecordListHandler extends ContestDetailBaseHandler {
|
|||||||
@param('lang', Types.String, true)
|
@param('lang', Types.String, true)
|
||||||
@param('status', Types.Int, true)
|
@param('status', Types.Int, true)
|
||||||
@param('fullStatus', Types.Boolean)
|
@param('fullStatus', Types.Boolean)
|
||||||
|
@param('all', Types.Boolean)
|
||||||
@param('allDomain', Types.Boolean)
|
@param('allDomain', Types.Boolean)
|
||||||
async get(
|
async get(
|
||||||
domainId: string, page = 1, pid?: string | number, tid?: ObjectId,
|
domainId: string, page = 1, pid?: string | number, tid?: ObjectId,
|
||||||
uidOrName?: string, lang?: string, status?: number, full = false,
|
uidOrName?: string, lang?: string, status?: number, full = false,
|
||||||
all = false,
|
all = false, allDomain = false,
|
||||||
) {
|
) {
|
||||||
const notification = [];
|
const notification = [];
|
||||||
let tdoc = null;
|
let tdoc = null;
|
||||||
@@ -78,11 +79,11 @@ class RecordListHandler extends ContestDetailBaseHandler {
|
|||||||
}
|
}
|
||||||
if (lang) q.lang = lang;
|
if (lang) q.lang = lang;
|
||||||
if (typeof status === 'number') q.status = status;
|
if (typeof status === 'number') q.status = status;
|
||||||
if (all) {
|
if (allDomain) {
|
||||||
this.checkPriv(PRIV.PRIV_MANAGE_ALL_DOMAIN);
|
this.checkPriv(PRIV.PRIV_MANAGE_ALL_DOMAIN);
|
||||||
delete q.contest;
|
delete q.contest;
|
||||||
}
|
}
|
||||||
let cursor = record.getMulti(all ? '' : domainId, q).sort('_id', -1);
|
let cursor = record.getMulti(allDomain ? '' : domainId, q).sort('_id', -1);
|
||||||
if (!full) cursor = cursor.project(buildProjection(record.PROJECTION_LIST));
|
if (!full) cursor = cursor.project(buildProjection(record.PROJECTION_LIST));
|
||||||
const limit = full ? 10 : system.get('pagination.record');
|
const limit = full ? 10 : system.get('pagination.record');
|
||||||
let rdocs = invalid
|
let rdocs = invalid
|
||||||
@@ -107,6 +108,7 @@ class RecordListHandler extends ContestDetailBaseHandler {
|
|||||||
pdict,
|
pdict,
|
||||||
udict,
|
udict,
|
||||||
all,
|
all,
|
||||||
|
allDomain,
|
||||||
filterPid: pid,
|
filterPid: pid,
|
||||||
filterTid: tid,
|
filterTid: tid,
|
||||||
filterUidOrName: uidOrName,
|
filterUidOrName: uidOrName,
|
||||||
@@ -115,7 +117,7 @@ class RecordListHandler extends ContestDetailBaseHandler {
|
|||||||
notification,
|
notification,
|
||||||
};
|
};
|
||||||
if (this.user.hasPriv(PRIV.PRIV_VIEW_JUDGE_STATISTICS) && !full) {
|
if (this.user.hasPriv(PRIV.PRIV_VIEW_JUDGE_STATISTICS) && !full) {
|
||||||
this.response.body.statistics = await record.stat(all ? undefined : domainId);
|
this.response.body.statistics = await record.stat(allDomain ? undefined : domainId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -237,6 +239,7 @@ class RecordDetailHandler extends ContestDetailBaseHandler {
|
|||||||
|
|
||||||
class RecordMainConnectionHandler extends ConnectionHandler {
|
class RecordMainConnectionHandler extends ConnectionHandler {
|
||||||
all = false;
|
all = false;
|
||||||
|
allDomain = false;
|
||||||
tid: string;
|
tid: string;
|
||||||
uid: number;
|
uid: number;
|
||||||
pid: number;
|
pid: number;
|
||||||
@@ -250,10 +253,11 @@ class RecordMainConnectionHandler extends ConnectionHandler {
|
|||||||
@param('uidOrName', Types.UidOrName, true)
|
@param('uidOrName', Types.UidOrName, true)
|
||||||
@param('status', Types.Int, true)
|
@param('status', Types.Int, true)
|
||||||
@param('pretest', Types.Boolean)
|
@param('pretest', Types.Boolean)
|
||||||
|
@param('all', Types.Boolean)
|
||||||
@param('allDomain', Types.Boolean)
|
@param('allDomain', Types.Boolean)
|
||||||
async prepare(
|
async prepare(
|
||||||
domainId: string, tid?: ObjectId, pid?: string | number, uidOrName?: string,
|
domainId: string, tid?: ObjectId, pid?: string | number, uidOrName?: string,
|
||||||
status?: number, pretest = false, all = false,
|
status?: number, pretest = false, all = false, allDomain = false,
|
||||||
) {
|
) {
|
||||||
if (tid) {
|
if (tid) {
|
||||||
this.tdoc = await contest.get(domainId, tid);
|
this.tdoc = await contest.get(domainId, tid);
|
||||||
@@ -283,9 +287,14 @@ class RecordMainConnectionHandler extends ConnectionHandler {
|
|||||||
}
|
}
|
||||||
if (status) this.status = status;
|
if (status) this.status = status;
|
||||||
if (all) {
|
if (all) {
|
||||||
this.checkPriv(PRIV.PRIV_MANAGE_ALL_DOMAIN);
|
this.checkPerm(PERM.PERM_VIEW_CONTEST_HIDDEN_SCOREBOARD);
|
||||||
|
this.checkPerm(PERM.PERM_VIEW_HOMEWORK_HIDDEN_SCOREBOARD);
|
||||||
this.all = true;
|
this.all = true;
|
||||||
}
|
}
|
||||||
|
if (allDomain) {
|
||||||
|
this.checkPriv(PRIV.PRIV_MANAGE_ALL_DOMAIN);
|
||||||
|
this.allDomain = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async message(msg: { rids: string[] }) {
|
async message(msg: { rids: string[] }) {
|
||||||
@@ -298,15 +307,17 @@ class RecordMainConnectionHandler extends ConnectionHandler {
|
|||||||
|
|
||||||
@subscribe('record/change')
|
@subscribe('record/change')
|
||||||
async onRecordChange(rdoc: RecordDoc) {
|
async onRecordChange(rdoc: RecordDoc) {
|
||||||
if (!this.all) {
|
if (!this.allDomain) {
|
||||||
if (rdoc.domainId !== this.args.domainId) return;
|
if (rdoc.domainId !== this.args.domainId) return;
|
||||||
if (!this.pretest && typeof rdoc.input === 'string') return;
|
if (!this.pretest && typeof rdoc.input === 'string') return;
|
||||||
|
if (!this.all) {
|
||||||
if (rdoc.contest && ![this.tid, '000000000000000000000000'].includes(rdoc.contest.toString())) return;
|
if (rdoc.contest && ![this.tid, '000000000000000000000000'].includes(rdoc.contest.toString())) return;
|
||||||
if (this.tid && rdoc.contest?.toString() !== '0'.repeat(24)) {
|
if (this.tid && rdoc.contest?.toString() !== '0'.repeat(24)) {
|
||||||
if (contest.isLocked(this.tdoc)) return;
|
if (contest.isLocked(this.tdoc)) return;
|
||||||
if (!contest.canShowSelfRecord.call(this, this.tdoc, true)) return;
|
if (!contest.canShowSelfRecord.call(this, this.tdoc, true)) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (this.pid && rdoc.pid !== this.pid) return;
|
if (this.pid && rdoc.pid !== this.pid) return;
|
||||||
if (this.uid && rdoc.uid !== this.uid) return;
|
if (this.uid && rdoc.uid !== this.uid) return;
|
||||||
|
|
||||||
@@ -325,7 +336,7 @@ class RecordMainConnectionHandler extends ConnectionHandler {
|
|||||||
if (this.applyProjection) rdoc = contest.applyProjection(tdoc, rdoc, this.user);
|
if (this.applyProjection) rdoc = contest.applyProjection(tdoc, rdoc, this.user);
|
||||||
this.send({
|
this.send({
|
||||||
html: await this.renderHTML('record_main_tr.html', {
|
html: await this.renderHTML('record_main_tr.html', {
|
||||||
rdoc, udoc, pdoc, tdoc, all: this.all,
|
rdoc, udoc, pdoc, tdoc, allDomain: this.allDomain,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,8 @@
|
|||||||
+ (("&tid=" + filterTid) if filterTid else "")
|
+ (("&tid=" + filterTid) if filterTid else "")
|
||||||
+ (("&uidOrName=" + filterUidOrName) if filterUidOrName else "")
|
+ (("&uidOrName=" + filterUidOrName) if filterUidOrName else "")
|
||||||
+ (("&pid=" + filterPid) if filterPid else "")
|
+ (("&pid=" + filterPid) if filterPid else "")
|
||||||
+ ("&allDomain=1" if all else "")
|
+ ("&all=1" if all else "")
|
||||||
|
+ ("&allDomain=1" if allDomain else "")
|
||||||
) }}
|
) }}
|
||||||
{{ set(UiContext, 'rids', rdocs.map(eval("rdoc=>rdoc._id.toString()"))) }}
|
{{ set(UiContext, 'rids', rdocs.map(eval("rdoc=>rdoc._id.toString()"))) }}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
{% import "components/problem.html" as problem with context %}
|
{% import "components/problem.html" as problem with context %}
|
||||||
<tr data-rid="{{ rdoc['_id'] }}">
|
<tr data-rid="{{ rdoc['_id'] }}">
|
||||||
{% set _isPretest = rdoc.contest and rdoc.contest.toString() == '000000000000000000000000' %}
|
{% set _isPretest = rdoc.contest and rdoc.contest.toString() == '000000000000000000000000' %}
|
||||||
{{ record.render_status_td(rdoc, allDomain = all) }}
|
{{ record.render_status_td(rdoc, allDomain = allDomain) }}
|
||||||
<td class="col--problem col--problem-name">
|
<td class="col--problem col--problem-name">
|
||||||
{% if handler.user.hasPerm(perm.PERM_REJUDGE) and not rdoc.files.hack and not _isPretest %}
|
{% if handler.user.hasPerm(perm.PERM_REJUDGE) and not rdoc.files.hack and not _isPretest %}
|
||||||
<form class="form--inline" method="post" action="{{ url('record_detail', rid=rdoc._id, domainId=rdoc.domainId) }}">
|
<form class="form--inline" method="post" action="{{ url('record_detail', rid=rdoc._id, domainId=rdoc.domainId) }}">
|
||||||
|
|||||||
Reference in new issue
Block a user