ui: show 'owner' tag for real owner (#13689)
* ui: show 'owner' tag for real owner Signed-off-by: a1012112796 <1012112796@qq.com> * Update custom/conf/app.example.ini * simplify logic fix logic fix a small bug about original author * remove system manager tag Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
parent
48c9865fce
commit
1e5247d424
|
@ -271,6 +271,27 @@ func getUserRepoPermission(e Engine, repo *Repository, user *User) (perm Permiss
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsUserRealRepoAdmin check if this user is real repo admin
|
||||||
|
func IsUserRealRepoAdmin(repo *Repository, user *User) (bool, error) {
|
||||||
|
if repo.OwnerID == user.ID {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
sess := x.NewSession()
|
||||||
|
defer sess.Close()
|
||||||
|
|
||||||
|
if err := repo.getOwner(sess); err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
accessMode, err := accessLevel(sess, user, repo)
|
||||||
|
if err != nil {
|
||||||
|
return false, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return accessMode >= AccessModeAdmin, nil
|
||||||
|
}
|
||||||
|
|
||||||
// IsUserRepoAdmin return true if user has admin right of a repo
|
// IsUserRepoAdmin return true if user has admin right of a repo
|
||||||
func IsUserRepoAdmin(repo *Repository, user *User) (bool, error) {
|
func IsUserRepoAdmin(repo *Repository, user *User) (bool, error) {
|
||||||
return isUserRepoAdmin(x, repo, user)
|
return isUserRepoAdmin(x, repo, user)
|
||||||
|
|
|
@ -980,8 +980,27 @@ func commentTag(repo *models.Repository, poster *models.User, issue *models.Issu
|
||||||
return models.CommentTagNone, err
|
return models.CommentTagNone, err
|
||||||
}
|
}
|
||||||
if perm.IsOwner() {
|
if perm.IsOwner() {
|
||||||
|
if !poster.IsAdmin {
|
||||||
return models.CommentTagOwner, nil
|
return models.CommentTagOwner, nil
|
||||||
} else if perm.CanWrite(models.UnitTypeCode) {
|
}
|
||||||
|
|
||||||
|
ok, err := models.IsUserRealRepoAdmin(repo, poster)
|
||||||
|
if err != nil {
|
||||||
|
return models.CommentTagNone, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if ok {
|
||||||
|
return models.CommentTagOwner, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if ok, err = repo.IsCollaborator(poster.ID); ok && err == nil {
|
||||||
|
return models.CommentTagWriter, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return models.CommentTagNone, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if perm.CanWrite(models.UnitTypeCode) {
|
||||||
return models.CommentTagWriter, nil
|
return models.CommentTagWriter, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="comment-header-right actions df ac">
|
<div class="comment-header-right actions df ac">
|
||||||
{{if not $.Repository.IsArchived}}
|
{{if not $.Repository.IsArchived}}
|
||||||
{{if eq .PosterID .Issue.PosterID }}
|
{{if or (and (eq .PosterID .Issue.PosterID) (eq .Issue.OriginalAuthorID 0)) (eq .Issue.OriginalAuthorID .OriginalAuthorID) }}
|
||||||
<div class="ui basic label">
|
<div class="ui basic label">
|
||||||
{{$.i18n.Tr "repo.issues.poster"}}
|
{{$.i18n.Tr "repo.issues.poster"}}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue