2020-02-07 16:27:45 +00:00
|
|
|
// Vikunja is a to-do list application to facilitate your life.
|
2021-02-02 19:19:13 +00:00
|
|
|
// Copyright 2018-2021 Vikunja and contributors. All rights reserved.
|
2018-11-26 20:17:33 +00:00
|
|
|
//
|
2019-12-04 19:39:56 +00:00
|
|
|
// This program is free software: you can redistribute it and/or modify
|
2020-12-23 15:41:52 +00:00
|
|
|
// it under the terms of the GNU Affero General Public Licensee as published by
|
2019-12-04 19:39:56 +00:00
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
2018-11-26 20:17:33 +00:00
|
|
|
//
|
2019-12-04 19:39:56 +00: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
|
2020-12-23 15:41:52 +00:00
|
|
|
// GNU Affero General Public Licensee for more details.
|
2018-11-26 20:17:33 +00:00
|
|
|
//
|
2020-12-23 15:41:52 +00:00
|
|
|
// You should have received a copy of the GNU Affero General Public Licensee
|
2019-12-04 19:39:56 +00:00
|
|
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2018-11-26 20:17:33 +00:00
|
|
|
|
2018-07-24 15:29:13 +00:00
|
|
|
package models
|
|
|
|
|
2018-10-31 12:42:38 +00:00
|
|
|
import (
|
2018-11-30 23:26:56 +00:00
|
|
|
"code.vikunja.io/web"
|
2020-12-23 15:32:28 +00:00
|
|
|
"xorm.io/xorm"
|
2018-10-31 12:42:38 +00:00
|
|
|
)
|
|
|
|
|
2022-11-13 16:07:01 +00:00
|
|
|
// CanCreate checks if the user can create a team <-> project relation
|
|
|
|
func (tl *TeamProject) CanCreate(s *xorm.Session, a web.Auth) (bool, error) {
|
|
|
|
return tl.canDoTeamProject(s, a)
|
2018-07-24 15:29:13 +00:00
|
|
|
}
|
2018-07-24 15:32:08 +00:00
|
|
|
|
2022-11-13 16:07:01 +00:00
|
|
|
// CanDelete checks if the user can delete a team <-> project relation
|
|
|
|
func (tl *TeamProject) CanDelete(s *xorm.Session, a web.Auth) (bool, error) {
|
|
|
|
return tl.canDoTeamProject(s, a)
|
2018-07-24 15:47:08 +00:00
|
|
|
}
|
2018-09-19 06:08:41 +00:00
|
|
|
|
2022-11-13 16:07:01 +00:00
|
|
|
// CanUpdate checks if the user can update a team <-> project relation
|
|
|
|
func (tl *TeamProject) CanUpdate(s *xorm.Session, a web.Auth) (bool, error) {
|
|
|
|
return tl.canDoTeamProject(s, a)
|
2019-06-28 08:21:48 +00:00
|
|
|
}
|
2018-11-30 23:26:56 +00:00
|
|
|
|
2022-11-13 16:07:01 +00:00
|
|
|
func (tl *TeamProject) canDoTeamProject(s *xorm.Session, a web.Auth) (bool, error) {
|
2019-08-31 20:56:41 +00:00
|
|
|
// Link shares aren't allowed to do anything
|
|
|
|
if _, is := a.(*LinkSharing); is {
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
2022-11-13 16:07:01 +00:00
|
|
|
l := Project{ID: tl.ProjectID}
|
2020-12-23 15:32:28 +00:00
|
|
|
return l.IsAdmin(s, a)
|
2018-09-19 06:08:41 +00:00
|
|
|
}
|