Replaced c with ctx for consistency
This commit is contained in:
parent
866beeb3c3
commit
5e20447c66
|
|
@ -13,57 +13,57 @@ import (
|
|||
)
|
||||
|
||||
// AddDependency adds new dependencies
|
||||
func AddDependency(c *context.Context) {
|
||||
func AddDependency(ctx *context.Context) {
|
||||
|
||||
depID := c.QueryInt64("newDependency")
|
||||
depID := ctx.QueryInt64("newDependency")
|
||||
|
||||
issueIndex := c.ParamsInt64("index")
|
||||
issue, err := models.GetIssueByIndex(c.Repo.Repository.ID, issueIndex)
|
||||
issueIndex := ctx.ParamsInt64("index")
|
||||
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, issueIndex)
|
||||
if err != nil {
|
||||
c.Handle(http.StatusInternalServerError, "GetIssueByIndex", err)
|
||||
ctx.Handle(http.StatusInternalServerError, "GetIssueByIndex", err)
|
||||
return
|
||||
}
|
||||
|
||||
// Check if the Repo is allowed to have dependencies
|
||||
if !c.Repo.CanCreateIssueDependencies(issue, c.User) {
|
||||
c.Handle(404, "MustEnableIssueDependencies", nil)
|
||||
if !ctx.Repo.CanCreateIssueDependencies(issue, ctx.User) {
|
||||
ctx.Handle(404, "MustEnableIssueDependencies", nil)
|
||||
return
|
||||
}
|
||||
|
||||
// Dependency
|
||||
dep, err := models.GetIssueByID(depID)
|
||||
if err != nil {
|
||||
c.Flash.Error(c.Tr("repo.issues.dependency.add_error_dep_not_exist"))
|
||||
url := fmt.Sprintf("%s/issues/%d", c.Repo.RepoLink, issueIndex)
|
||||
c.Redirect(url, http.StatusSeeOther)
|
||||
ctx.Flash.Error(ctx.Tr("repo.issues.dependency.add_error_dep_not_exist"))
|
||||
url := fmt.Sprintf("%s/issues/%d", ctx.Repo.RepoLink, issueIndex)
|
||||
ctx.Redirect(url, http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
|
||||
// Check if both issues are in the same repo
|
||||
if issue.RepoID != dep.RepoID {
|
||||
c.Flash.Error(c.Tr("repo.issues.dependency.add_error_dep_not_same_repo"))
|
||||
url := fmt.Sprintf("%s/issues/%d", c.Repo.RepoLink, issueIndex)
|
||||
c.Redirect(url, http.StatusSeeOther)
|
||||
ctx.Flash.Error(ctx.Tr("repo.issues.dependency.add_error_dep_not_same_repo"))
|
||||
url := fmt.Sprintf("%s/issues/%d", ctx.Repo.RepoLink, issueIndex)
|
||||
ctx.Redirect(url, http.StatusSeeOther)
|
||||
return
|
||||
}
|
||||
|
||||
// Check if issue and dependency is the same
|
||||
if dep.Index == issueIndex {
|
||||
c.Flash.Error(c.Tr("repo.issues.dependency.add_error_same_issue"))
|
||||
ctx.Flash.Error(ctx.Tr("repo.issues.dependency.add_error_same_issue"))
|
||||
} else {
|
||||
err := models.CreateIssueDependency(c.User, issue, dep)
|
||||
err := models.CreateIssueDependency(ctx.User, issue, dep)
|
||||
if err != nil {
|
||||
if models.IsErrDependencyExists(err) {
|
||||
c.Flash.Error(c.Tr("repo.issues.dependency.add_error_dep_exists"))
|
||||
ctx.Flash.Error(ctx.Tr("repo.issues.dependency.add_error_dep_exists"))
|
||||
} else if models.IsErrCircularDependency(err) {
|
||||
c.Flash.Error(c.Tr("repo.issues.dependency.add_error_cannot_create_circular"))
|
||||
ctx.Flash.Error(ctx.Tr("repo.issues.dependency.add_error_cannot_create_circular"))
|
||||
} else {
|
||||
c.Handle(http.StatusInternalServerError, "CreateOrUpdateIssueDependency", err)
|
||||
ctx.Handle(http.StatusInternalServerError, "CreateOrUpdateIssueDependency", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/issues/%d", c.Repo.RepoLink, issueIndex)
|
||||
c.Redirect(url, http.StatusSeeOther)
|
||||
url := fmt.Sprintf("%s/issues/%d", ctx.Repo.RepoLink, issueIndex)
|
||||
ctx.Redirect(url, http.StatusSeeOther)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user