core&ui: bug fix

This commit is contained in:
undefined committed 2021-05-30 18:42:49 +08:00
1 parent 8532cb5ec3
commit 3a518010be
13 files changed
+27 -30

No files matched your search

+1 -1
View File
@@ -220,7 +220,7 @@ export class ContestEditHandler extends Handler {
) {
const pids = _pids.replace(/,/g, ',').split(',').map((i) => {
if ((+i).toString() === i) return +i;
return i;
return i.trim();
}).filter((i) => i);
const beginAtMoment = moment.tz(`${beginAtDate} ${beginAtTime}`, this.user.timeZone);
if (!beginAtMoment.isValid()) throw new ValidationError('beginAtDate', 'beginAtTime');
+8 -6
View File
@@ -5,7 +5,7 @@ import AdmZip from 'adm-zip';
import { Time } from '@hydrooj/utils/lib/utils';
import {
ValidationError, HomeworkNotLiveError, ProblemNotFoundError,
HomeworkNotAttendedError, BadRequestError, ContestNotFoundError,
HomeworkNotAttendedError, BadRequestError,
} from '../error';
import {
PenaltyRules, Tdoc, ProblemDoc, User,
@@ -250,8 +250,7 @@ class HomeworkEditHandler extends Handler {
const tdoc = tid
? await contest.get(domainId, tid, document.TYPE_HOMEWORK)
: null;
if (tid && !tdoc) throw new ContestNotFoundError(domainId, tid);
else if (!tid) this.checkPerm(PERM.PERM_CREATE_HOMEWORK);
if (!tid) this.checkPerm(PERM.PERM_CREATE_HOMEWORK);
else if (!this.user.own(tdoc)) this.checkPerm(PERM.PERM_EDIT_HOMEWORK);
else this.checkPerm(PERM.PERM_EDIT_HOMEWORK_SELF);
const extensionDays = tid
@@ -308,10 +307,13 @@ class HomeworkEditHandler extends Handler {
) {
const pids = _pids.replace(/,/g, ',').split(',').map((i) => {
if ((+i).toString() === i) return +i;
return i;
return i.trim();
}).filter((i) => i);
const tdoc = await contest.get(domainId, tid, document.TYPE_HOMEWORK);
if (!this.user.own(tdoc)) this.checkPerm(PERM.PERM_EDIT_HOMEWORK);
const tdoc = tid
? await contest.get(domainId, tid, document.TYPE_HOMEWORK)
: null;
if (!tid) this.checkPerm(PERM.PERM_CREATE_HOMEWORK);
else if (!this.user.own(tdoc)) this.checkPerm(PERM.PERM_EDIT_HOMEWORK);
else this.checkPerm(PERM.PERM_EDIT_HOMEWORK_SELF);
const beginAt = moment.tz(`${beginAtDate} ${beginAtTime}`, this.user.timeZone);
if (!beginAt.isValid()) throw new ValidationError('beginAtDate', 'beginAtTime');