Added method to prevent making an issue dependent on itself
Signed-off-by: Konrad <konrad@kola-entertainments.de>
This commit is contained in:
parent
6859c47397
commit
39f7f92b84
|
|
@ -44,7 +44,6 @@ func (iw *IssueDependency) BeforeUpdate() {
|
|||
}
|
||||
|
||||
// CreateIssueDependency creates a new dependency for an issue
|
||||
// TODO: prevent issues having itself as dependency
|
||||
func CreateIssueDependency(userID, issueID int64, depID int64) (err error, exists bool, depExists bool) {
|
||||
err = x.Sync(new(IssueDependency))
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -28,18 +28,24 @@ func AddDependency(c *context.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
err, exists, depExists := models.CreateIssueDependency(c.User.ID, issue.ID, dep);
|
||||
if err != nil {
|
||||
c.Handle(http.StatusInternalServerError, "CreateOrUpdateIssueDependency", err)
|
||||
return
|
||||
}
|
||||
// Check if issue and dependency is the same
|
||||
if dep == issueIndex{
|
||||
c.Flash.Error("You cannot make an issue depend on itself!")
|
||||
} else {
|
||||
|
||||
if !depExists {
|
||||
c.Flash.Error("Dependend issue does not exist!")
|
||||
}
|
||||
err, exists, depExists := models.CreateIssueDependency(c.User.ID, issue.ID, dep);
|
||||
if err != nil {
|
||||
c.Handle(http.StatusInternalServerError, "CreateOrUpdateIssueDependency", err)
|
||||
return
|
||||
}
|
||||
|
||||
if exists {
|
||||
c.Flash.Error("Dependency already exists!")
|
||||
if !depExists {
|
||||
c.Flash.Error("Dependend issue does not exist!")
|
||||
}
|
||||
|
||||
if exists {
|
||||
c.Flash.Error("Dependency already exists!")
|
||||
}
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/issues/%d", c.Repo.RepoLink, issueIndex)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user