Improve model and add roles

This commit is contained in:
William Bouzourène 2025-01-01 15:22:02 +01:00
parent 488da64ccf
commit 3e984d059c
Signed by: bouzoure
SSH key fingerprint: SHA256:19MbXpLua4rUtk8tunMesD8KUKb91LXLHg8E/qTooww
5 changed files with 32 additions and 38 deletions

View file

@ -37,11 +37,10 @@ func connectDatabase() (*gorm.DB, error) {
err = database.AutoMigrate(
&models.User{},
&models.ParentSection{},
&models.Section{},
&models.Role{},
&models.UserRoles{},
&models.Person{},
&models.ManageSection{},
&models.ManageParentSection{},
&models.List{},
&models.ListItem{},
)

View file

@ -4,6 +4,8 @@ import "gorm.io/gorm"
type Person struct {
gorm.Model
IsMember bool
IsContact bool
FirstName string
LastName string
Email string

15
models/roles.go Normal file
View file

@ -0,0 +1,15 @@
package models
import "gorm.io/gorm"
type Role struct {
gorm.Model
Name string
ShowPerson bool
CreatePerson bool
EditPerson bool
ShowArchivedPerson bool
ArchivePerson bool
RestorePerson bool
ExportData bool
}

View file

@ -2,16 +2,12 @@ package models
import "gorm.io/gorm"
type ParentSection struct {
gorm.Model
Name string
ShortName string
}
type Section struct {
gorm.Model
Name string
ShortName string
ParentSectionID uint
ParentSection ParentSection
Name string
ShortName string
ParentSectionID uint
ParentSection *Section
ContainsMembers bool
ContainsContacts bool
}

View file

@ -17,30 +17,12 @@ type User struct {
SkipWelcome bool
}
type ManageSection struct {
type UserRoles struct {
gorm.Model
UserID uint
User User
SectionID uint
Section Section
ShowPerson bool
CreatePerson bool
EditPerson bool
ShowArchivedPerson bool
ArchivePerson bool
UnarchivePerson bool
}
type ManageParentSection struct {
gorm.Model
UserID uint
User User
ParentSectionID uint
ParentSection ParentSection
ShowPerson bool
CreatePerson bool
EditPerson bool
ShowArchivedPerson bool
ArchivePerson bool
UnarchivePerson bool
UserID uint
User User
RoleID uint
Role Role
SectionID uint
Section Section
}