core: UserModel.getListForRender: support extra fields

This commit is contained in:
undefined committed 2024-08-12 02:46:02 +08:00
1 parent f86b8f99f8
commit c171c06dec
5 files changed
+19 -11

No files matched your search

+9 -4
View File
@@ -562,7 +562,10 @@ export class ContestManagementHandler extends ContestManagementBaseHandler {
owner_udoc: await user.getById(domainId, this.tdoc.owner),
pdict: await problem.getList(domainId, this.tdoc.pids, true, true, [...problem.PROJECTION_CONTEST_LIST, 'tag']),
files: sortFiles(this.tdoc.files || []),
udict: await user.getListForRender(domainId, tcdocs.map((i) => i.owner), this.user.hasPerm(PERM.PERM_VIEW_DISPLAYNAME)),
udict: await user.getListForRender(
domainId, tcdocs.map((i) => i.owner),
this.user.hasPerm(PERM.PERM_VIEW_DISPLAYNAME) ? ['displayName'] : []
),
tcdocs,
urlForFile: (filename: string) => this.url('contest_file_download', { tid, filename }),
};
@@ -668,8 +671,10 @@ export class ContestUserHandler extends ContestManagementBaseHandler {
for (const tsdoc of tsdocs) {
tsdoc.endAt = (this.tdoc.duration && tsdoc.startAt) ? moment(tsdoc.startAt).add(this.tdoc.duration, 'hours').toDate() : null;
}
const udict = await user.getListForRender(domainId,
[this.tdoc.owner, ...tsdocs.map((i) => i.uid)], this.user.hasPerm(PERM.PERM_VIEW_DISPLAYNAME));
const udict = await user.getListForRender(
domainId, [this.tdoc.owner, ...tsdocs.map((i) => i.uid)],
this.user.hasPerm(PERM.PERM_VIEW_DISPLAYNAME) ? ['displayName'] : []
);
this.response.body = { tdoc: this.tdoc, tsdocs, udict };
this.response.pjax = 'partials/contest_user.html';
this.response.template = 'contest_user.html';
@@ -709,7 +714,7 @@ export class ContestBalloonHandler extends ContestManagementBaseHandler {
owner_udoc: await user.getById(domainId, this.tdoc.owner),
pdict: await problem.getList(domainId, this.tdoc.pids, true, true, problem.PROJECTION_CONTEST_LIST),
bdocs,
udict: await user.getListForRender(domainId, uids, this.user.hasPerm(PERM.PERM_VIEW_DISPLAYNAME)),
udict: await user.getListForRender(domainId, uids, this.user.hasPerm(PERM.PERM_VIEW_DISPLAYNAME) ? ['displayName'] : []),
};
this.response.pjax = 'partials/contest_balloon.html';
this.response.template = 'contest_balloon.html';
+1 -1
View File
@@ -960,7 +960,7 @@ export class ProblemStatisticsHandler extends ProblemDetailHandler {
'record',
);
const [udict, udoc] = await Promise.all([
user.getListForRender(domainId, rsdocs.map((i) => i.uid), this.user.hasPerm(PERM.PERM_VIEW_DISPLAYNAME)),
user.getListForRender(domainId, rsdocs.map((i) => i.uid), this.user.hasPerm(PERM.PERM_VIEW_DISPLAYNAME) ? ['displayName'] : []),
user.getById(domainId, this.pdoc.owner),
]);
this.response.template = 'problem_statistics.html';
+1 -1
View File
@@ -112,7 +112,7 @@ class TrainingDetailHandler extends Handler {
const canViewHidden = this.user.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN) || this.user._id;
const [udoc, udict, pdict, psdict, selfPsdict] = await Promise.all([
user.getById(domainId, tdoc.owner),
user.getListForRender(domainId, enrollUsers, this.user.hasPerm(PERM.PERM_VIEW_DISPLAYNAME)),
user.getListForRender(domainId, enrollUsers, this.user.hasPerm(PERM.PERM_VIEW_DISPLAYNAME) ? ['displayName'] : []),
problem.getList(domainId, pids, canViewHidden, true),
problem.getListStatus(domainId, uid, pids),
shouldCompare ? problem.getListStatus(domainId, this.user._id, pids) : {},