vikunja-api/models/teams_rights.go

20 lines
543 B
Go
Raw Normal View History

2018-07-14 17:34:59 +02:00
package models
// CanCreate checks if the user can create a new team
2018-07-14 18:29:24 +02:00
func (t *Team) CanCreate(user *User, id int64) bool {
2018-07-14 17:34:59 +02:00
// This is currently a dummy function, later on we could imagine global limits etc.
return true
2018-07-14 17:37:46 +02:00
}
2018-07-14 18:29:24 +02:00
// CanUpdate checks if the user can update a team
func (t *Team) CanUpdate(user *User, id int64) bool {
// Check if the current user is in the team and has admin rights in it
exists, _ := x.Where("team_id = ?", id).
And("user_id = ?", user.ID).
And("is_admin = ?", true).
Get(&TeamMember{})
return exists
}