Renamed "c" to "ctx" for consistency
This commit is contained in:
parent
2058f4e5c5
commit
5dc9c22972
|
|
@ -14,28 +14,24 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// RemoveDependency removes the dependency
|
// RemoveDependency removes the dependency
|
||||||
func RemoveDependency(c *context.Context) {
|
func RemoveDependency(ctx *context.Context) {
|
||||||
depID, err := strconv.ParseInt(c.Req.PostForm.Get("removeDependencyID"), 10, 64)
|
depID := ctx.QueryInt64("removeDependencyID")
|
||||||
if err != nil {
|
|
||||||
c.Handle(http.StatusBadRequest, "issue ID is not int", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
issueIndex := c.ParamsInt64("index")
|
issueIndex := ctx.ParamsInt64("index")
|
||||||
issue, err := models.GetIssueByIndex(c.Repo.Repository.ID, issueIndex)
|
issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, issueIndex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Handle(http.StatusInternalServerError, "GetIssueByIndex", err)
|
ctx.Handle(http.StatusInternalServerError, "GetIssueByIndex", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the Repo is allowed to have dependencies
|
// Check if the Repo is allowed to have dependencies
|
||||||
if !c.Repo.CanCreateIssueDependencies(issue, c.User) {
|
if !ctx.Repo.CanCreateIssueDependencies(issue, ctx.User) {
|
||||||
c.Handle(404, "MustEnableIssueDependencies", nil)
|
ctx.Handle(404, "MustEnableIssueDependencies", nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dependency Type
|
// Dependency Type
|
||||||
depTypeStr := c.Req.PostForm.Get("dependencyType")
|
depTypeStr := ctx.Req.PostForm.Get("dependencyType")
|
||||||
|
|
||||||
var depType models.DependencyType
|
var depType models.DependencyType
|
||||||
|
|
||||||
|
|
@ -45,22 +41,22 @@ func RemoveDependency(c *context.Context) {
|
||||||
case "blocking":
|
case "blocking":
|
||||||
depType = models.DependencyTypeBlocking
|
depType = models.DependencyTypeBlocking
|
||||||
default:
|
default:
|
||||||
c.Handle(http.StatusBadRequest, "GetDependecyType", nil)
|
ctx.Handle(http.StatusBadRequest, "GetDependecyType", nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dependency
|
// Dependency
|
||||||
dep, err := models.GetIssueByID(depID)
|
dep, err := models.GetIssueByID(depID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Handle(http.StatusInternalServerError, "GetIssueByID", err)
|
ctx.Handle(http.StatusInternalServerError, "GetIssueByID", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = models.RemoveIssueDependency(c.User, issue, dep, depType); err != nil {
|
if err = models.RemoveIssueDependency(ctx.User, issue, dep, depType); err != nil {
|
||||||
c.Handle(http.StatusInternalServerError, "CreateOrUpdateIssueDependency", err)
|
ctx.Handle(http.StatusInternalServerError, "CreateOrUpdateIssueDependency", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
url := fmt.Sprintf("%s/issues/%d", c.Repo.RepoLink, issueIndex)
|
url := fmt.Sprintf("%s/issues/%d", ctx.Repo.RepoLink, issueIndex)
|
||||||
c.Redirect(url, http.StatusSeeOther)
|
ctx.Redirect(url, http.StatusSeeOther)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user