core: fix pretest display

This commit is contained in:
undefined committed 2021-09-24 17:56:26 +08:00
1 parent a2f1e886db
commit 71bb2f0b51
5 files changed
+14 -6

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "hydrooj", "name": "hydrooj",
"version": "2.39.2", "version": "2.39.3",
"bin": "bin/hydrooj.js", "bin": "bin/hydrooj.js",
"main": "src/loader", "main": "src/loader",
"module": "src/loader", "module": "src/loader",
+3 -1
View File
@@ -107,7 +107,9 @@ class RecordDetailHandler extends Handler {
this.response.template = 'record_detail.html'; 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);
if (rdoc.contest) { if (rdoc.contest.toHexString() === '000000000000000000000000') {
if (rdoc.uid !== this.user._id) throw new PermissionError(PERM.PERM_READ_RECORD_CODE);
} else if (rdoc.contest) {
const tdoc = await contest.get(domainId, rdoc.contest); const tdoc = await contest.get(domainId, rdoc.contest);
let canView = this.user.own(tdoc); let canView = this.user.own(tdoc);
canView ||= contest.canShowRecord.call(this, tdoc); canView ||= contest.canShowRecord.call(this, tdoc);
+6 -1
View File
@@ -535,7 +535,7 @@ const scripts: UpgradeScript[] = [
return true; return true;
}, },
null, null,
async function _46_47() { async function _47_48() {
const _FRESH_INSTALL_IGNORE = 1; const _FRESH_INSTALL_IGNORE = 1;
await document.coll.updateMany({ docType: document.TYPE_HOMEWORK }, { $set: { docType: document.TYPE_CONTEST } }); await document.coll.updateMany({ docType: document.TYPE_HOMEWORK }, { $set: { docType: document.TYPE_CONTEST } });
await document.collStatus.updateMany({ docType: document.TYPE_HOMEWORK }, { $set: { docType: document.TYPE_CONTEST } }); await document.collStatus.updateMany({ docType: document.TYPE_HOMEWORK }, { $set: { docType: document.TYPE_CONTEST } });
@@ -546,6 +546,11 @@ const scripts: UpgradeScript[] = [
await RecordModel.coll.updateMany({ contest: null }, { $unset: { contest: '' } }); await RecordModel.coll.updateMany({ contest: null }, { $unset: { contest: '' } });
return true; return true;
}, },
async function _48_49() {
const _FRESH_INSTALL_IGNORE = 1;
await RecordModel.coll.updateMany({ input: { $exists: true } }, { $set: { contest: new ObjectID('000000000000000000000000') } });
return true;
},
]; ];
export default scripts; export default scripts;
@@ -52,7 +52,7 @@ export default connect(mapStateToProps, null, mergeProps)(class ScratchpadRecord
handleRowClick(ev, id) { handleRowClick(ev, id) {
const url = substitute( const url = substitute(
decodeURIComponent(UiContext.getRecordDetailUrl), decodeURIComponent(UiContext.getRecordDetailUrl),
{ rid: id } { rid: id },
); );
emulateAnchorClick(ev, url, true); emulateAnchorClick(ev, url, true);
} }
@@ -60,7 +60,8 @@ export default connect(mapStateToProps, null, mergeProps)(class ScratchpadRecord
render() { render() {
const { data } = this.props; const { data } = this.props;
const submitAt = parseMongoId(data._id).timestamp * 1000; const submitAt = parseMongoId(data._id).timestamp * 1000;
return data.hidden ? null : ( // Is pretest
return data.contest?.toString() === '000000000000000000000000' ? null : (
<tr onClick={(ev) => this.handleRowClick(ev, data._id)}> <tr onClick={(ev) => this.handleRowClick(ev, data._id)}>
<td className={`col--detail record-status--border ${recordEnum.STATUS_CODES[data.status]}`}> <td className={`col--detail record-status--border ${recordEnum.STATUS_CODES[data.status]}`}>
<span className={`icon record-status--icon ${recordEnum.STATUS_CODES[data.status]}`}></span> <span className={`icon record-status--icon ${recordEnum.STATUS_CODES[data.status]}`}></span>
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@hydrooj/ui-default", "name": "@hydrooj/ui-default",
"version": "4.22.5", "version": "4.22.6",
"author": "undefined <i@undefined.moe>", "author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"main": "hydro.js", "main": "hydro.js",