summaryrefslogtreecommitdiffstats
path: root/models/issue.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-07-24 23:13:42 +0800
committerUnknwon <u@gogs.io>2015-07-24 23:13:42 +0800
commitdc4aab9925b46f8ad4b18f7926e2904163c1c5b5 (patch)
tree77bb65a5407f7daddf2166054d0abf757dc32715 /models/issue.go
parent3426ae42b3eadd5acd43e20470a8f1dd45bb55b0 (diff)
downloadgitea-dc4aab9925b46f8ad4b18f7926e2904163c1c5b5.tar.gz
gitea-dc4aab9925b46f8ad4b18f7926e2904163c1c5b5.zip
UI: CURD labels
- fix update lable break connection with repository
Diffstat (limited to 'models/issue.go')
-rw-r--r--models/issue.go18
1 files changed, 7 insertions, 11 deletions
diff --git a/models/issue.go b/models/issue.go
index 4ddf5725f9..f62bc1e096 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -242,10 +242,9 @@ const (
)
// GetIssuesByLabel returns a list of issues by given label and repository.
-func GetIssuesByLabel(repoId int64, label string) ([]*Issue, error) {
+func GetIssuesByLabel(repoID, labelID int64) ([]*Issue, error) {
issues := make([]*Issue, 0, 10)
- err := x.Where("repo_id=?", repoId).And("label_ids like '%$" + label + "|%'").Find(&issues)
- return issues, err
+ return issues, x.Where("repo_id=?", repoID).And("label_ids like '%$" + com.ToStr(labelID) + "|%'").Find(&issues)
}
// GetIssueCountByPoster returns number of issues of repository by poster.
@@ -577,9 +576,8 @@ func UpdateLabel(l *Label) error {
}
// DeleteLabel delete a label of given repository.
-func DeleteLabel(repoId int64, strId string) error {
- id, _ := com.StrTo(strId).Int64()
- l, err := GetLabelById(id)
+func DeleteLabel(repoID, labelID int64) error {
+ l, err := GetLabelById(labelID)
if err != nil {
if err == ErrLabelNotExist {
return nil
@@ -587,27 +585,25 @@ func DeleteLabel(repoId int64, strId string) error {
return err
}
- issues, err := GetIssuesByLabel(repoId, strId)
+ issues, err := GetIssuesByLabel(repoID, labelID)
if err != nil {
return err
}
sess := x.NewSession()
- defer sess.Close()
+ defer sessionRelease(sess)
if err = sess.Begin(); err != nil {
return err
}
for _, issue := range issues {
- issue.LabelIds = strings.Replace(issue.LabelIds, "$"+strId+"|", "", -1)
+ issue.LabelIds = strings.Replace(issue.LabelIds, "$"+com.ToStr(labelID)+"|", "", -1)
if _, err = sess.Id(issue.ID).AllCols().Update(issue); err != nil {
- sess.Rollback()
return err
}
}
if _, err = sess.Delete(l); err != nil {
- sess.Rollback()
return err
}
return sess.Commit()