forked from forgejo/forgejo
Fix issues/pulls dependencies problems (#9842)
* Fix issues/pulls dependencies problems * fix swagger and api param name * fix js
This commit is contained in:
parent
0641965860
commit
f540d0ac87
8 changed files with 57 additions and 26 deletions
|
@ -14,14 +14,6 @@ import (
|
|||
|
||||
// AddDependency adds new dependencies
|
||||
func AddDependency(ctx *context.Context) {
|
||||
// Check if the Repo is allowed to have dependencies
|
||||
if !ctx.Repo.CanCreateIssueDependencies(ctx.User) {
|
||||
ctx.Error(http.StatusForbidden, "CanCreateIssueDependencies")
|
||||
return
|
||||
}
|
||||
|
||||
depID := ctx.QueryInt64("newDependency")
|
||||
|
||||
issueIndex := ctx.ParamsInt64("index")
|
||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, issueIndex)
|
||||
if err != nil {
|
||||
|
@ -29,6 +21,14 @@ func AddDependency(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
// Check if the Repo is allowed to have dependencies
|
||||
if !ctx.Repo.CanCreateIssueDependencies(ctx.User, issue.IsPull) {
|
||||
ctx.Error(http.StatusForbidden, "CanCreateIssueDependencies")
|
||||
return
|
||||
}
|
||||
|
||||
depID := ctx.QueryInt64("newDependency")
|
||||
|
||||
if err = issue.LoadRepo(); err != nil {
|
||||
ctx.ServerError("LoadRepo", err)
|
||||
return
|
||||
|
@ -73,14 +73,6 @@ func AddDependency(ctx *context.Context) {
|
|||
|
||||
// RemoveDependency removes the dependency
|
||||
func RemoveDependency(ctx *context.Context) {
|
||||
// Check if the Repo is allowed to have dependencies
|
||||
if !ctx.Repo.CanCreateIssueDependencies(ctx.User) {
|
||||
ctx.Error(http.StatusForbidden, "CanCreateIssueDependencies")
|
||||
return
|
||||
}
|
||||
|
||||
depID := ctx.QueryInt64("removeDependencyID")
|
||||
|
||||
issueIndex := ctx.ParamsInt64("index")
|
||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, issueIndex)
|
||||
if err != nil {
|
||||
|
@ -88,6 +80,14 @@ func RemoveDependency(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
// Check if the Repo is allowed to have dependencies
|
||||
if !ctx.Repo.CanCreateIssueDependencies(ctx.User, issue.IsPull) {
|
||||
ctx.Error(http.StatusForbidden, "CanCreateIssueDependencies")
|
||||
return
|
||||
}
|
||||
|
||||
depID := ctx.QueryInt64("removeDependencyID")
|
||||
|
||||
if err = issue.LoadRepo(); err != nil {
|
||||
ctx.ServerError("LoadRepo", err)
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue