mirror of
https://codeberg.org/davrot/forgejo.git
synced 2025-05-17 14:00:01 +02:00
#1597 support pull requests in same repository
This commit is contained in:
parent
9df6ce48c5
commit
2d2d85bba4
13 changed files with 96 additions and 135 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue