diff --git a/routers/web/repo/compare.go b/routers/web/repo/compare.go index fc5f82ec0673c..b0d93fc7b05f8 100644 --- a/routers/web/repo/compare.go +++ b/routers/web/repo/compare.go @@ -844,6 +844,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 0f1491ae80939..29d17d2e656a0 100644 --- a/routers/web/repo/pull.go +++ b/routers/web/repo/pull.go @@ -1371,7 +1371,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 } @@ -1449,6 +1449,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(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()) }