mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-22 10:38:30 -04:00
#1146 finish new access rights for collaborators
This commit is contained in:
parent
045f14fbd0
commit
a5b0400be7
22 changed files with 210 additions and 190 deletions
|
@ -273,7 +273,7 @@ func RetrieveRepoMilestonesAndAssignees(ctx *middleware.Context, repo *models.Re
|
|||
}
|
||||
|
||||
func RetrieveRepoMetas(ctx *middleware.Context, repo *models.Repository) []*models.Label {
|
||||
if !ctx.Repo.IsAdmin() {
|
||||
if !ctx.Repo.IsWriter() {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
@ -356,7 +356,7 @@ func ValidateRepoMetas(ctx *middleware.Context, form auth.CreateIssueForm) ([]in
|
|||
return nil, 0, 0
|
||||
}
|
||||
|
||||
if !ctx.Repo.IsAdmin() {
|
||||
if !ctx.Repo.IsWriter() {
|
||||
return nil, 0, 0
|
||||
}
|
||||
|
||||
|
@ -624,7 +624,7 @@ func ViewIssue(ctx *middleware.Context) {
|
|||
ctx.Data["Labels"] = labels
|
||||
|
||||
// Check milestone and assignee.
|
||||
if ctx.Repo.IsAdmin() {
|
||||
if ctx.Repo.IsWriter() {
|
||||
RetrieveRepoMilestonesAndAssignees(ctx, repo)
|
||||
if ctx.Written() {
|
||||
return
|
||||
|
@ -664,8 +664,8 @@ func ViewIssue(ctx *middleware.Context) {
|
|||
if repo.IsOwnedBy(comment.PosterID) ||
|
||||
(repo.Owner.IsOrganization() && repo.Owner.IsOwnedBy(comment.PosterID)) {
|
||||
comment.ShowTag = models.COMMENT_TAG_OWNER
|
||||
} else if comment.Poster.IsAdminOfRepo(repo) {
|
||||
comment.ShowTag = models.COMMENT_TAG_ADMIN
|
||||
} else if comment.Poster.IsWriterOfRepo(repo) {
|
||||
comment.ShowTag = models.COMMENT_TAG_WRITER
|
||||
} else if comment.PosterID == issue.PosterID {
|
||||
comment.ShowTag = models.COMMENT_TAG_POSTER
|
||||
}
|
||||
|
@ -688,7 +688,7 @@ func ViewIssue(ctx *middleware.Context) {
|
|||
ctx.Data["Participants"] = participants
|
||||
ctx.Data["NumParticipants"] = len(participants)
|
||||
ctx.Data["Issue"] = issue
|
||||
ctx.Data["IsIssueOwner"] = ctx.Repo.IsAdmin() || (ctx.IsSigned && issue.IsPoster(ctx.User.Id))
|
||||
ctx.Data["IsIssueOwner"] = ctx.Repo.IsWriter() || (ctx.IsSigned && (issue.IsPoster(ctx.User.Id) || ctx.User.IsAdmin))
|
||||
ctx.Data["SignInLink"] = setting.AppSubUrl + "/user/login"
|
||||
|
||||
ctx.Data["RequireHighlightJS"] = true
|
||||
|
@ -715,7 +715,7 @@ func UpdateIssueTitle(ctx *middleware.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if !ctx.IsSigned || (ctx.User.Id != issue.PosterID && !ctx.Repo.IsAdmin()) {
|
||||
if !ctx.IsSigned || (ctx.User.Id != issue.PosterID && !ctx.Repo.IsWriter() && !ctx.User.IsAdmin) {
|
||||
ctx.Error(403)
|
||||
return
|
||||
}
|
||||
|
@ -742,7 +742,7 @@ func UpdateIssueContent(ctx *middleware.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
if !ctx.IsSigned || (ctx.User.Id != issue.PosterID && !ctx.Repo.IsAdmin()) {
|
||||
if !ctx.IsSigned || (ctx.User.Id != issue.PosterID && !ctx.Repo.IsWriter() && !ctx.User.IsAdmin) {
|
||||
ctx.Error(403)
|
||||
return
|
||||
}
|
||||
|
@ -883,7 +883,7 @@ func NewComment(ctx *middleware.Context, form auth.CreateCommentForm) {
|
|||
var comment *models.Comment
|
||||
defer func() {
|
||||
// Check if issue admin/poster changes the status of issue.
|
||||
if (ctx.Repo.IsAdmin() || (ctx.IsSigned && issue.IsPoster(ctx.User.Id))) &&
|
||||
if (ctx.Repo.IsWriter() || (ctx.IsSigned && issue.IsPoster(ctx.User.Id))) &&
|
||||
(form.Status == "reopen" || form.Status == "close") &&
|
||||
!(issue.IsPull && issue.HasMerged) {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue