vikunja-api/pkg/models/task_assignees_rights.go

46 lines
1.5 KiB
Go
Raw Normal View History

// Vikunja is a todo-list application to facilitate your life.
2020-01-09 18:33:22 +01:00
// Copyright 2018-2020 Vikunja and contributors. All rights reserved.
2019-01-08 20:13:07 +01:00
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
2019-01-08 20:13:07 +01:00
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
2019-01-08 20:13:07 +01:00
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
2019-01-08 20:13:07 +01:00
package models
import (
"code.vikunja.io/web"
)
// CanCreate checks if a user can add a new assignee
2019-08-14 22:19:04 +02:00
func (la *TaskAssginee) CanCreate(a web.Auth) (bool, error) {
return canDoTaskAssingee(la.TaskID, a)
2019-01-08 20:13:07 +01:00
}
// CanCreate checks if a user can add a new assignee
2019-03-24 13:35:50 +01:00
func (ba *BulkAssignees) CanCreate(a web.Auth) (bool, error) {
2019-08-14 22:19:04 +02:00
return canDoTaskAssingee(ba.TaskID, a)
2019-01-08 20:13:07 +01:00
}
// CanDelete checks if a user can delete an assignee
2019-08-14 22:19:04 +02:00
func (la *TaskAssginee) CanDelete(a web.Auth) (bool, error) {
return canDoTaskAssingee(la.TaskID, a)
2019-01-08 20:13:07 +01:00
}
2019-08-14 22:19:04 +02:00
func canDoTaskAssingee(taskID int64, a web.Auth) (bool, error) {
2019-01-08 20:13:07 +01:00
// Check if the current user can edit the list
list, err := GetListSimplByTaskID(taskID)
if err != nil {
2019-03-24 13:35:50 +01:00
return false, err
2019-01-08 20:13:07 +01:00
}
return list.CanUpdate(a)
2019-01-08 20:13:07 +01:00
}