You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.2 KiB
40 lines
1.2 KiB
package models
|
|
|
|
// ProjectPermission is a structure that associates a user with a project.
|
|
type ProjectPermission struct {
|
|
ProjectID string `db:"project_id"`
|
|
UserID string `db:"user_id"`
|
|
Level int `db:"access_level"`
|
|
}
|
|
|
|
const (
|
|
ProjectPermissionLevelNoAccess int = 0
|
|
ProjectPermissionLevelObserver int = 1
|
|
ProjectPermissionLevelMember int = 2
|
|
ProjectPermissionLevelAdmin int = 3
|
|
ProjectPermissionLevelOwner int = 4
|
|
)
|
|
|
|
func (permission *ProjectPermission) CanViewAnyIssue() bool {
|
|
return permission.Level >= ProjectPermissionLevelObserver
|
|
}
|
|
|
|
func (permission *ProjectPermission) CanViewOwnIssue() bool {
|
|
return permission.Level >= ProjectPermissionLevelObserver
|
|
}
|
|
|
|
func (permission *ProjectPermission) CanManageOwnIssue() bool {
|
|
return permission.Level >= ProjectPermissionLevelMember
|
|
}
|
|
|
|
func (permission *ProjectPermission) CanManageAnyIssue() bool {
|
|
return permission.Level >= ProjectPermissionLevelAdmin
|
|
}
|
|
|
|
func (permission *ProjectPermission) CanManagePermissions() bool {
|
|
return permission.Level >= ProjectPermissionLevelOwner
|
|
}
|
|
|
|
func (permission *ProjectPermission) CanManageActivities() bool {
|
|
return permission.Level >= ProjectPermissionLevelAdmin
|
|
}
|