From bdf8c899e59663ca6ddafb40a884b04e69b35bbd Mon Sep 17 00:00:00 2001 From: Sherine7734 Date: Mon, 13 Oct 2025 17:06:20 +0000 Subject: [PATCH 1/3] Added a checkbox based form to submit consent to being shown in the Kioleskap Leaderboard. --- ..env.swp | Bin 0 -> 1024 bytes .../settings/kioleskapLeaderboard.tsx | 21 +++++++++++++++ .../[username]/(user-admin)/settings/page.tsx | 3 +++ src/prisma/schema/ombul.prisma | 24 +++++++++++++----- src/prisma/schema/permission.prisma | 3 +++ src/prisma/schema/user.prisma | 3 +++ src/services/users/actions.ts | 1 + src/services/users/operations.ts | 1 + src/services/users/schemas.ts | 7 ++++- 9 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 ..env.swp create mode 100644 src/app/users/[username]/(user-admin)/settings/kioleskapLeaderboard.tsx diff --git a/..env.swp b/..env.swp new file mode 100644 index 0000000000000000000000000000000000000000..f6b0251678dc70a9ae12cbdfa3d6fddacef1eea4 GIT binary patch literal 1024 zcmYc?$V<%2S1{8vVn6{I{0t05`S~R%f;c!njsYS50lLlxLGCUV#=$sLF)-+*=9S@; S9F-Uifzc44bqIu_TL1vI3kwGT literal 0 HcmV?d00001 diff --git a/src/app/users/[username]/(user-admin)/settings/kioleskapLeaderboard.tsx b/src/app/users/[username]/(user-admin)/settings/kioleskapLeaderboard.tsx new file mode 100644 index 000000000..af34329e8 --- /dev/null +++ b/src/app/users/[username]/(user-admin)/settings/kioleskapLeaderboard.tsx @@ -0,0 +1,21 @@ +'use client' +import { updateUserAction } from '@/services/users/actions' +import Form from '@/app/_components/Form/Form' +import Checkbox from '@/app/_components/UI/Checkbox' +import { configureAction } from '@/services/configureAction' + + +export default function RegisterKioleskapLeaderboard({ + userId, + kioleskapLead, +}: { + userId: number, + kioleskapLead: boolean, +}) { + return
+ Jeg vil vises på Kioleskapets leaderboard +
+} diff --git a/src/app/users/[username]/(user-admin)/settings/page.tsx b/src/app/users/[username]/(user-admin)/settings/page.tsx index ffefa3d44..89fb3a090 100644 --- a/src/app/users/[username]/(user-admin)/settings/page.tsx +++ b/src/app/users/[username]/(user-admin)/settings/page.tsx @@ -1,8 +1,10 @@ import RegisterStudentCardButton from './RegisterStudentCardButton' +import RegisterKioleskapLeaderboard from './kioleskapLeaderboard' import { getProfileForAdmin } from '@/app/users/[username]/(user-admin)/getProfileForAdmin' import Image from '@/components/Image/Image' import type { PropTypes } from '@/app/users/[username]/page' + export default async function UserSettings({ params }: PropTypes) { const { profile } = await getProfileForAdmin(await params, 'settings') @@ -11,6 +13,7 @@ export default async function UserSettings({ params }: PropTypes) {

Generelle Instillinger

+ ) } diff --git a/src/prisma/schema/ombul.prisma b/src/prisma/schema/ombul.prisma index d55b56a7a..7f77552b0 100644 --- a/src/prisma/schema/ombul.prisma +++ b/src/prisma/schema/ombul.prisma @@ -1,15 +1,27 @@ model Ombul { - id Int @id @default(autoincrement()) + id Int @id @default(autoincrement()) name String description String? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - fsLocation String @unique //location in /store/ombul/[fsLocation] + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + fsLocation String @unique //location in /store/ombul/[fsLocation] year Int issueNumber Int - coverImage CmsImage @relation(fields: [coverImageId], references: [id], onDelete: Cascade) - coverImageId Int @unique + coverImage CmsImage @relation(fields: [coverImageId], references: [id], onDelete: Cascade) + coverImageId Int @unique + OmbulComment OmbulComment[] @@unique([year, name]) @@unique([year, issueNumber]) } + +model OmbulComment { + commentId Int @id @default(autoincrement()) + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + userId Int + comment String + Ombul Ombul @relation(fields: [OmbulId], references: [id], onDelete: Cascade) + OmbulId Int + CommentedAt DateTime @default(now()) + LastEditedAt DateTime @updatedAt +} diff --git a/src/prisma/schema/permission.prisma b/src/prisma/schema/permission.prisma index 08e75ba90..23515d23d 100644 --- a/src/prisma/schema/permission.prisma +++ b/src/prisma/schema/permission.prisma @@ -15,6 +15,9 @@ enum Permission { OMBUL_UPDATE OMBUL_DESTROY + OMBUL_COMMENT_READ + OMBUL_COMMENT_WRITE + // Groups - Generic GROUP_READ GROUP_DESTROY diff --git a/src/prisma/schema/user.prisma b/src/prisma/schema/user.prisma index c31cd5548..5f446db12 100644 --- a/src/prisma/schema/user.prisma +++ b/src/prisma/schema/user.prisma @@ -27,6 +27,8 @@ model User { memberships Membership[] credentials Credentials? feideAccount FeideAccount? + imageConsent Boolean @default(false) + kioleskapLead Boolean @default(false) notificationSubscriptions NotificationSubscription[] mailingLists MailingListUser[] @@ -41,6 +43,7 @@ model User { Event Event[] cabinBooking Booking[] @relation() + OmbulComment OmbulComment[] // We need to explicitly mark the combination of 'id', 'username' and 'email' as // unique to make the relation to 'Credentials' work. diff --git a/src/services/users/actions.ts b/src/services/users/actions.ts index 17de12e36..e3eaca666 100644 --- a/src/services/users/actions.ts +++ b/src/services/users/actions.ts @@ -42,3 +42,4 @@ export const updateUserAction = makeAction(userOperations.update) export const registerNewEmailAction = makeAction(userOperations.registerNewEmail) export const registerUser = makeAction(userOperations.register) export const registerStudentCardInQueueAction = makeAction(userOperations.registerStudentCardInQueue) + diff --git a/src/services/users/operations.ts b/src/services/users/operations.ts index 89dc9b37f..a012d9a95 100644 --- a/src/services/users/operations.ts +++ b/src/services/users/operations.ts @@ -110,6 +110,7 @@ export const userOperations = { ...userFilterSelection, bio: true, image: true, + kioleskapLead: true, }, }).then(async userData => ({ ...userData, diff --git a/src/services/users/schemas.ts b/src/services/users/schemas.ts index 0308e6501..f026ac1ae 100644 --- a/src/services/users/schemas.ts +++ b/src/services/users/schemas.ts @@ -14,9 +14,12 @@ export const userSchema = z.object({ lastname: z.string().max(50).min(2), allergies: z.string().max(150).optional().nullable(), studentCard: studentCardSchema, + kioleskapLead: Zpn.checkboxOrBoolean({ + label: 'leaderboard' + }), password: z.string().max(50).min(12, { // eslint-disable-next-line - message: 'Passoret må minst ha 12 tegn, en stor og en liten bokstav, et tall, en rune, to emojier, en musikk note, en magisk sopp og en dråpe smørekopp-blod (avsky).' + message: 'Passordet må minst ha 12 tegn, en stor og en liten bokstav, et tall, en rune, to emojier, en musikk note, en magisk sopp og en dråpe smørekopp-blod (avsky).' }), confirmPassword: z.string().max(50).min(12), acceptedTerms: Zpn.checkboxOrBoolean({ @@ -42,6 +45,8 @@ export const userSchemas = { firstname: true, lastname: true, username: true, + kioleskapLead: true, + }), register: userSchema.pick({ From 3012d10f5e5d03ab4b78898351972099ebc9b815 Mon Sep 17 00:00:00 2001 From: Sherine7734 Date: Mon, 3 Nov 2025 19:14:31 +0100 Subject: [PATCH 2/3] Deleted OmbulComment --- ..env.swp | Bin 1024 -> 0 bytes projectNext | 1 + src/prisma/schema/ombul.prisma | 11 ----------- src/prisma/schema/permission.prisma | 3 --- src/prisma/schema/user.prisma | 2 +- 5 files changed, 2 insertions(+), 15 deletions(-) delete mode 100644 ..env.swp create mode 160000 projectNext diff --git a/..env.swp b/..env.swp deleted file mode 100644 index f6b0251678dc70a9ae12cbdfa3d6fddacef1eea4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1024 zcmYc?$V<%2S1{8vVn6{I{0t05`S~R%f;c!njsYS50lLlxLGCUV#=$sLF)-+*=9S@; S9F-Uifzc44bqIu_TL1vI3kwGT diff --git a/projectNext b/projectNext new file mode 160000 index 000000000..c7b2f2445 --- /dev/null +++ b/projectNext @@ -0,0 +1 @@ +Subproject commit c7b2f2445113979eadeb1d0fcb19e70af1c23327 diff --git a/src/prisma/schema/ombul.prisma b/src/prisma/schema/ombul.prisma index 7f77552b0..2a1914325 100644 --- a/src/prisma/schema/ombul.prisma +++ b/src/prisma/schema/ombul.prisma @@ -9,19 +9,8 @@ model Ombul { issueNumber Int coverImage CmsImage @relation(fields: [coverImageId], references: [id], onDelete: Cascade) coverImageId Int @unique - OmbulComment OmbulComment[] @@unique([year, name]) @@unique([year, issueNumber]) } -model OmbulComment { - commentId Int @id @default(autoincrement()) - user User @relation(fields: [userId], references: [id], onDelete: Cascade) - userId Int - comment String - Ombul Ombul @relation(fields: [OmbulId], references: [id], onDelete: Cascade) - OmbulId Int - CommentedAt DateTime @default(now()) - LastEditedAt DateTime @updatedAt -} diff --git a/src/prisma/schema/permission.prisma b/src/prisma/schema/permission.prisma index 23515d23d..08e75ba90 100644 --- a/src/prisma/schema/permission.prisma +++ b/src/prisma/schema/permission.prisma @@ -15,9 +15,6 @@ enum Permission { OMBUL_UPDATE OMBUL_DESTROY - OMBUL_COMMENT_READ - OMBUL_COMMENT_WRITE - // Groups - Generic GROUP_READ GROUP_DESTROY diff --git a/src/prisma/schema/user.prisma b/src/prisma/schema/user.prisma index 5f446db12..5a77a761a 100644 --- a/src/prisma/schema/user.prisma +++ b/src/prisma/schema/user.prisma @@ -43,7 +43,7 @@ model User { Event Event[] cabinBooking Booking[] @relation() - OmbulComment OmbulComment[] + // We need to explicitly mark the combination of 'id', 'username' and 'email' as // unique to make the relation to 'Credentials' work. From bbbfbbcffbc435763c3fa186fa88232de3efaf7f Mon Sep 17 00:00:00 2001 From: Sherine7734 Date: Mon, 3 Nov 2025 20:06:17 +0100 Subject: [PATCH 3/3] fix: duplicate datafeild entry --- src/prisma/schema/user.prisma | 1 - 1 file changed, 1 deletion(-) diff --git a/src/prisma/schema/user.prisma b/src/prisma/schema/user.prisma index 54607726d..c3594c6e7 100644 --- a/src/prisma/schema/user.prisma +++ b/src/prisma/schema/user.prisma @@ -28,7 +28,6 @@ model User { memberships Membership[] credentials Credentials? feideAccount FeideAccount? - imageConsent Boolean @default(false) kioleskapLead Boolean @default(false) notificationSubscriptions NotificationSubscription[]