From f14c0c0e221da85e7075fc577329edad708fc5d7 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 22 Feb 2023 08:24:32 +0800 Subject: [PATCH] Add Clubs to the admin portal --- pkg/admin/src/db.ts | 33 +++++++++++++++++++++++++++++++++ pkg/admin/src/index.ts | 2 ++ 2 files changed, 35 insertions(+) diff --git a/pkg/admin/src/db.ts b/pkg/admin/src/db.ts index 95ef60f49..a694e165a 100644 --- a/pkg/admin/src/db.ts +++ b/pkg/admin/src/db.ts @@ -8,6 +8,7 @@ import { JoinColumn, ManyToOne, OneToMany, + OneToOne, } from 'typeorm' import AdminJs from 'adminjs' import { Database, Resource } from '@adminjs/typeorm' @@ -46,6 +47,7 @@ export const registerDatabase = async (secrets: any): Promise => { UserArticle, ReceivedEmail, ContentDisplayReport, + Group, ], }) @@ -186,3 +188,34 @@ export class ReceivedEmail extends BaseEntity { @Column({ type: 'timestamp', name: 'updated_at' }) updatedAt!: Date } + +@Entity() +export class Group extends BaseEntity { + @PrimaryGeneratedColumn('uuid') + id!: string + + @Column('text') + name!: string + + @OneToOne(() => User) + @JoinColumn() + createdBy!: User + + @Column({ type: 'timestamp', name: 'created_at' }) + createdAt!: Date + + @Column({ type: 'timestamp', name: 'updated_at' }) + updatedAt!: Date + + @Column('text', { nullable: true }) + description?: string | null + + @Column('text', { nullable: true }) + topics?: string | null + + @Column('boolean', { default: false }) + onlyAdminCanPost!: boolean + + @Column('boolean', { default: false }) + onlyAdminCanSeeMembers!: boolean +} diff --git a/pkg/admin/src/index.ts b/pkg/admin/src/index.ts index 56faeaaf3..c1b128727 100644 --- a/pkg/admin/src/index.ts +++ b/pkg/admin/src/index.ts @@ -8,6 +8,7 @@ import { UserArticle, UserProfile, ReceivedEmail, + Group, ContentDisplayReport, } from './db' import { compare, hashSync } from 'bcryptjs' @@ -35,6 +36,7 @@ const ADMIN_USER_EMAIL = { resource: UserProfile, options: { parent: { name: 'Users' } } }, { resource: UserArticle, options: { parent: { name: 'Users' } } }, { resource: ReceivedEmail, options: { parent: { name: 'Users' } } }, + { resource: Group, options: { parent: { name: 'Users' } } }, { resource: ContentDisplayReport, },