mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 09:38:19 +08:00
core&ui: pagination for homework
This commit is contained in:
1 parent
7c0301c3e0
commit
5baf8f3207
6 files changed
+28
-24
No files matched your search
@@ -6,7 +6,7 @@ import {
|
||||
ContestNotFoundError, ForbiddenError, HomeworkNotLiveError,
|
||||
ValidationError,
|
||||
} from '../error';
|
||||
import { PenaltyRules } from '../interface';
|
||||
import { PenaltyRules, Tdoc } from '../interface';
|
||||
import paginate from '../lib/paginate';
|
||||
import { PERM } from '../model/builtin';
|
||||
import * as contest from '../model/contest';
|
||||
@@ -22,8 +22,9 @@ const validatePenaltyRules = (input: string) => yaml.load(input);
|
||||
const convertPenaltyRules = validatePenaltyRules;
|
||||
|
||||
class HomeworkMainHandler extends Handler {
|
||||
async get({ domainId }) {
|
||||
const tdocs = await contest.getMulti(domainId, { rule: 'homework' }).toArray();
|
||||
async get({ domainId, page = 1 }) {
|
||||
const cursor = contest.getMulti(domainId, { rule: 'homework' });
|
||||
const [tdocs, tpcount] = await paginate<Tdoc>(cursor, page, system.get('pagination.contest'));
|
||||
const calendar = [];
|
||||
for (const tdoc of tdocs) {
|
||||
const cal = { ...tdoc, url: this.url('homework_detail', { tid: tdoc.docId }) };
|
||||
@@ -33,7 +34,9 @@ class HomeworkMainHandler extends Handler {
|
||||
} else cal.endAt = tdoc.penaltySince;
|
||||
calendar.push(cal);
|
||||
}
|
||||
this.response.body = { tdocs, calendar };
|
||||
this.response.body = {
|
||||
tdocs, calendar, tpcount, page,
|
||||
};
|
||||
this.response.template = 'homework_main.html';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user