MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / post

Method post

packages/hydrooj/src/handler/training.ts:216–234  ·  view source on GitHub ↗
(
        domainId: string, tid: ObjectId,
        title: string, content: string,
        _dag: string, pin = 0, description: string,
    )

Source from the content-addressed store, hash-verified

214 @param('pin', Types.UnsignedInt)
215 @param('description', Types.Content)
216 async post(
217 domainId: string, tid: ObjectId,
218 title: string, content: string,
219 _dag: string, pin = 0, description: string,
220 ) {
221 if ((!!this.tdoc?.pin) !== (!!pin)) this.checkPerm(PERM.PERM_PIN_TRAINING);
222 const dag = await _parseDagJson(domainId, _dag);
223 const pids = training.getPids(dag);
224 assert(pids.length, new ValidationError('dag', null, 'Please specify at least one problem'));
225 if (!tid) {
226 tid = await training.add(domainId, title, content, this.user._id, dag, description, pin);
227 } else {
228 await training.edit(domainId, tid, {
229 title, content, dag, description, pin,
230 });
231 }
232 this.response.body = { tid };
233 this.response.redirect = this.url('training_detail', { tid });
234 }
235}
236
237export class TrainingFilesHandler extends Handler {

Callers

nothing calls this directly

Calls 5

_parseDagJsonFunction · 0.85
checkPermMethod · 0.80
urlMethod · 0.80
addMethod · 0.45
editMethod · 0.45

Tested by

no test coverage detected