mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core&ui: training: pin level
This commit is contained in:
5 files changed
+16
-13
No files matched your search
@@ -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,
|
||||
|
||||
Reference in new issue
Block a user