mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-19 17:38:19 +08:00
core: feat: problem_delete
This commit is contained in:
1 parent
93dddbd0d5
commit
403565d956
4 files changed
+11
-7
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "hydrooj",
|
||||
"version": "2.15.23",
|
||||
"version": "2.15.24",
|
||||
"bin": "bin/hydrooj.js",
|
||||
"main": "dist/loader.js",
|
||||
"typings": "dist/loader.d.ts",
|
||||
|
||||
@@ -165,7 +165,6 @@ export class ProblemRandomHandler extends ProblemHandler {
|
||||
|
||||
export class ProblemDetailHandler extends ProblemHandler {
|
||||
pdoc: Pdoc;
|
||||
|
||||
udoc: User;
|
||||
|
||||
@route('pid', Types.String, true, null, parsePid)
|
||||
@@ -213,6 +212,12 @@ export class ProblemDetailHandler extends ProblemHandler {
|
||||
});
|
||||
this.back();
|
||||
}
|
||||
|
||||
async postDelete() {
|
||||
if (this.pdoc.owner !== this.user._id) this.checkPerm(PERM.PERM_EDIT_PROBLEM);
|
||||
await problem.del(this.pdoc.domainId, this.pdoc.docId);
|
||||
this.response.redirect = this.url('problem_main');
|
||||
}
|
||||
}
|
||||
|
||||
export class ProblemExportHandler extends ProblemDetailHandler {
|
||||
@@ -464,7 +469,6 @@ export class ProblemFilesHandler extends ProblemDetailHandler {
|
||||
async postUploadFile(domainId: string, filename: string, type = 'testdata') {
|
||||
if (!this.request.files.file) throw new ValidationError('file');
|
||||
if (this.pdoc.owner !== this.user._id) this.checkPerm(PERM.PERM_EDIT_PROBLEM);
|
||||
else this.checkPerm(PERM.PERM_EDIT_PROBLEM_SELF);
|
||||
if (filename === 'testdata.zip') {
|
||||
const zip = new AdmZip(this.request.files.file.path);
|
||||
const entries = zip.getEntries();
|
||||
@@ -489,7 +493,6 @@ export class ProblemFilesHandler extends ProblemDetailHandler {
|
||||
@post('type', Types.Range(['testdata', 'additional_file']), true)
|
||||
async postDeleteFiles(domainId: string, files: string[], type = 'testdata') {
|
||||
if (this.pdoc.owner !== this.user._id) this.checkPerm(PERM.PERM_EDIT_PROBLEM);
|
||||
else this.checkPerm(PERM.PERM_EDIT_PROBLEM_SELF);
|
||||
if (type === 'testdata') {
|
||||
await problem.delTestdata(domainId, this.pdoc.docId, files);
|
||||
} else {
|
||||
|
||||
@@ -141,6 +141,7 @@ export function del(domainId: string, docId: number) {
|
||||
return Promise.all([
|
||||
document.deleteOne(domainId, document.TYPE_PROBLEM, docId),
|
||||
document.deleteMultiStatus(domainId, document.TYPE_PROBLEM, { docId }),
|
||||
storage.list(`problem/${domainId}/${docId}/`, true).then((items) => storage.del(items.map((item) => item.prefix + item.name))),
|
||||
bus.parallel('problem/delete', domainId, docId),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -660,10 +660,10 @@ export function Route(name: string, path: string, RouteHandler: any, ...permPriv
|
||||
|
||||
export class ConnectionHandler extends HandlerCommon {
|
||||
conn: sockjs.Connection;
|
||||
args: any;
|
||||
args: Record<string, any>;
|
||||
request: {
|
||||
params: any;
|
||||
headers: any;
|
||||
params: Record<string, any>;
|
||||
headers: Record<string, string>;
|
||||
ip: string;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user