diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index f3b95b68fe..042b8ed692 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -845,6 +845,7 @@ func CompareDiff(ctx *context.Context) { } } + ctx.Data["IsProjectsEnabled"] = ctx.Repo.CanWrite(unit.TypeProjects) ctx.Data["IsAttachmentEnabled"] = setting.Attachment.Enabled upload.AddUploadContext(ctx, "comment") diff --git a/routers/web/repo/pull.go b/routers/web/repo/pull.go index 39f9cefa5c..a7e703d01c 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -1387,7 +1387,7 @@ func CompareAndPullRequestPost(ctx *context.Context) { return } - labelIDs, assigneeIDs, milestoneID, _ := ValidateRepoMetas(ctx, *form, true) + labelIDs, assigneeIDs, milestoneID, projectID := ValidateRepoMetas(ctx, *form, true) if ctx.Written() { return } @@ -1465,6 +1465,17 @@ func CompareAndPullRequestPost(ctx *context.Context) { return } + if projectID > 0 { + if !ctx.Repo.CanWrite(unit.TypeProjects) { + ctx.Error(http.StatusBadRequest, "user hasn't the permission to write to projects") + return + } + if err := issues_model.ChangeProjectAssign(ctx, pullIssue, ctx.Doer, projectID); err != nil { + ctx.ServerError("ChangeProjectAssign", err) + return + } + } + log.Trace("Pull request created: %d/%d", repo.ID, pullIssue.ID) ctx.JSONRedirect(pullIssue.Link()) }