vikunja-api/pkg/models/team_list_rights.go

36 lines
964 B
Go
Raw Normal View History

package models
2018-10-31 13:42:38 +01:00
import (
"code.vikunja.io/api/pkg/log"
)
// CanCreate checks if the user can create a team <-> list relation
2018-10-31 13:42:38 +01:00
func (tl *TeamList) CanCreate(u *User) bool {
l := List{ID: tl.ListID}
if err := l.GetSimpleByID(); err != nil {
2018-10-31 13:42:38 +01:00
log.Log.Error("Error occurred during CanCreate for TeamList: %s", err)
return false
}
2018-10-31 13:42:38 +01:00
return l.IsAdmin(u)
}
// CanDelete checks if the user can delete a team <-> list relation
func (tl *TeamList) CanDelete(user *User) bool {
l := List{ID: tl.ListID}
if err := l.GetSimpleByID(); err != nil {
2018-10-31 13:42:38 +01:00
log.Log.Error("Error occurred during CanDelete for TeamList: %s", err)
return false
}
return l.IsAdmin(user)
2018-07-24 17:47:08 +02:00
}
// CanUpdate checks if the user can update a team <-> list relation
func (tl *TeamList) CanUpdate(user *User) bool {
l := List{ID: tl.ListID}
if err := l.GetSimpleByID(); err != nil {
2018-10-31 13:42:38 +01:00
log.Log.Error("Error occurred during CanUpdate for TeamList: %s", err)
return false
}
return l.IsAdmin(user)
}