Skip to content

Commit

Permalink
feat: allow ban participant (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
thezzisu authored Aug 17, 2024
1 parent e572593 commit 70cf00b
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .yarn/versions/f94bc75b.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
releases:
"@aoi-js/frontend": patch
"@aoi-js/server": patch
13 changes: 11 additions & 2 deletions apps/frontend/src/components/contest/RanklistRenderer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ import { ref, computed } from 'vue'
import { useI18n } from 'vue-i18n'
import { RouterLink } from 'vue-router'
import RanklistTopstars from '../contest/RanklistTopstars.vue'
import { useRanklistRenderer } from './RanklistRenderer'
import RanklistTopstars from './RanklistTopstars.vue'
import PrincipalProfile from '@/components/utils/PrincipalProfile.vue'
import { renderMarkdown } from '@/utils/markdown'
Expand All @@ -85,3 +84,13 @@ const length = computed(() =>
const { admin, participantUrl, problemUrl, solutionUrl } = useRanklistRenderer()
</script>

<style scoped>
td:not(:last-child) {
border-right: 1px solid #eee;
}
th {
border-bottom: 2px solid #eee;
}
</style>
1 change: 1 addition & 0 deletions apps/frontend/src/locales/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ term:
access-level: Access Level
rules: Rules
ip: IP
banned: Banned

common:
created-at: Created at
Expand Down
1 change: 1 addition & 0 deletions apps/frontend/src/locales/zh-Hans.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ term:
access-level: 访问等级
rules: 规则
ip: IP 地址
banned: 封禁

common:
created-at: 创建于
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<SettingsEditor :endpoint="`contest/${contestId}/participant/admin/${userId}`">
<template v-slot="scoped">
<VCombobox v-model="scoped.value.tags" :label="t('term.tags')" multiple chips />
<VCheckbox v-model="scoped.value.banned" :label="t('term.banned')" />
</template>
</SettingsEditor>
<VDivider />
Expand All @@ -26,7 +27,7 @@ import { useI18n } from 'vue-i18n'
import type { IContestDTO } from '@/components/contest/types'
import PrincipalProfile from '@/components/utils/PrincipalProfile.vue'
import SettingsEditor from '@/components/utils/SettingsEditor.vue'
import { useContestCapability, useContestSettings } from '@/utils/contest/inject'
import { useContestCapability } from '@/utils/contest/inject'
defineProps<{
orgId: string
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/db/contest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export interface IContestParticipant {
createdAt: number
updatedAt: number
tags?: string[]
banned?: boolean
}

export interface IContestProblem {
Expand Down
8 changes: 2 additions & 6 deletions apps/server/src/routes/contest/participant/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ const contestParticipantAdminRoutes = defineRoutes(async (s) => {
userId: T.UUID()
}),
body: T.Object({
tags: T.Optional(T.Array(T.String()))
tags: T.Optional(T.Array(T.String())),
banned: T.Optional(T.Boolean())
})
}
},
Expand All @@ -139,9 +140,4 @@ const contestParticipantAdminRoutes = defineRoutes(async (s) => {
return 0
}
)

s.delete('/:userId', {}, async () => {
// TODO: delete participant
return s.httpErrors.notImplemented()
})
})
2 changes: 2 additions & 0 deletions apps/server/src/routes/contest/scoped.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ export const contestScopedRoutes = defineRoutes(async (s) => {
})
if (!participant) {
ensureCapability(capability, CONTEST_CAPS.CAP_ACCESS, s.httpErrors.forbidden())
} else if (participant.banned) {
ensureCapability(capability, CONTEST_CAPS.CAP_ADMIN, s.httpErrors.forbidden())
}
req.provide(kContestContext, {
_contestId: contestId,
Expand Down

0 comments on commit 70cf00b

Please sign in to comment.