2018-07-24 17:29:13 +02:00
|
|
|
package models
|
|
|
|
|
2018-10-31 13:42:38 +01:00
|
|
|
import (
|
|
|
|
"code.vikunja.io/api/pkg/log"
|
|
|
|
)
|
|
|
|
|
2018-07-24 17:32:08 +02:00
|
|
|
// 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 {
|
2018-10-06 13:05:29 +02:00
|
|
|
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)
|
2018-10-06 13:05:29 +02:00
|
|
|
return false
|
|
|
|
}
|
2018-10-31 13:42:38 +01:00
|
|
|
return l.IsAdmin(u)
|
2018-07-24 17:29:13 +02:00
|
|
|
}
|
2018-07-24 17:32:08 +02:00
|
|
|
|
|
|
|
// CanDelete checks if the user can delete a team <-> list relation
|
|
|
|
func (tl *TeamList) CanDelete(user *User) bool {
|
2018-10-06 13:05:29 +02:00
|
|
|
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)
|
2018-10-06 13:05:29 +02:00
|
|
|
return false
|
|
|
|
}
|
2018-07-24 17:32:08 +02:00
|
|
|
return l.IsAdmin(user)
|
2018-07-24 17:47:08 +02:00
|
|
|
}
|
2018-09-19 08:08:41 +02:00
|
|
|
|
|
|
|
// CanUpdate checks if the user can update a team <-> list relation
|
|
|
|
func (tl *TeamList) CanUpdate(user *User) bool {
|
2018-10-06 13:05:29 +02:00
|
|
|
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)
|
2018-10-06 13:05:29 +02:00
|
|
|
return false
|
|
|
|
}
|
2018-09-19 08:08:41 +02:00
|
|
|
return l.IsAdmin(user)
|
|
|
|
}
|