core&ui: add training maintainer

This commit is contained in:
panda committed 2023-07-04 21:33:16 +00:00
1 parent bd95b9bd83
commit 79504ed900
5 files changed
+18 -8

No files matched your search

+5 -5
View File
@@ -206,20 +206,20 @@ class TrainingEditHandler extends Handler {
@param('dag', Types.Content)
@param('pin', Types.UnsignedInt)
@param('description', Types.Content)
@param('maintainer', Types.NumericArray, true)
async post(
domainId: string, tid: ObjectId,
title: string, content: string,
_dag: string, pin = 0, description: string,
domainId: string, tid: ObjectId, title: string, content: string,
_dag: string, pin = 0, description: string, maintainer: number[] = [],
) {
if ((!!this.tdoc?.pin) !== (!!pin)) this.checkPerm(PERM.PERM_PIN_TRAINING);
const dag = await _parseDagJson(domainId, _dag);
const pids = training.getPids(dag);
assert(pids.length, new ValidationError('dag', null, 'Please specify at least one problem'));
if (!tid) {
tid = await training.add(domainId, title, content, this.user._id, dag, description, pin);
tid = await training.add(domainId, title, content, this.user._id, dag, description, pin, maintainer);
} else {
await training.edit(domainId, tid, {
title, content, dag, description, pin,
title, content, dag, description, pin, maintainer,
});
}
this.response.body = { tid };
+3 -2
View File
@@ -35,8 +35,8 @@ export function setStatus(domainId: string, tid: ObjectId, uid: number, $set: an
}
export function add(
domainId: string, title: string, content: string,
owner: number, dag: TrainingNode[] = [], description = '', pin = 0,
domainId: string, title: string, content: string, owner: number,
dag: TrainingNode[] = [], description = '', pin = 0, maintainer: number[] = [],
) {
return document.add(domainId, content, owner, document.TYPE_TRAINING, null, null, null, {
dag,
@@ -44,6 +44,7 @@ export function add(
description,
attend: 0,
pin,
maintainer,
});
}