summaryrefslogtreecommitdiffstats
path: root/models/issue.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2015-08-20 04:31:28 +0800
committerUnknwon <u@gogs.io>2015-08-20 04:31:28 +0800
commit371572cf5f853211fb11bb28bc41658119d3e247 (patch)
tree68530957b87dbc2f659d4a155bbec41bb557c033 /models/issue.go
parentf114f7874303d249b2956c894b1a90b042430acf (diff)
downloadgitea-371572cf5f853211fb11bb28bc41658119d3e247.tar.gz
gitea-371572cf5f853211fb11bb28bc41658119d3e247.zip
allow edit issue and comment
Diffstat (limited to 'models/issue.go')
-rw-r--r--models/issue.go31
1 files changed, 21 insertions, 10 deletions
diff --git a/models/issue.go b/models/issue.go
index d8c4809f11..f1ae400a05 100644
--- a/models/issue.go
+++ b/models/issue.go
@@ -1363,6 +1363,14 @@ func (c *Comment) AfterSet(colName string, _ xorm.Cell) {
}
}
+func (c *Comment) AfterDelete() {
+ _, err := DeleteAttachmentsByComment(c.ID, true)
+
+ if err != nil {
+ log.Info("Could not delete files for comment %d on issue #%d: %s", c.ID, c.IssueID, err)
+ }
+}
+
// HashTag returns unique hash tag for comment.
func (c *Comment) HashTag() string {
return "issuecomment-" + com.ToStr(c.ID)
@@ -1473,11 +1481,16 @@ func CreateIssueComment(doer *User, repo *Repository, issue *Issue, content stri
return CreateComment(doer, repo, issue, 0, 0, COMMENT_TYPE_COMMENT, content, attachments)
}
-// GetCommentById returns the comment with the given id
-func GetCommentById(id int64) (*Comment, error) {
+// GetCommentByID returns the comment by given ID.
+func GetCommentByID(id int64) (*Comment, error) {
c := new(Comment)
- _, err := x.Id(id).Get(c)
- return c, err
+ has, err := x.Id(id).Get(c)
+ if err != nil {
+ return nil, err
+ } else if !has {
+ return nil, ErrCommentNotExist{id}
+ }
+ return c, nil
}
// GetCommentsByIssueID returns all comments of issue by given ID.
@@ -1486,12 +1499,10 @@ func GetCommentsByIssueID(issueID int64) ([]*Comment, error) {
return comments, x.Where("issue_id=?", issueID).Asc("created").Find(&comments)
}
-func (c *Comment) AfterDelete() {
- _, err := DeleteAttachmentsByComment(c.ID, true)
-
- if err != nil {
- log.Info("Could not delete files for comment %d on issue #%d: %s", c.ID, c.IssueID, err)
- }
+// UpdateComment updates information of comment.
+func UpdateComment(c *Comment) error {
+ _, err := x.Id(c.ID).AllCols().Update(c)
+ return err
}
// Attachment represent a attachment of issue/comment/release.