mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: fix record_download
This commit is contained in:
1 parent
ef59d79b1a
commit
5c1217dc60
2 files changed
+3
-2
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "3.11.5",
|
"version": "3.11.6",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "src/loader",
|
"main": "src/loader",
|
||||||
"module": "src/loader",
|
"module": "src/loader",
|
||||||
|
|||||||
@@ -105,7 +105,6 @@ class RecordDetailHandler extends Handler {
|
|||||||
@param('rid', Types.ObjectID)
|
@param('rid', Types.ObjectID)
|
||||||
@param('download', Types.Boolean)
|
@param('download', Types.Boolean)
|
||||||
async get(domainId: string, rid: ObjectID, download = false) {
|
async get(domainId: string, rid: ObjectID, download = false) {
|
||||||
this.response.template = 'record_detail.html';
|
|
||||||
const rdoc = await record.get(domainId, rid);
|
const rdoc = await record.get(domainId, rid);
|
||||||
if (!rdoc) throw new RecordNotFoundError(rid);
|
if (!rdoc) throw new RecordNotFoundError(rid);
|
||||||
let tdoc;
|
let tdoc;
|
||||||
@@ -143,6 +142,7 @@ class RecordDetailHandler extends Handler {
|
|||||||
if (download) {
|
if (download) {
|
||||||
const lang = langs[rdoc.lang]?.pretest || rdoc.lang;
|
const lang = langs[rdoc.lang]?.pretest || rdoc.lang;
|
||||||
this.response.body = rdoc.code;
|
this.response.body = rdoc.code;
|
||||||
|
this.response.type = 'text/plain';
|
||||||
this.response.disposition = `attachment; filename="${langs[lang].code_file || `foo.${rdoc.lang}`}"`;
|
this.response.disposition = `attachment; filename="${langs[lang].code_file || `foo.${rdoc.lang}`}"`;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -150,6 +150,7 @@ class RecordDetailHandler extends Handler {
|
|||||||
if (!problem.canViewBy(pdoc, this.user)) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_HIDDEN);
|
if (!problem.canViewBy(pdoc, this.user)) throw new PermissionError(PERM.PERM_VIEW_PROBLEM_HIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.response.template = 'record_detail.html';
|
||||||
this.response.body = {
|
this.response.body = {
|
||||||
udoc, rdoc, pdoc, tdoc,
|
udoc, rdoc, pdoc, tdoc,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in new issue
Block a user