aboutsummaryrefslogtreecommitdiff
path: root/models
diff options
context:
space:
mode:
Diffstat (limited to 'models')
-rw-r--r--models/issue.go18
1 files changed, 15 insertions, 3 deletions
diff --git a/models/issue.go b/models/issue.go
index 90ef287c..c0f2da2f 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -96,6 +96,11 @@ func (i *Issue) GetAssignee() (err error) {
return err
}
+func (i *Issue) Attachments() []*Attachment {
+ a, _ := GetAttachmentsForIssue(i.Id)
+ return a
+}
+
func (i *Issue) AfterDelete() {
_, err := DeleteAttachmentsByIssue(i.Id, true)
@@ -871,8 +876,9 @@ func GetIssueComments(issueId int64) ([]Comment, error) {
}
// Attachments returns the attachments for this comment.
-func (c *Comment) Attachments() ([]*Attachment, error) {
- return GetAttachmentsByComment(c.Id)
+func (c *Comment) Attachments() []*Attachment {
+ a, _ := GetAttachmentsByComment(c.Id)
+ return a
}
func (c *Comment) AfterDelete() {
@@ -928,10 +934,16 @@ func GetAttachmentById(id int64) (*Attachment, error) {
return m, nil
}
+func GetAttachmentsForIssue(issueId int64) ([]*Attachment, error) {
+ attachments := make([]*Attachment, 0, 10)
+ err := x.Where("issue_id = ?", issueId).Where("comment_id = 0").Find(&attachments)
+ return attachments, err
+}
+
// GetAttachmentsByIssue returns a list of attachments for the given issue
func GetAttachmentsByIssue(issueId int64) ([]*Attachment, error) {
attachments := make([]*Attachment, 0, 10)
- err := x.Where("issue_id = ?", issueId).Find(&attachments)
+ err := x.Where("issue_id = ?", issueId).Where("comment_id > 0").Find(&attachments)
return attachments, err
}