Switched to constants for dependency type
Signed-off-by: Konrad <konrad@kola-entertainments.de>
This commit is contained in:
parent
bccb37c08c
commit
0eaf0404cc
|
|
@ -20,6 +20,12 @@ type IssueDependency struct {
|
||||||
UpdatedUnix int64 `xorm:"updated"`
|
UpdatedUnix int64 `xorm:"updated"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Define Dependency Type Constants
|
||||||
|
const(
|
||||||
|
DependencyTypeBlockedBy int64 = 1
|
||||||
|
DependencyTypeBlocking int64 = 2
|
||||||
|
)
|
||||||
|
|
||||||
// CreateIssueDependency creates a new dependency for an issue
|
// CreateIssueDependency creates a new dependency for an issue
|
||||||
func CreateIssueDependency(user *User, issue, dep *Issue) (exists bool, err error) {
|
func CreateIssueDependency(user *User, issue, dep *Issue) (exists bool, err error) {
|
||||||
sess := x.NewSession()
|
sess := x.NewSession()
|
||||||
|
|
@ -84,14 +90,14 @@ func RemoveIssueDependency(user *User, issue *Issue, dep *Issue, depType int64)
|
||||||
// If it exists, remove it, otherwise show an error message
|
// If it exists, remove it, otherwise show an error message
|
||||||
if exists {
|
if exists {
|
||||||
|
|
||||||
if depType == 1 {
|
if depType == DependencyTypeBlockedBy {
|
||||||
_, err := x.Delete(&IssueDependency{IssueID: issue.ID, DependencyID: dep.ID})
|
_, err := x.Delete(&IssueDependency{IssueID: issue.ID, DependencyID: dep.ID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if depType == 2 {
|
if depType == DependencyTypeBlocking {
|
||||||
_, err := x.Delete(&IssueDependency{IssueID: dep.ID, DependencyID: issue.ID})
|
_, err := x.Delete(&IssueDependency{IssueID: dep.ID, DependencyID: issue.ID})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ func RemoveDependency(c *context.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if depType != 1 && depType != 2 {
|
if depType != models.DependencyTypeBlockedBy && depType != models.DependencyTypeBlocking {
|
||||||
c.Handle(http.StatusBadRequest, "GetDependecyType", nil)
|
c.Handle(http.StatusBadRequest, "GetDependecyType", nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user