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 }