Bug fixed for deleted label in issue comment (#904)

* bug fixed for deleted label in issue comment

* fix indent
tokarchuk/v1.17
Lunny Xiao 8 years ago committed by GitHub
parent 442145dbd3
commit 8a0be5e9f0
  1. 11
      models/issue_comment.go
  2. 5
      models/issue_label.go
  3. 18
      templates/repo/issue/view_content.tmpl

@ -214,12 +214,13 @@ func (c *Comment) LoadLabel() error {
has, err := x.ID(c.LabelID).Get(&label)
if err != nil {
return err
} else if !has {
return ErrLabelNotExist{
LabelID: c.LabelID,
}
} else if has {
c.Label = &label
} else {
// Ignore Label is deleted, but not clear this table
log.Warn("Commit %d cannot load label %d", c.ID, c.LabelID)
}
c.Label = &label
return nil
}

@ -249,6 +249,11 @@ func DeleteLabel(repoID, labelID int64) error {
return err
}
// Clear label id in comment table
if _, err = sess.Where("label_id = ?", labelID).Cols("label_id").Update(&Comment{}); err != nil {
return err
}
return sess.Commit()
}

@ -145,14 +145,16 @@
</div>
</div>
{{else if eq .Type 7}}
<div class="event">
<span class="octicon octicon-primitive-dot"></span>
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
<img src="{{.Poster.RelAvatarLink}}">
</a>
<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
{{if .Content}}{{$.i18n.Tr "repo.issues.add_label_at" .Label.ForegroundColor .Label.Color .Label.Name $createdStr | Safe}}{{else}}{{$.i18n.Tr "repo.issues.remove_label_at" .Label.ForegroundColor .Label.Color .Label.Name $createdStr | Safe}}{{end}}</span>
</div>
{{if .Label}}
<div class="event">
<span class="octicon octicon-primitive-dot"></span>
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
<img src="{{.Poster.RelAvatarLink}}">
</a>
<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
{{if .Content}}{{$.i18n.Tr "repo.issues.add_label_at" .Label.ForegroundColor .Label.Color .Label.Name $createdStr | Safe}}{{else}}{{$.i18n.Tr "repo.issues.remove_label_at" .Label.ForegroundColor .Label.Color .Label.Name $createdStr | Safe}}{{end}}</span>
</div>
{{end}}
{{else if eq .Type 8}}
<div class="event">
<span class="octicon octicon-primitive-dot"></span>

Loading…
Cancel
Save