From c116d6a21277907236fe7b58c33389c86f7c362b Mon Sep 17 00:00:00 2001 From: undefined Date: Fri, 29 Oct 2021 20:33:07 +0800 Subject: [PATCH] core: fix share --- packages/hydrooj/package.json | 2 +- packages/hydrooj/src/handler/problem.ts | 4 +++ packages/ui-default/package.json | 2 +- .../templates/partials/problem_list.html | 30 ++++++++----------- 4 files changed, 18 insertions(+), 20 deletions(-) diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index d144bf166..5b59845c6 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "3.1.17", + "version": "3.1.18", "bin": "bin/hydrooj.js", "main": "src/loader", "module": "src/loader", diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index f4dae24a6..f468818d8 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -187,6 +187,8 @@ export class ProblemMainHandler extends ProblemHandler { @param('pids', Types.NumericArray) @param('target', Types.String) async postCopy(domainId: string, pids: number[], target: string) { + const t = `,${this.domain.share || ''},`; + if (t !== ',*,' && !t.includes(`,${target},`)) throw new PermissionError(target); const ddoc = await domain.get(target); if (!ddoc) throw new NotFoundError(target); const dudoc = await user.getById(target, this.user._id); @@ -346,6 +348,8 @@ export class ProblemDetailHandler extends ProblemHandler { @param('target', Types.String) async postCopy(domainId: string, target: string) { + const t = `,${this.domain.share || ''},`; + if (t !== ',*,' && !t.includes(`,${target},`)) throw new PermissionError(target); const ddoc = await domain.get(target); if (!ddoc) throw new NotFoundError(target); const dudoc = await user.getById(target, this.user._id); diff --git a/packages/ui-default/package.json b/packages/ui-default/package.json index 4502d0244..c930f2baf 100644 --- a/packages/ui-default/package.json +++ b/packages/ui-default/package.json @@ -1,6 +1,6 @@ { "name": "@hydrooj/ui-default", - "version": "4.26.9", + "version": "4.26.10", "author": "undefined ", "license": "AGPL-3.0", "main": "hydro.js", diff --git a/packages/ui-default/templates/partials/problem_list.html b/packages/ui-default/templates/partials/problem_list.html index 79aa7ed3c..3e32f265c 100644 --- a/packages/ui-default/templates/partials/problem_list.html +++ b/packages/ui-default/templates/partials/problem_list.html @@ -8,10 +8,8 @@ {% else %} - {% if handler.user.hasPerm(perm.PERM_EDIT_PROBLEM) %} - {% endif %} {% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %} {% endif %} @@ -22,14 +20,12 @@ - {% if handler.user.hasPerm(perm.PERM_EDIT_PROBLEM) %} - - - {% endif %} + + {% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %} {% endif %} @@ -43,14 +39,12 @@ {%- for pdoc in pdocs -%} {% set psdoc = psdict[pdoc['docId']] %} - {% if handler.user.hasPerm(perm.PERM_EDIT_PROBLEM) %} - - - {% endif %} + + {% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %} {% if psdoc['rid'] %} {{ record.render_status_td(psdoc, rid_key='rid', class="edit-mode-hide") }}
- - {{ _('ID') }} + + {{ _('ID') }}{{ _('Status') }}
- - {{ pdoc.docId }} + + {{ pdoc.docId }}