ui: fix assign text & core: allow owner get homework detail (#345)

This commit is contained in:
panda authored and GitHub committed 2022-04-25 17:17:04 +08:00
1 parent de9426a7fc
commit 59f1b4e429
7 files changed
+8 -4

No files matched your search

+1 -1
View File
@@ -83,7 +83,7 @@ export class ContestDetailHandler extends Handler {
@param('page', Types.PositiveInt, true) @param('page', Types.PositiveInt, true)
async prepare(domainId: string, tid: ObjectID) { async prepare(domainId: string, tid: ObjectID) {
const tdoc = await contest.get(domainId, tid); const tdoc = await contest.get(domainId, tid);
if (tdoc.assign?.length) { if (tdoc.assign?.length && !this.user.own(tdoc)) {
const groups = await user.listGroup(domainId, this.user._id); const groups = await user.listGroup(domainId, this.user._id);
if (!Set.intersection(tdoc.assign, groups.map((i) => i.name)).size) { if (!Set.intersection(tdoc.assign, groups.map((i) => i.name)).size) {
throw new ForbiddenError('You are not assigned.'); throw new ForbiddenError('You are not assigned.');
+1 -1
View File
@@ -61,7 +61,7 @@ class DiscussionHandler extends Handler {
// TODO(twd2): exclude problem/contest discussions? // TODO(twd2): exclude problem/contest discussions?
// TODO(iceboy): continuation based pagination. // TODO(iceboy): continuation based pagination.
this.vnode = await discussion.getVnode(domainId, typeMapper[type], name, this.user._id); this.vnode = await discussion.getVnode(domainId, typeMapper[type], name, this.user._id);
if (this.vnode.assign?.length) { if (this.vnode.assign?.length && !this.user.own(this.vnode)) {
if (!Set.intersection(this.vnode.assign, this.user.group).size) { if (!Set.intersection(this.vnode.assign, this.user.group).size) {
throw new PermissionError(PERM.PERM_VIEW_PROBLEM_HIDDEN); throw new PermissionError(PERM.PERM_VIEW_PROBLEM_HIDDEN);
} }
+1 -1
View File
@@ -45,7 +45,7 @@ class HomeworkDetailHandler extends Handler {
async prepare(domainId: string, tid: ObjectID) { async prepare(domainId: string, tid: ObjectID) {
const tdoc = await contest.get(domainId, tid); const tdoc = await contest.get(domainId, tid);
if (tdoc.rule !== 'homework') throw new ContestNotFoundError(domainId, tid); if (tdoc.rule !== 'homework') throw new ContestNotFoundError(domainId, tid);
if (tdoc.assign?.length) { if (tdoc.assign?.length && !this.user.own(tdoc)) {
if (!Set.intersection(tdoc.assign, this.user.group).size) { if (!Set.intersection(tdoc.assign, this.user.group).size) {
throw new ForbiddenError('You are not assigned.'); throw new ForbiddenError('You are not assigned.');
} }
+2
View File
@@ -79,6 +79,7 @@ Any user is allowed to join this domain: 任意用户都可以加入此域
API: API API: API
Argument {0} is invalid.: 非法的参数 {0} 。 Argument {0} is invalid.: 非法的参数 {0} 。
Arguments: 参数 Arguments: 参数
Assign: 分配给
At least 4 characters: 至少 4 个字符 At least 4 characters: 至少 4 个字符
Attend Contest: 参加比赛 Attend Contest: 参加比赛
Attend contests: 参加比赛 Attend contests: 参加比赛
@@ -336,6 +337,7 @@ fs_upload: 上传文件
Gender Visibility: 性别可见性 Gender Visibility: 性别可见性
Gender: 性别 Gender: 性别
Gravatar URL Prefix: Gravatar地址前缀 Gravatar URL Prefix: Gravatar地址前缀
Group / UID: 小组或 UID
Group Name: 名称 Group Name: 名称
Hard Deadline: 最终截止时间 Hard Deadline: 最终截止时间
Hash: 散列 Hash: 散列
@@ -70,6 +70,7 @@
columns:4, columns:4,
label:'Assign', label:'Assign',
name:'assign', name:'assign',
placeholder:_('Group / UID'),
value:tdoc.assign|default(''), value:tdoc.assign|default(''),
row:false row:false
}) }} }) }}
@@ -66,6 +66,7 @@
columns:4, columns:4,
label:'Assign', label:'Assign',
name:'assign', name:'assign',
placeholder:_('Group / UID'),
value:tdoc.assign|default('') value:tdoc.assign|default('')
}) }} }) }}
</div> </div>
@@ -43,7 +43,7 @@
row:false, row:false,
columns:3, columns:3,
label:'Assign', label:'Assign',
help_text:'Assigned groups', placeholder:_('Group / UID'),
name:'assign', name:'assign',
value:pdoc.assign|default([])|join(', ') value:pdoc.assign|default([])|join(', ')
}) }} }) }}