Browse Source

Fixed #200

pull/210/head
Unknown 11 years ago
parent
commit
87854c95a9
  1. 4
      models/issue.go
  2. 10
      routers/repo/issue.go

4
models/issue.go

@ -473,6 +473,10 @@ func NewLabel(l *Label) error {
// GetLabelById returns a label by given ID. // GetLabelById returns a label by given ID.
func GetLabelById(id int64) (*Label, error) { func GetLabelById(id int64) (*Label, error) {
if id <= 0 {
return nil, ErrLabelNotExist
}
l := &Label{Id: id} l := &Label{Id: id}
has, err := orm.Get(l) has, err := orm.Get(l)
if err != nil { if err != nil {

10
routers/repo/issue.go

@ -742,7 +742,15 @@ func UpdateLabel(ctx *middleware.Context, params martini.Params, form auth.Creat
} }
func DeleteLabel(ctx *middleware.Context) { func DeleteLabel(ctx *middleware.Context) {
strIds := strings.Split(ctx.Query("remove"), ",") removes := ctx.Query("remove")
if len(strings.TrimSpace(removes)) == 0 {
ctx.JSON(200, map[string]interface{}{
"ok": true,
})
return
}
strIds := strings.Split(removes, ",")
for _, strId := range strIds { for _, strId := range strIds {
if err := models.DeleteLabel(ctx.Repo.Repository.Id, strId); err != nil { if err := models.DeleteLabel(ctx.Repo.Repository.Id, strId); err != nil {
ctx.Handle(500, "issue.DeleteLabel(DeleteLabel)", err) ctx.Handle(500, "issue.DeleteLabel(DeleteLabel)", err)

Loading…
Cancel
Save