summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2016-03-21 12:47:54 -0400
committerUnknwon <u@gogs.io>2016-03-21 12:47:54 -0400
commite6f927f61af927156798390e64f17dd6755697e7 (patch)
treec97f90dfb0f4ae96534c13f98352907fb42d177b /models
parent60ae8ac3d2995d46156ead8ad93004801daad4ce (diff)
downloadgitea-e6f927f61af927156798390e64f17dd6755697e7.tar.gz
gitea-e6f927f61af927156798390e64f17dd6755697e7.zip
#1692 api: admin list and create team under organization
Diffstat (limited to 'models')
-rw-r--r--models/access.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/models/access.go b/models/access.go
index 447777ad5a..b4c1349b65 100644
--- a/models/access.go
+++ b/models/access.go
@@ -20,6 +20,33 @@ const (
ACCESS_MODE_OWNER // 4
)
+func (mode AccessMode) String() string {
+ switch mode {
+ case ACCESS_MODE_READ:
+ return "read"
+ case ACCESS_MODE_WRITE:
+ return "write"
+ case ACCESS_MODE_ADMIN:
+ return "admin"
+ case ACCESS_MODE_OWNER:
+ return "owner"
+ default:
+ return "none"
+ }
+}
+
+// ParseAccessMode returns corresponding access mode to given permission string.
+func ParseAccessMode(permission string) AccessMode {
+ switch permission {
+ case "write":
+ return ACCESS_MODE_WRITE
+ case "admin":
+ return ACCESS_MODE_ADMIN
+ default:
+ return ACCESS_MODE_READ
+ }
+}
+
// Access represents the highest access level of a user to the repository. The only access type
// that is not in this table is the real owner of a repository. In case of an organization
// repository, the members of the owners team are in this table.