Remove unnecessary permissions load (#9796)

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <matti@mdranta.net>
tokarchuk/v1.17
Lunny Xiao 5 years ago committed by Antoine GIRARD
parent f740943df4
commit dbd89acf98
  1. 8
      routers/api/v1/repo/pull.go
  2. 7
      routers/repo/issue.go
  3. 9
      routers/repo/milestone.go

@ -600,13 +600,7 @@ func MergePullRequest(ctx *context.APIContext, form auth.MergePullRequestForm) {
return return
} }
perm, err := models.GetUserRepoPermission(ctx.Repo.Repository, ctx.User) allowedMerge, err := pull_service.IsUserAllowedToMerge(pr, ctx.Repo.Permission, ctx.User)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetUserRepoPermission", err)
return
}
allowedMerge, err := pull_service.IsUserAllowedToMerge(pr, perm, ctx.User)
if err != nil { if err != nil {
ctx.Error(http.StatusInternalServerError, "IsUSerAllowedToMerge", err) ctx.Error(http.StatusInternalServerError, "IsUSerAllowedToMerge", err)
return return

@ -316,12 +316,7 @@ func Issues(ctx *context.Context) {
return return
} }
perm, err := models.GetUserRepoPermission(ctx.Repo.Repository, ctx.User) ctx.Data["CanWriteIssuesOrPulls"] = ctx.Repo.CanWriteIssuesOrPulls(isPullList)
if err != nil {
ctx.ServerError("GetUserRepoPermission", err)
return
}
ctx.Data["CanWriteIssuesOrPulls"] = perm.CanWriteIssuesOrPulls(isPullList)
ctx.HTML(200, tplIssues) ctx.HTML(200, tplIssues)
} }

@ -268,13 +268,8 @@ func MilestoneIssuesAndPulls(ctx *context.Context) {
issues(ctx, milestoneID, util.OptionalBoolNone) issues(ctx, milestoneID, util.OptionalBoolNone)
perm, err := models.GetUserRepoPermission(ctx.Repo.Repository, ctx.User) ctx.Data["CanWriteIssues"] = ctx.Repo.CanWriteIssuesOrPulls(false)
if err != nil { ctx.Data["CanWritePulls"] = ctx.Repo.CanWriteIssuesOrPulls(true)
ctx.ServerError("GetUserRepoPermission", err)
return
}
ctx.Data["CanWriteIssues"] = perm.CanWriteIssuesOrPulls(false)
ctx.Data["CanWritePulls"] = perm.CanWriteIssuesOrPulls(true)
ctx.HTML(200, tplMilestoneIssues) ctx.HTML(200, tplMilestoneIssues)
} }

Loading…
Cancel
Save