core&ui: training: pin level

This commit is contained in:
undefined committed 2023-04-14 12:20:13 +08:00
1 parent 234b3e970b
commit 672b0b32a6
5 files changed
+16 -13

No files matched your search

+4 -5
View File
@@ -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,