mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
core&ui: bug fix
This commit is contained in:
1 parent
8532cb5ec3
commit
3a518010be
13 files changed
+27
-30
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "hydrooj",
|
"name": "hydrooj",
|
||||||
"version": "2.28.10",
|
"version": "2.28.11",
|
||||||
"bin": "bin/hydrooj.js",
|
"bin": "bin/hydrooj.js",
|
||||||
"main": "dist/loader.js",
|
"main": "dist/loader.js",
|
||||||
"typings": "dist/loader.d.ts",
|
"typings": "dist/loader.d.ts",
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ export class ContestEditHandler extends Handler {
|
|||||||
) {
|
) {
|
||||||
const pids = _pids.replace(/,/g, ',').split(',').map((i) => {
|
const pids = _pids.replace(/,/g, ',').split(',').map((i) => {
|
||||||
if ((+i).toString() === i) return +i;
|
if ((+i).toString() === i) return +i;
|
||||||
return i;
|
return i.trim();
|
||||||
}).filter((i) => i);
|
}).filter((i) => i);
|
||||||
const beginAtMoment = moment.tz(`${beginAtDate} ${beginAtTime}`, this.user.timeZone);
|
const beginAtMoment = moment.tz(`${beginAtDate} ${beginAtTime}`, this.user.timeZone);
|
||||||
if (!beginAtMoment.isValid()) throw new ValidationError('beginAtDate', 'beginAtTime');
|
if (!beginAtMoment.isValid()) throw new ValidationError('beginAtDate', 'beginAtTime');
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import AdmZip from 'adm-zip';
|
|||||||
import { Time } from '@hydrooj/utils/lib/utils';
|
import { Time } from '@hydrooj/utils/lib/utils';
|
||||||
import {
|
import {
|
||||||
ValidationError, HomeworkNotLiveError, ProblemNotFoundError,
|
ValidationError, HomeworkNotLiveError, ProblemNotFoundError,
|
||||||
HomeworkNotAttendedError, BadRequestError, ContestNotFoundError,
|
HomeworkNotAttendedError, BadRequestError,
|
||||||
} from '../error';
|
} from '../error';
|
||||||
import {
|
import {
|
||||||
PenaltyRules, Tdoc, ProblemDoc, User,
|
PenaltyRules, Tdoc, ProblemDoc, User,
|
||||||
@@ -250,8 +250,7 @@ class HomeworkEditHandler extends Handler {
|
|||||||
const tdoc = tid
|
const tdoc = tid
|
||||||
? await contest.get(domainId, tid, document.TYPE_HOMEWORK)
|
? await contest.get(domainId, tid, document.TYPE_HOMEWORK)
|
||||||
: null;
|
: null;
|
||||||
if (tid && !tdoc) throw new ContestNotFoundError(domainId, tid);
|
if (!tid) this.checkPerm(PERM.PERM_CREATE_HOMEWORK);
|
||||||
else if (!tid) this.checkPerm(PERM.PERM_CREATE_HOMEWORK);
|
|
||||||
else if (!this.user.own(tdoc)) this.checkPerm(PERM.PERM_EDIT_HOMEWORK);
|
else if (!this.user.own(tdoc)) this.checkPerm(PERM.PERM_EDIT_HOMEWORK);
|
||||||
else this.checkPerm(PERM.PERM_EDIT_HOMEWORK_SELF);
|
else this.checkPerm(PERM.PERM_EDIT_HOMEWORK_SELF);
|
||||||
const extensionDays = tid
|
const extensionDays = tid
|
||||||
@@ -308,10 +307,13 @@ class HomeworkEditHandler extends Handler {
|
|||||||
) {
|
) {
|
||||||
const pids = _pids.replace(/,/g, ',').split(',').map((i) => {
|
const pids = _pids.replace(/,/g, ',').split(',').map((i) => {
|
||||||
if ((+i).toString() === i) return +i;
|
if ((+i).toString() === i) return +i;
|
||||||
return i;
|
return i.trim();
|
||||||
}).filter((i) => i);
|
}).filter((i) => i);
|
||||||
const tdoc = await contest.get(domainId, tid, document.TYPE_HOMEWORK);
|
const tdoc = tid
|
||||||
if (!this.user.own(tdoc)) this.checkPerm(PERM.PERM_EDIT_HOMEWORK);
|
? 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);
|
else this.checkPerm(PERM.PERM_EDIT_HOMEWORK_SELF);
|
||||||
const beginAt = moment.tz(`${beginAtDate} ${beginAtTime}`, this.user.timeZone);
|
const beginAt = moment.tz(`${beginAtDate} ${beginAtTime}`, this.user.timeZone);
|
||||||
if (!beginAt.isValid()) throw new ValidationError('beginAtDate', 'beginAtTime');
|
if (!beginAt.isValid()) throw new ValidationError('beginAtDate', 'beginAtTime');
|
||||||
|
|||||||
@@ -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> {
|
export async function parallel<K extends keyof EventMap>(name: K, ...args: Parameters<EventMap[K]>): Promise<void> {
|
||||||
const tasks: Promise<any>[] = [];
|
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] || []) {
|
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));
|
tasks.push(callback.apply(this, args));
|
||||||
}
|
}
|
||||||
await Promise.all(tasks);
|
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> {
|
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] || []);
|
const hooks = Array.from(_hooks[name] || []);
|
||||||
for (const callback of hooks) {
|
for (const callback of hooks) {
|
||||||
if (argv.options.busDetail) logger.debug(callback.toString());
|
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]> {
|
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] || []);
|
const hooks = Array.from(_hooks[name] || []);
|
||||||
for (const callback of hooks) {
|
for (const callback of hooks) {
|
||||||
const result = callback.apply(this, args);
|
const result = callback.apply(this, args);
|
||||||
|
|||||||
@@ -84,13 +84,12 @@ export async function updateJudge(args) {
|
|||||||
|
|
||||||
if (cluster.isMaster) {
|
if (cluster.isMaster) {
|
||||||
bus.on('app/started', async () => {
|
bus.on('app/started', async () => {
|
||||||
const info = await sysinfo.get();
|
sysinfo.get().then((info) => coll.updateOne(
|
||||||
await coll.updateOne(
|
|
||||||
{ mid: info.mid, type: 'server' },
|
{ mid: info.mid, type: 'server' },
|
||||||
{ $set: { ...info, updateAt: new Date(), type: 'server' } },
|
{ $set: { ...info, updateAt: new Date(), type: 'server' } },
|
||||||
{ upsert: true },
|
{ upsert: true },
|
||||||
);
|
));
|
||||||
await feedback();
|
feedback();
|
||||||
setInterval(update, 60 * 1000);
|
setInterval(update, 60 * 1000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ problem_create: Problem Create
|
|||||||
problem_edit: Problem Edit
|
problem_edit: Problem Edit
|
||||||
problem_import: Import Problem
|
problem_import: Import Problem
|
||||||
problem_main: Problem Set
|
problem_main: Problem Set
|
||||||
problem_settings: Problem Settings
|
|
||||||
problem_solution: Problem Solution
|
problem_solution: Problem Solution
|
||||||
problem_statistics: Problem Statistics
|
problem_statistics: Problem Statistics
|
||||||
problem_submit: Problem Submit
|
problem_submit: Problem Submit
|
||||||
|
|||||||
@@ -551,7 +551,6 @@ problem_create: 创建题目
|
|||||||
problem_edit: 编辑题目
|
problem_edit: 编辑题目
|
||||||
problem_import: 导入题目
|
problem_import: 导入题目
|
||||||
problem_main: 题库
|
problem_main: 题库
|
||||||
problem_settings: 题目设置
|
|
||||||
problem_solution: 题解
|
problem_solution: 题解
|
||||||
problem_statistics: 题目统计
|
problem_statistics: 题目统计
|
||||||
problem_submit: 递交代码
|
problem_submit: 递交代码
|
||||||
|
|||||||
@@ -341,7 +341,6 @@ Problem Tags Visibility: 題目標籤可見性
|
|||||||
problem_create: 創建題目
|
problem_create: 創建題目
|
||||||
problem_edit: 編輯題目
|
problem_edit: 編輯題目
|
||||||
problem_main: 題庫
|
problem_main: 題庫
|
||||||
problem_settings: 題目設定
|
|
||||||
problem_solution: 題解
|
problem_solution: 題解
|
||||||
problem_submit: 遞交程式碼
|
problem_submit: 遞交程式碼
|
||||||
Problem: 題目
|
Problem: 題目
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@hydrooj/ui-default",
|
"name": "@hydrooj/ui-default",
|
||||||
"version": "4.11.4",
|
"version": "4.11.5",
|
||||||
"author": "undefined <i@undefined.moe>",
|
"author": "undefined <i@undefined.moe>",
|
||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"main": "hydro.js",
|
"main": "hydro.js",
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
.page--problem_main
|
.page--problem_main
|
||||||
.page--problem_category
|
.page--problem_category
|
||||||
.page--problem_settings
|
|
||||||
.col--checkbox
|
.col--checkbox
|
||||||
width: rem(60px)
|
width: rem(60px)
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,9 @@
|
|||||||
{%- if not invalid %}
|
{%- if not invalid %}
|
||||||
<a
|
<a
|
||||||
{%- if tdoc and tdoc.docType == model.document.TYPE_CONTEST %}
|
{%- 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 %}
|
{%- 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 %}
|
{%- else %}
|
||||||
href="{{ url('problem_detail', pid=pdoc.pid|default(pdoc.docId)) }}"
|
href="{{ url('problem_detail', pid=pdoc.pid|default(pdoc.docId)) }}"
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|||||||
@@ -24,17 +24,17 @@
|
|||||||
<span class="icon icon-send"></span> {{ _('Submit') }}
|
<span class="icon icon-send"></span> {{ _('Submit') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% elif model.contest.isDone(tdoc) %}
|
{% 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') }}
|
<span class="icon icon-send"></span> {{ _('Open in Problem Set') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if handler.user.own(pdoc, perm.PERM_EDIT_PROBLEM_SELF) or handler.user.hasPerm(perm.PERM_EDIT_PROBLEM) %}
|
{% 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__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') }}
|
<span class="icon icon-edit"></span> {{ _('Edit') }}
|
||||||
</a></li>
|
</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') }}
|
<span class="icon icon-file"></span> {{ _('Files') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ol>
|
</ol>
|
||||||
|
|||||||
@@ -24,16 +24,16 @@
|
|||||||
<span class="icon icon-send"></span> {{ _('Submit') }}
|
<span class="icon icon-send"></span> {{ _('Submit') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% elif model.contest.isDone(tdoc) %}
|
{% 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') }}
|
<span class="icon icon-send"></span> {{ _('Open in Problem Set') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if handler.user.own(pdoc, perm.PERM_EDIT_PROBLEM_SELF) or handler.user.hasPerm(perm.PERM_EDIT_PROBLEM) %}
|
{% 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__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') }}
|
<span class="icon icon-edit"></span> {{ _('Edit') }}
|
||||||
</a></li>
|
</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') }}
|
<span class="icon icon-wrench"></span> {{ _('Settings') }}
|
||||||
</a></li>
|
</a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
Reference in new issue
Block a user