mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: fix group filter
This commit is contained in:
2 files changed
+6
-4
No files matched your search
@@ -78,7 +78,7 @@ export class ContestListHandler extends Handler {
|
|||||||
async get(domainId: string, rule = '', group = '', page = 1) {
|
async get(domainId: string, rule = '', group = '', page = 1) {
|
||||||
if (rule && contest.RULES[rule].hidden) throw new BadRequestError();
|
if (rule && contest.RULES[rule].hidden) throw new BadRequestError();
|
||||||
const groups = (await user.listGroup(domainId, this.user.hasPerm(PERM.PERM_VIEW_HIDDEN_CONTEST) ? undefined : this.user._id))
|
const groups = (await user.listGroup(domainId, this.user.hasPerm(PERM.PERM_VIEW_HIDDEN_CONTEST) ? undefined : this.user._id))
|
||||||
.map((i) => i.name).filter((i) => !Number.isSafeInteger(+i));
|
.map((i) => i.name);
|
||||||
if (group && !groups.includes(group)) throw new NotAssignedError(group);
|
if (group && !groups.includes(group)) throw new NotAssignedError(group);
|
||||||
const rules = Object.keys(contest.RULES).filter((i) => !contest.RULES[i].hidden);
|
const rules = Object.keys(contest.RULES).filter((i) => !contest.RULES[i].hidden);
|
||||||
const q = {
|
const q = {
|
||||||
@@ -102,9 +102,10 @@ export class ContestListHandler extends Handler {
|
|||||||
const tids = [];
|
const tids = [];
|
||||||
for (const tdoc of tdocs) tids.push(tdoc.docId);
|
for (const tdoc of tdocs) tids.push(tdoc.docId);
|
||||||
const tsdict = await contest.getListStatus(domainId, this.user._id, tids);
|
const tsdict = await contest.getListStatus(domainId, this.user._id, tids);
|
||||||
|
const groupsFilter = groups.filter((i) => !Number.isSafeInteger(+i));
|
||||||
this.response.template = 'contest_main.html';
|
this.response.template = 'contest_main.html';
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
page, tpcount, qs, rule, tdocs, tsdict, groups, group,
|
page, tpcount, qs, rule, tdocs, tsdict, groups: groupsFilter, group,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class HomeworkMainHandler extends Handler {
|
|||||||
@param('page', Types.PositiveInt, true)
|
@param('page', Types.PositiveInt, true)
|
||||||
async get(domainId: string, group = '', page = 1) {
|
async get(domainId: string, group = '', page = 1) {
|
||||||
const groups = (await user.listGroup(domainId, this.user.hasPerm(PERM.PERM_VIEW_HIDDEN_CONTEST) ? undefined : this.user._id))
|
const groups = (await user.listGroup(domainId, this.user.hasPerm(PERM.PERM_VIEW_HIDDEN_CONTEST) ? undefined : this.user._id))
|
||||||
.map((i) => i.name).filter((i) => !Number.isSafeInteger(+i));
|
.map((i) => i.name);
|
||||||
if (group && !groups.includes(group)) throw new NotAssignedError(group);
|
if (group && !groups.includes(group)) throw new NotAssignedError(group);
|
||||||
const cursor = contest.getMulti(domainId, {
|
const cursor = contest.getMulti(domainId, {
|
||||||
rule: 'homework',
|
rule: 'homework',
|
||||||
@@ -54,8 +54,9 @@ class HomeworkMainHandler extends Handler {
|
|||||||
calendar.push(cal);
|
calendar.push(cal);
|
||||||
}
|
}
|
||||||
const qs = group ? `group=${group}` : '';
|
const qs = group ? `group=${group}` : '';
|
||||||
|
const groupsFilter = groups.filter((i) => !Number.isSafeInteger(+i));
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
tdocs, calendar, tpcount, page, qs, groups, group,
|
tdocs, calendar, tpcount, page, qs, groups: groupsFilter, group,
|
||||||
};
|
};
|
||||||
this.response.template = 'homework_main.html';
|
this.response.template = 'homework_main.html';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user