Browse Source

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

* bug fixed for deleted label in issue comment

* fix indent
for-closed-social
Lunny Xiao 7 years ago
committed by GitHub
parent
commit
8a0be5e9f0
3 changed files with 21 additions and 13 deletions
  1. +6
    -5
      models/issue_comment.go
  2. +5
    -0
      models/issue_label.go
  3. +10
    -8
      templates/repo/issue/view_content.tmpl

+ 6
- 5
models/issue_comment.go View File

@ -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
}

+ 5
- 0
models/issue_label.go View File

@ -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()
}

+ 10
- 8
templates/repo/issue/view_content.tmpl View File

@ -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