|
|
|
@ -202,20 +202,19 @@ class TrainingEditHandler extends Handler {
|
|
|
|
|
@param('title', Types.Title)
|
|
|
|
|
@param('content', Types.Content)
|
|
|
|
|
@param('dag', Types.Content)
|
|
|
|
|
@param('pin', Types.Boolean)
|
|
|
|
|
@param('pin', Types.UnsignedInt)
|
|
|
|
|
@param('description', Types.Content)
|
|
|
|
|
async post(
|
|
|
|
|
domainId: string, tid: ObjectId,
|
|
|
|
|
title: string, content: string,
|
|
|
|
|
_dag: string, pin = false, description: string,
|
|
|
|
|
_dag: string, pin = 0, description: string,
|
|
|
|
|
) {
|
|
|
|
|
if ((!!this.tdoc?.pin) !== pin) this.checkPerm(PERM.PERM_PIN_TRAINING);
|
|
|
|
|
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);
|
|
|
|
|
if (pin) await training.edit(domainId, tid, { pin });
|
|
|
|
|
tid = await training.add(domainId, title, content, this.user._id, dag, description, pin);
|
|
|
|
|
} else {
|
|
|
|
|
await training.edit(domainId, tid, {
|
|
|
|
|
title, content, dag, description, pin,
|
|
|
|
|