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

* bug fixed for deleted label in issue comment

* fix indent
This commit is contained in:
Lunny Xiao 2017-02-11 20:56:57 +08:00 committed by GitHub
parent 442145dbd3
commit 8a0be5e9f0
3 changed files with 21 additions and 13 deletions

View File

@ -214,12 +214,13 @@ func (c *Comment) LoadLabel() error {
has, err := x.ID(c.LabelID).Get(&label) has, err := x.ID(c.LabelID).Get(&label)
if err != nil { if err != nil {
return err return err
} else if !has { } else if has {
return ErrLabelNotExist{ c.Label = &label
LabelID: c.LabelID, } 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 return nil
} }

View File

@ -249,6 +249,11 @@ func DeleteLabel(repoID, labelID int64) error {
return err 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() return sess.Commit()
} }

View File

@ -145,14 +145,16 @@
</div> </div>
</div> </div>
{{else if eq .Type 7}} {{else if eq .Type 7}}
<div class="event"> {{if .Label}}
<span class="octicon octicon-primitive-dot"></span> <div class="event">
<a class="ui avatar image" href="{{.Poster.HomeLink}}"> <span class="octicon octicon-primitive-dot"></span>
<img src="{{.Poster.RelAvatarLink}}"> <a class="ui avatar image" href="{{.Poster.HomeLink}}">
</a> <img src="{{.Poster.RelAvatarLink}}">
<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a> </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> <span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</a>
</div> {{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}} {{else if eq .Type 8}}
<div class="event"> <div class="event">
<span class="octicon octicon-primitive-dot"></span> <span class="octicon octicon-primitive-dot"></span>