From 2e3c10be13167517b613f162cfeaa8a1d46b07b1 Mon Sep 17 00:00:00 2001 From: konrad Date: Tue, 17 Jul 2018 08:16:04 +0200 Subject: [PATCH] updated todo + cleanup --- Featurecreep.md | 11 +++++++++++ models/namespace_rights.go | 14 +------------- models/teams.go | 16 ++++++++-------- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/Featurecreep.md b/Featurecreep.md index 98dc50e6..be6c9e54 100644 --- a/Featurecreep.md +++ b/Featurecreep.md @@ -130,6 +130,17 @@ Teams sind global, d.h. Ein Team kann mehrere Namespaces verwalten. ?? Wenn man Listen mit nem Nutzer teilt, wird ein Team für diesen Nutzer erstellt, falls er nicht bereits in einem ist. +*Routen* + +* [ ] `namespaces/:id/teams` + * [ ] Create + * [ ] ReadAll + * [ ] Delete +* [ ] `lists/:id/teams` + * [ ] Create + * [ ] ReadAll + * [ ] Delete + #### v0.3 * [ ] Labels diff --git a/models/namespace_rights.go b/models/namespace_rights.go index 6ae9b2ca..46fb4b49 100644 --- a/models/namespace_rights.go +++ b/models/namespace_rights.go @@ -12,24 +12,12 @@ const ( const ( // Can read lists in a namespace NamespaceRightRead NamespaceRight = iota - // Cat write items in a namespace like lists and todo items + // Can write items in a namespace like lists and todo items. Cannot create new lists. NamespaceRightWrite // Can manage a namespace, can do everything NamespaceRightAdmin ) -// IsNamespaceAdmin returns whether the usre has admin rights in a namespace -func (user *User) IsNamespaceAdmin(namespace *Namespace) (err error) { - // Owners always have admin rights - if user.ID == namespace.Owner.ID { - return nil - } - - // Check if that user is in a team which has admin rights to that namespace - - return ErrUserNeedsToBeNamespaceAdmin{UserID: user.ID, NamespaceID: namespace.ID} -} - // IsAdmin returns true or false if the user is admin on that namespace or not func (n *Namespace) IsAdmin(user *User) bool { diff --git a/models/teams.go b/models/teams.go index 8f2c80ce..92a32514 100644 --- a/models/teams.go +++ b/models/teams.go @@ -62,10 +62,10 @@ type TeamUser struct { // TeamNamespace defines the relationship between a Team and a Namespace type TeamNamespace struct { - ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"` - TeamID int64 `xorm:"int(11) not null" json:"team_id"` - NamespaceID int64 `xorm:"int(11) not null" json:"namespace_id"` - Rights []int64 `xorm:"varchar(250)" json:"rights"` + ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"` + TeamID int64 `xorm:"int(11) not null" json:"team_id"` + NamespaceID int64 `xorm:"int(11) not null" json:"namespace_id"` + Rights NamespaceRight `xorm:"int(11)" json:"rights"` Created int64 `xorm:"created" json:"created"` Updated int64 `xorm:"updated" json:"updated"` @@ -78,10 +78,10 @@ func (TeamNamespace) TableName() string { // TeamList defines the relation between a team and a list type TeamList struct { - ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"` - TeamID int64 `xorm:"int(11) not null" json:"team_id"` - ListID int64 `xorm:"int(11) not null" json:"list_id"` - Rights []int64 `xorm:"varchar(250)" json:"rights"` + ID int64 `xorm:"int(11) autoincr not null unique pk" json:"id"` + TeamID int64 `xorm:"int(11) not null" json:"team_id"` + ListID int64 `xorm:"int(11) not null" json:"list_id"` + Rights int `xorm:"varchar(250)" json:"rights"` Created int64 `xorm:"created" json:"created"` Updated int64 `xorm:"updated" json:"updated"`