mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
core&ui: support /record?all=1
This commit is contained in:
3 files changed
+26
-14
No files matched your search
@@ -34,11 +34,12 @@ class RecordListHandler extends ContestDetailBaseHandler {
|
||||
@param('lang', Types.String, true)
|
||||
@param('status', Types.Int, true)
|
||||
@param('fullStatus', Types.Boolean)
|
||||
@param('all', Types.Boolean)
|
||||
@param('allDomain', Types.Boolean)
|
||||
async get(
|
||||
domainId: string, page = 1, pid?: string | number, tid?: ObjectId,
|
||||
uidOrName?: string, lang?: string, status?: number, full = false,
|
||||
all = false,
|
||||
all = false, allDomain = false,
|
||||
) {
|
||||
const notification = [];
|
||||
let tdoc = null;
|
||||
@@ -78,11 +79,11 @@ class RecordListHandler extends ContestDetailBaseHandler {
|
||||
}
|
||||
if (lang) q.lang = lang;
|
||||
if (typeof status === 'number') q.status = status;
|
||||
if (all) {
|
||||
if (allDomain) {
|
||||
this.checkPriv(PRIV.PRIV_MANAGE_ALL_DOMAIN);
|
||||
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));
|
||||
const limit = full ? 10 : system.get('pagination.record');
|
||||
let rdocs = invalid
|
||||
@@ -107,6 +108,7 @@ class RecordListHandler extends ContestDetailBaseHandler {
|
||||
pdict,
|
||||
udict,
|
||||
all,
|
||||
allDomain,
|
||||
filterPid: pid,
|
||||
filterTid: tid,
|
||||
filterUidOrName: uidOrName,
|
||||
@@ -115,7 +117,7 @@ class RecordListHandler extends ContestDetailBaseHandler {
|
||||
notification,
|
||||
};
|
||||
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 {
|
||||
all = false;
|
||||
allDomain = false;
|
||||
tid: string;
|
||||
uid: number;
|
||||
pid: number;
|
||||
@@ -250,10 +253,11 @@ class RecordMainConnectionHandler extends ConnectionHandler {
|
||||
@param('uidOrName', Types.UidOrName, true)
|
||||
@param('status', Types.Int, true)
|
||||
@param('pretest', Types.Boolean)
|
||||
@param('all', Types.Boolean)
|
||||
@param('allDomain', Types.Boolean)
|
||||
async prepare(
|
||||
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) {
|
||||
this.tdoc = await contest.get(domainId, tid);
|
||||
@@ -283,9 +287,14 @@ class RecordMainConnectionHandler extends ConnectionHandler {
|
||||
}
|
||||
if (status) this.status = status;
|
||||
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;
|
||||
}
|
||||
if (allDomain) {
|
||||
this.checkPriv(PRIV.PRIV_MANAGE_ALL_DOMAIN);
|
||||
this.allDomain = true;
|
||||
}
|
||||
}
|
||||
|
||||
async message(msg: { rids: string[] }) {
|
||||
@@ -298,13 +307,15 @@ class RecordMainConnectionHandler extends ConnectionHandler {
|
||||
|
||||
@subscribe('record/change')
|
||||
async onRecordChange(rdoc: RecordDoc) {
|
||||
if (!this.all) {
|
||||
if (!this.allDomain) {
|
||||
if (rdoc.domainId !== this.args.domainId) return;
|
||||
if (!this.pretest && typeof rdoc.input === 'string') return;
|
||||
if (rdoc.contest && ![this.tid, '000000000000000000000000'].includes(rdoc.contest.toString())) return;
|
||||
if (this.tid && rdoc.contest?.toString() !== '0'.repeat(24)) {
|
||||
if (contest.isLocked(this.tdoc)) return;
|
||||
if (!contest.canShowSelfRecord.call(this, this.tdoc, true)) return;
|
||||
if (!this.all) {
|
||||
if (rdoc.contest && ![this.tid, '000000000000000000000000'].includes(rdoc.contest.toString())) return;
|
||||
if (this.tid && rdoc.contest?.toString() !== '0'.repeat(24)) {
|
||||
if (contest.isLocked(this.tdoc)) return;
|
||||
if (!contest.canShowSelfRecord.call(this, this.tdoc, true)) return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.pid && rdoc.pid !== this.pid) return;
|
||||
@@ -325,7 +336,7 @@ class RecordMainConnectionHandler extends ConnectionHandler {
|
||||
if (this.applyProjection) rdoc = contest.applyProjection(tdoc, rdoc, this.user);
|
||||
this.send({
|
||||
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 "")
|
||||
+ (("&uidOrName=" + filterUidOrName) if filterUidOrName 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()"))) }}
|
||||
<div class="row">
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{% import "components/problem.html" as problem with context %}
|
||||
<tr data-rid="{{ rdoc['_id'] }}">
|
||||
{% 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">
|
||||
{% 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) }}">
|
||||
|
||||
Reference in new issue
Block a user