Skip to content

Commit

Permalink
Merge pull request #181 from hibiya-itchief/develop
Browse files Browse the repository at this point in the history
生徒も投票可能にする
  • Loading branch information
aozoraUS authored Sep 11, 2024
2 parents ab94fee + bc4f1d7 commit 09dcf41
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
21 changes: 16 additions & 5 deletions layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,22 @@
>{{ page.text }}</v-list-item-title
>
</v-list-item>
<!-- 9/12のテストに向けて生徒も投票可能に -->
<v-list-item
v-show="
$auth.user?.groups?.includes(user_groups.parents.id) ||
$auth.user?.groups?.includes(user_groups.guest.id) ||
$auth.user?.groups?.includes(user_groups.students.id)
"
to="/votes"
>
<v-list-item-icon>
<v-icon color="theme_color">mdi-vote</v-icon>
</v-list-item-icon>
<v-list-item-title style="font-family: serif; font-weight: bold">
投票
</v-list-item-title>
</v-list-item>
<v-list-item
v-show="$auth.user?.groups?.includes(user_groups.students.id)"
to="/tickets/intoScanner"
Expand Down Expand Up @@ -549,11 +565,6 @@ export default Vue.extend({
text: 'ヘルプ',
link: '/help',
},
{
icon: 'mdi-vote',
text: '投票',
link: '/votes',
},
],
}
},
Expand Down
33 changes: 33 additions & 0 deletions pages/votes/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ type Data = {
now_loading: boolean
votable: { [group_id: string]: boolean } // {"group_id":"votable"}の形で投票可能かを保存する
vote_count: number // ユーザーが投票した数 -> まだ投票できるかの判定に利用
user_groups: {
admin: string
parents: string
guest: string
students: string
}
}
export default Vue.extend({
Expand All @@ -112,10 +118,37 @@ export default Vue.extend({
now_loading: true,
votable: {},
vote_count: 0,
user_groups: {
admin: process.env.AZURE_AD_GROUPS_QUAINT_ADMIN as string,
parents: process.env.AZURE_AD_GROUPS_QUAINT_PARENTS as string,
guest: process.env.AZURE_AD_GROUPS_QUAINT_GUEST as string,
students: process.env.AZURE_AD_GROUPS_QUAINT_STUDENTS as string,
},
}
},
async created() {
// 権限確認
// 9/12日のテストのためstudentsも許可
if (
!(
(this.$auth.user?.groups as string[]).includes(
this.user_groups.admin
) ||
(this.$auth.user?.groups as string[]).includes(
this.user_groups.parents
) ||
(this.$auth.user?.groups as string[]).includes(
this.user_groups.guest
) ||
(this.$auth.user?.groups as string[]).includes(
this.user_groups.students
)
)
) {
this.$nuxt.error({ statusCode: 403, message: 'Forbidden' })
}
this.vote_count = await this.$axios.$get('/users/me/count/votes')
this.taken_tickets = await this.$axios.$get('/users/me/tickets') // ←used状態のものも使えるようにする
Expand Down

0 comments on commit 09dcf41

Please sign in to comment.