diff options
author | Unknwon <u@gogs.io> | 2016-03-04 15:43:01 -0500 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-03-04 15:43:01 -0500 |
commit | 2d2d85bba4dd5131e72db533c31aab423f86232e (patch) | |
tree | e53c3c263021efc846dee43249651142a49e76f3 /models/user.go | |
parent | 9df6ce48c538e0458b6798f0819db8afce43e5c7 (diff) | |
download | gitea-2d2d85bba4dd5131e72db533c31aab423f86232e.tar.gz gitea-2d2d85bba4dd5131e72db533c31aab423f86232e.zip |
#1597 support pull requests in same repository
Diffstat (limited to 'models/user.go')
-rw-r--r-- | models/user.go | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/models/user.go b/models/user.go index 3264c0634b..6e7c27293d 100644 --- a/models/user.go +++ b/models/user.go @@ -348,16 +348,10 @@ func (u *User) UploadAvatar(data []byte) error { // IsAdminOfRepo returns true if user has admin or higher access of repository. func (u *User) IsAdminOfRepo(repo *Repository) bool { - if err := repo.GetOwner(); err != nil { - log.Error(3, "GetOwner: %v", err) - return false - } - - if repo.Owner.IsOrganization() { + if repo.MustOwner().IsOrganization() { has, err := HasAccess(u, repo, ACCESS_MODE_ADMIN) if err != nil { log.Error(3, "HasAccess: %v", err) - return false } return has } @@ -365,6 +359,15 @@ func (u *User) IsAdminOfRepo(repo *Repository) bool { return repo.IsOwnedBy(u.Id) } +// CanWriteTo returns true if user has write access to given repository. +func (u *User) CanWriteTo(repo *Repository) bool { + has, err := HasAccess(u, repo, ACCESS_MODE_WRITE) + if err != nil { + log.Error(3, "HasAccess: %v", err) + } + return has +} + // IsOrganization returns true if user is actually a organization. func (u *User) IsOrganization() bool { return u.Type == ORGANIZATION |