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
|
// 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) {
|
func CreateIssueDependency(userID, issueID int64, depID int64) (err error, exists bool, depExists bool) {
|
||||||
err = x.Sync(new(IssueDependency))
|
err = x.Sync(new(IssueDependency))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -28,18 +28,24 @@ func AddDependency(c *context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
err, exists, depExists := models.CreateIssueDependency(c.User.ID, issue.ID, dep);
|
// Check if issue and dependency is the same
|
||||||
if err != nil {
|
if dep == issueIndex{
|
||||||
c.Handle(http.StatusInternalServerError, "CreateOrUpdateIssueDependency", err)
|
c.Flash.Error("You cannot make an issue depend on itself!")
|
||||||
return
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
if !depExists {
|
err, exists, depExists := models.CreateIssueDependency(c.User.ID, issue.ID, dep);
|
||||||
c.Flash.Error("Dependend issue does not exist!")
|
if err != nil {
|
||||||
}
|
c.Handle(http.StatusInternalServerError, "CreateOrUpdateIssueDependency", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if exists {
|
if !depExists {
|
||||||
c.Flash.Error("Dependency already exists!")
|
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)
|
url := fmt.Sprintf("%s/issues/%d", c.Repo.RepoLink, issueIndex)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user