diff options
author | Justin Nuß <nuss.justin@gmail.com> | 2014-07-23 21:24:24 +0200 |
---|---|---|
committer | Justin Nuß <nuss.justin@gmail.com> | 2014-07-23 21:24:24 +0200 |
commit | 34304e6a0c9a3904b999e3ae1fcc9e6518d3f026 (patch) | |
tree | b5b225396138e7fd68bff0f4e8f5123e4e148883 /models | |
parent | 4617bef8954deeef5bd2ba36d84aba3b05a4dd83 (diff) | |
download | gitea-34304e6a0c9a3904b999e3ae1fcc9e6518d3f026.tar.gz gitea-34304e6a0c9a3904b999e3ae1fcc9e6518d3f026.zip |
WIP: Allow attachments for issues, not only comments
Diffstat (limited to 'models')
-rw-r--r-- | models/issue.go | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/models/issue.go b/models/issue.go index 90ef287cec..c0f2da2f2b 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 } |