ui: allow deleting contest/homework via edit page

This commit is contained in:
masnn committed 2021-04-13 16:08:08 +00:00
1 parent 1bb340f27a
commit 8a8e312ca4
5 files changed
+53 -1

No files matched your search

+8
View File
@@ -96,6 +96,14 @@ class ContestDetailHandler extends ContestHandler {
await contest.attend(domainId, tid, this.user._id);
this.back();
}
@param('tid', Types.ObjectID)
async postDelete(domainId: string, tid: ObjectID) {
const tdoc = await contest.get(domainId, tid);
if (tdoc.owner !== this.user._id) this.checkPerm(PERM.PERM_EDIT_CONTEST);
await contest.del(domainId, tid);
this.response.redirect = this.url('contest_main');
}
}
class ContestBoardcastHandler extends ContestHandler {
+8
View File
@@ -108,6 +108,14 @@ class HomeworkDetailHandler extends HomeworkHandler {
await contest.attend(domainId, tdoc.docId, this.user._id, document.TYPE_HOMEWORK);
this.back();
}
@param('tid', Types.ObjectID)
async postDelete(domainId: string, tid: ObjectID) {
const tdoc = await contest.get(domainId, tid, document.TYPE_HOMEWORK);
if (tdoc.owner !== this.user._id) this.checkPerm(PERM.PERM_EDIT_HOMEWORK);
await contest.del(domainId, tid, document.TYPE_HOMEWORK);
this.response.redirect = this.url('homework_main');
}
}
class HomeworkDetailProblemHandler extends HomeworkHandler {