summaryrefslogtreecommitdiffstats
path: root/models/access.go
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-03-17 14:03:58 -0400
committerUnknown <joe2010xtmf@163.com>2014-03-17 14:03:58 -0400
commite51afe4621cfbc8380994c818981f42a097e3ec5 (patch)
tree74e26a6c8fa60ab82f9f1e791693cd178adc5a10 /models/access.go
parent9d3b003add6bee6cb23cbac5d32f6fb3d4fd50cb (diff)
downloadgitea-e51afe4621cfbc8380994c818981f42a097e3ec5.tar.gz
gitea-e51afe4621cfbc8380994c818981f42a097e3ec5.zip
Add postgres support, clean code, code review
Diffstat (limited to 'models/access.go')
-rw-r--r--models/access.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/models/access.go b/models/access.go
index ea5cbfaa50..36d9405f52 100644
--- a/models/access.go
+++ b/models/access.go
@@ -9,11 +9,13 @@ import (
"time"
)
+// Access types.
const (
AU_READABLE = iota + 1
AU_WRITABLE
)
+// Access represents the accessibility of user and repository.
type Access struct {
Id int64
UserName string `xorm:"unique(s)"`
@@ -22,12 +24,13 @@ type Access struct {
Created time.Time `xorm:"created"`
}
+// AddAccess adds new access record.
func AddAccess(access *Access) error {
_, err := orm.Insert(access)
return err
}
-// if one user can read or write one repository
+// HasAccess returns true if someone can read or write given repository.
func HasAccess(userName, repoName string, mode int) (bool, error) {
return orm.Get(&Access{
Id: 0,