Add create organization

This commit is contained in:
Unknown 2014-06-25 00:44:48 -04:00
parent b2801a2e98
commit e0f9c628c5
24 changed files with 438 additions and 197 deletions

View file

@ -11,19 +11,20 @@ import (
"github.com/go-xorm/xorm"
)
// Access types.
type AccessType int
const (
AU_READABLE = iota + 1
AU_WRITABLE
READABLE AccessType = iota + 1
WRITABLE
)
// Access represents the accessibility of user to repository.
type Access struct {
Id int64
UserName string `xorm:"unique(s)"`
RepoName string `xorm:"unique(s)"` // <user name>/<repo name>
Mode int `xorm:"unique(s)"`
Created time.Time `xorm:"created"`
UserName string `xorm:"unique(s)"`
RepoName string `xorm:"unique(s)"` // <user name>/<repo name>
Mode AccessType `xorm:"unique(s)"`
Created time.Time `xorm:"created"`
}
// AddAccess adds new access record.
@ -59,7 +60,7 @@ func UpdateAccessWithSession(sess *xorm.Session, access *Access) error {
// HasAccess returns true if someone can read or write to given repository.
// The repoName should be in format <username>/<reponame>.
func HasAccess(uname, repoName string, mode int) (bool, error) {
func HasAccess(uname, repoName string, mode AccessType) (bool, error) {
if len(repoName) == 0 {
return false, nil
}