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
@@ -1,6 +1,6 @@
{
"name": "hydrooj",
"version": "2.28.10",
"version": "2.28.11",
"bin": "bin/hydrooj.js",
"main": "dist/loader.js",
"typings": "dist/loader.d.ts",
+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');
+4 -4
View File
@@ -147,9 +147,9 @@ export function off<K extends keyof EventMap>(name: K, listener: EventMap[K]) {
export async function parallel<K extends keyof EventMap>(name: K, ...args: Parameters<EventMap[K]>): Promise<void> {
const tasks: Promise<any>[] = [];
if (argv.options.showBus) logger.debug('parallel: %s %o', name, args);
if (argv.options.showBus && name !== 'message/log') logger.debug('parallel: %s %o', name, args);
for (const callback of _hooks[name] || []) {
if (argv.options.busDetail) logger.debug(callback.toString());
if (argv.options.busDetail && name !== 'message/log') logger.debug(callback.toString());
tasks.push(callback.apply(this, args));
}
await Promise.all(tasks);
@@ -160,7 +160,7 @@ export function emit<K extends keyof EventMap>(name: K, ...args: Parameters<Even
}
export async function serial<K extends keyof EventMap>(name: K, ...args: Parameters<EventMap[K]>): Promise<void> {
if (argv.options.showBus) logger.debug('serial: %s %o', name, args);
if (argv.options.showBus && name !== 'message/log') logger.debug('serial: %s %o', name, args);
const hooks = Array.from(_hooks[name] || []);
for (const callback of hooks) {
if (argv.options.busDetail) logger.debug(callback.toString());
@@ -169,7 +169,7 @@ export async function serial<K extends keyof EventMap>(name: K, ...args: Paramet
}
export function bail<K extends keyof EventMap>(name: K, ...args: Parameters<EventMap[K]>): ReturnType<EventMap[K]> {
if (argv.options.showBus) logger.debug('bail: %s %o', name, args);
if (argv.options.showBus && name !== 'message/log') logger.debug('bail: %s %o', name, args);
const hooks = Array.from(_hooks[name] || []);
for (const callback of hooks) {
const result = callback.apply(this, args);
+3 -4
View File
@@ -84,13 +84,12 @@ export async function updateJudge(args) {
if (cluster.isMaster) {
bus.on('app/started', async () => {
const info = await sysinfo.get();
await coll.updateOne(
sysinfo.get().then((info) => coll.updateOne(
{ mid: info.mid, type: 'server' },
{ $set: { ...info, updateAt: new Date(), type: 'server' } },
{ upsert: true },
);
await feedback();
));
feedback();
setInterval(update, 60 * 1000);
});
}
-1
View File
@@ -21,7 +21,6 @@ problem_create: Problem Create
problem_edit: Problem Edit
problem_import: Import Problem
problem_main: Problem Set
problem_settings: Problem Settings
problem_solution: Problem Solution
problem_statistics: Problem Statistics
problem_submit: Problem Submit
-1
View File
@@ -551,7 +551,6 @@ problem_create: 创建题目
problem_edit: 编辑题目
problem_import: 导入题目
problem_main: 题库
problem_settings: 题目设置
problem_solution: 题解
problem_statistics: 题目统计
problem_submit: 递交代码
-1
View File
@@ -341,7 +341,6 @@ Problem Tags Visibility: 題目標籤可見性
problem_create: 創建題目
problem_edit: 編輯題目
problem_main: 題庫
problem_settings: 題目設定
problem_solution: 題解
problem_submit: 遞交程式碼
Problem: 題目
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/ui-default",
"version": "4.11.4",
"version": "4.11.5",
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0",
"main": "hydro.js",
@@ -1,6 +1,5 @@
.page--problem_main
.page--problem_category
.page--problem_settings
.col--checkbox
width: rem(60px)
@@ -2,9 +2,9 @@
{%- if not invalid %}
<a
{%- if tdoc and tdoc.docType == model.document.TYPE_CONTEST %}
href="{{ url('contest_detail_problem', tid=tdoc.docId, pid=pdoc.pid) }}"
href="{{ url('contest_detail_problem', tid=tdoc.docId, pid=pdoc.pid|default(pdoc.docId)) }}"
{%- elif tdoc and tdoc.docType == model.document.TYPE_HOMEWORK %}
href="{{ url('homework_detail_problem', tid=tdoc.docId, pid=pdoc.pid) }}"
href="{{ url('homework_detail_problem', tid=tdoc.docId, pid=pdoc.pid|default(pdoc.docId)) }}"
{%- else %}
href="{{ url('problem_detail', pid=pdoc.pid|default(pdoc.docId)) }}"
{%- endif %}
@@ -24,17 +24,17 @@
<span class="icon icon-send"></span> {{ _('Submit') }}
</a></li>
{% elif model.contest.isDone(tdoc) %}
<li class="menu__item scratchpad--hide"><a class="menu__link" href="{{ url('problem_detail', pid=pdoc.pid|default(pdoc.docId)) }}">
<li class="menu__item scratchpad--hide"><a class="menu__link" href="{{ url('problem_detail', pid=pdoc.docId) }}">
<span class="icon icon-send"></span> {{ _('Open in Problem Set') }}
</a></li>
{% endif %}
{% if handler.user.own(pdoc, perm.PERM_EDIT_PROBLEM_SELF) or handler.user.hasPerm(perm.PERM_EDIT_PROBLEM) %}
<li class="menu__seperator"></li>
<li class="menu__item"><a class="menu__link{% if page_name == 'problem_edit' %} active{% endif %}" href="{{ url('problem_edit', pid=pdoc.pid|default(pdoc.docId)) }}">
<li class="menu__item"><a class="menu__link{% if page_name == 'problem_edit' %} active{% endif %}" href="{{ url('problem_edit', pid=pdoc.docId) }}">
<span class="icon icon-edit"></span> {{ _('Edit') }}
</a></li>
<li class="menu__item"><a class="menu__link{% if page_name == 'problem_settings' %} active{% endif %}" href="{{ url('problem_settings', pid=pdoc.pid|default(pdoc.docId)) }}">
<span class="icon icon-wrench"></span> {{ _('Settings') }}
<li class="menu__item"><a class="menu__link{% if page_name == 'problem_files' %} active{% endif %}" href="{{ url('problem_files', pid=pdoc.docId) }}">
<span class="icon icon-file"></span> {{ _('Files') }}
</a></li>
{% endif %}
</ol>
@@ -24,16 +24,16 @@
<span class="icon icon-send"></span> {{ _('Submit') }}
</a></li>
{% elif model.contest.isDone(tdoc) %}
<li class="menu__item scratchpad--hide"><a class="menu__link" href="{{ url('problem_detail', pid=pdoc.pid|default(pdoc.docId)) }}">
<li class="menu__item scratchpad--hide"><a class="menu__link" href="{{ url('problem_detail', pid=pdoc.docId) }}">
<span class="icon icon-send"></span> {{ _('Open in Problem Set') }}
</a></li>
{% endif %}
{% if handler.user.own(pdoc, perm.PERM_EDIT_PROBLEM_SELF) or handler.user.hasPerm(perm.PERM_EDIT_PROBLEM) %}
<li class="menu__seperator"></li>
<li class="menu__item"><a class="menu__link{% if page_name == 'problem_edit' %} active{% endif %}" href="{{ url('problem_edit', pid=pdoc.pid|default(pdoc.docId)) }}">
<li class="menu__item"><a class="menu__link{% if page_name == 'problem_edit' %} active{% endif %}" href="{{ url('problem_edit', pid=pdoc.docId) }}">
<span class="icon icon-edit"></span> {{ _('Edit') }}
</a></li>
<li class="menu__item"><a class="menu__link{% if page_name == 'problem_settings' %} active{% endif %}" href="{{ url('problem_settings', pid=pdoc.pid|default(pdoc.docId)) }}">
<li class="menu__item"><a class="menu__link{% if page_name == 'problem_files' %} active{% endif %}" href="{{ url('problem_files', pid=pdoc.docId) }}">
<span class="icon icon-wrench"></span> {{ _('Settings') }}
</a></li>
{% endif %}