From ac0a50663df0721090fa54ead1f021c5c6f3ebdc Mon Sep 17 00:00:00 2001 From: kolaente Date: Thu, 14 Jun 2018 16:14:49 +0200 Subject: [PATCH] Added basic definitions for namespaces and teams --- Featurecreep.md | 7 +++-- models/models.go | 5 ++++ models/namespaces.go | 35 ++++++++++++++++++++++++ models/teams.go | 65 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 110 insertions(+), 2 deletions(-) create mode 100644 models/namespaces.go create mode 100644 models/teams.go diff --git a/Featurecreep.md b/Featurecreep.md index 0effcb5c..2c2c1051 100644 --- a/Featurecreep.md +++ b/Featurecreep.md @@ -100,7 +100,7 @@ Oder noch Besser: Man kann globale Rechte pro Namespace vergeben, die man dann w Rechte: Erstmal nur 3: Lesen, Schreiben, Admin. Admins dürfen auch Namen ändern, Teams verwalten, neue Listen anlegen, etc. - Owner haben immer Adminrechte. + Owner haben immer Adminrechte. Später sollte es auch möglich sein, den ownership an andere zur übertragen.s Teams sind global, d.h. Ein Team kann mehrere Namespaces verwalten. @@ -111,12 +111,15 @@ Teams sind global, d.h. Ein Team kann mehrere Namespaces verwalten. * [ ] Ansehen * [ ] Bearbeiten * [ ] Löschen + + Ein zu lösendes Problem: Wie regelt man die Berechtigungen um Teams zu verwalten? + * [ ] Namespaces * [ ] Erstellen * [ ] Ansehen * [ ] Bearbeiten * [ ] Löschen - * [ ] Teams hinzufügen + * [ ] Teams hinzufügen. Der Nutzer kriegt nur Teams angezeigt die er erstellt hat. * [ ] Listen * [ ] Listen zu einem Namespace hinzufügen diff --git a/models/models.go b/models/models.go index 14130a44..6fc958a5 100644 --- a/models/models.go +++ b/models/models.go @@ -35,6 +35,11 @@ func init() { new(User), new(List), new(ListItem), + new(Team), + new(TeamMember), + new(TeamList), + new(TeamNamespace), + new(Namespace), ) } diff --git a/models/namespaces.go b/models/namespaces.go new file mode 100644 index 00000000..7e0b7fcf --- /dev/null +++ b/models/namespaces.go @@ -0,0 +1,35 @@ +package models + +// Namespace holds informations about a namespace +type Namespace struct { + ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"` + Name string `xorm:"varchar(250) autoincr not null" json:"name"` + Description string `xorm:"varchar(700) autoincr not null" json:"description"` + OwnerID int64 `xorm:"int(11) autoincr not null" json:"owner_id"` + + Created int64 `xorm:"created" json:"created"` + Updated int64 `xorm:"updated" json:"updated"` +} + +// TableName makes beautiful table names +func (Namespace) TableName() string { + return "namespaces" +} + +// NamespaceRight defines the rights teams can have for namespaces +type NamespaceRight int + +// define unknown namespace right +const ( + NamespaceRightUnknown = -1 +) + +// Enumerate all the namespace rights +const ( + // Can read lists in a namespace + NamespaceRightRead NamespaceRight = iota + // Cat write items in a namespace like lists and todo items + NamespaceRightWrite + // Can manage a namespace, can do everything + NamespaceRightAdmin +) \ No newline at end of file diff --git a/models/teams.go b/models/teams.go new file mode 100644 index 00000000..20a3a747 --- /dev/null +++ b/models/teams.go @@ -0,0 +1,65 @@ +package models + +// Team holds a team object +type Team struct { + ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"` + Name string `xorm:"varchar(250) not null" json:"name"` + Description string `xorm:"varchar(250)" json:"description"` + Rights []int64 `xorm:"varchar(250)" json:"rights"` + CreatedByID int64 `xorm:"int(11) not null" json:"-"` + + Created int64 `xorm:"created" json:"created"` + Updated int64 `xorm:"updated" json:"updated"` + + CreatedBy User `json:"created_by"` +} + +// TableName makes beautiful table names +func (Team) TableName() string { + return "teams" +} + +// TeamMember defines the relationship between a user and a team +type TeamMember struct { + ID int64 `xorm:"int(11) autoincr not null unique pk"` + TeamID int64 `xorm:"int(11) autoincr not null"` + UserID int64 `xorm:"int(11) autoincr not null"` + + Created int64 `xorm:"created"` + Updated int64 `xorm:"updated"` +} + +// TableName makes beautiful table names +func (TeamMember) TableName() string { + return "team_members" +} + +// TeamNamespaces defines the relationship between a Team and a Namespace +type TeamNamespace struct { + ID int64 `xorm:"int(11) autoincr not null unique pk"` + TeamID int64 `xorm:"int(11) autoincr not null"` + NamespaceID int64 `xorm:"int(11) autoincr not null"` + + Created int64 `xorm:"created"` + Updated int64 `xorm:"updated"` +} + +// TableName makes beautiful table names +func (TeamNamespace) TableName() string { + return "team_namespaces" +} + +// TeamList defines the relation between a team and a list +type TeamList struct { + ID int64 `xorm:"int(11) autoincr not null unique pk"` + TeamID int64 `xorm:"int(11) autoincr not null"` + ListID int64 `xorm:"int(11) autoincr not null"` + + Created int64 `xorm:"created"` + Updated int64 `xorm:"updated"` +} + +// TableName makes beautiful table names +func (TeamList) TableName() string { + return "team_list" +}