Bug fixed for deleted label in issue comment (#904)
* bug fixed for deleted label in issue comment * fix indent
This commit is contained in:
parent
442145dbd3
commit
8a0be5e9f0
|
@ -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{
|
|
||||||
LabelID: c.LabelID,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
c.Label = &label
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -145,6 +145,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{else if eq .Type 7}}
|
{{else if eq .Type 7}}
|
||||||
|
{{if .Label}}
|
||||||
<div class="event">
|
<div class="event">
|
||||||
<span class="octicon octicon-primitive-dot"></span>
|
<span class="octicon octicon-primitive-dot"></span>
|
||||||
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
|
<a class="ui avatar image" href="{{.Poster.HomeLink}}">
|
||||||
|
@ -153,6 +154,7 @@
|
||||||
<span class="text grey"><a href="{{.Poster.HomeLink}}">{{.Poster.Name}}</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>
|
{{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>
|
</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>
|
||||||
|
|
Loading…
Reference in a new issue