aboutsummaryrefslogtreecommitdiffstats
path: root/models/access.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-03-05 18:08:42 -0500
committerUnknwon <u@gogs.io>2016-03-05 18:08:42 -0500
commit045f14fbd0e3553521f5092cf839be363c74a090 (patch)
tree9c82f5111c5c5262c97bd7936462fa4170e76b4f /models/access.go
parent05d8664f15013b0159b3689bda84e89dd7be22fd (diff)
downloadgitea-045f14fbd0e3553521f5092cf839be363c74a090.tar.gz
gitea-045f14fbd0e3553521f5092cf839be363c74a090.zip
#1146 finsih UI work for access mode of collaborators
Collaborators have write access as default, and can be changed via repository collaboration settings page to change between read, write and admin.
Diffstat (limited to 'models/access.go')
-rw-r--r--models/access.go21
1 files changed, 10 insertions, 11 deletions
diff --git a/models/access.go b/models/access.go
index 5eef32819e..fe2350606a 100644
--- a/models/access.go
+++ b/models/access.go
@@ -13,11 +13,11 @@ import (
type AccessMode int
const (
- ACCESS_MODE_NONE AccessMode = iota
- ACCESS_MODE_READ
- ACCESS_MODE_WRITE
- ACCESS_MODE_ADMIN
- ACCESS_MODE_OWNER
+ ACCESS_MODE_NONE AccessMode = iota // 0
+ ACCESS_MODE_READ // 1
+ ACCESS_MODE_WRITE // 2
+ ACCESS_MODE_ADMIN // 3
+ ACCESS_MODE_OWNER // 4
)
// Access represents the highest access level of a user to the repository. The only access type
@@ -151,15 +151,14 @@ func (repo *Repository) refreshAccesses(e Engine, accessMap map[int64]AccessMode
return nil
}
-// FIXME: should be able to have read-only access.
-// Give all collaborators write access.
+// refreshCollaboratorAccesses retrieves repository collaborations with their access modes.
func (repo *Repository) refreshCollaboratorAccesses(e Engine, accessMap map[int64]AccessMode) error {
- collaborators, err := repo.getCollaborators(e)
+ collaborations, err := repo.getCollaborations(e)
if err != nil {
- return fmt.Errorf("getCollaborators: %v", err)
+ return fmt.Errorf("getCollaborations: %v", err)
}
- for _, c := range collaborators {
- accessMap[c.Id] = ACCESS_MODE_WRITE
+ for _, c := range collaborations {
+ accessMap[c.UserID] = c.Mode
}
return nil
}