From b846f195c11808d3ed302c4d854d5eb700fdf1dc Mon Sep 17 00:00:00 2001 From: Unknwon Date: Thu, 20 Aug 2015 00:12:43 +0800 Subject: [PATCH] work #1500 --- models/action.go | 9 +++++++++ models/issue.go | 34 +++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/models/action.go b/models/action.go index de7f93a973..0e336c372b 100644 --- a/models/action.go +++ b/models/action.go @@ -14,6 +14,8 @@ import ( "time" "unicode" + "github.com/go-xorm/xorm" + "github.com/gogits/gogs/modules/base" "github.com/gogits/gogs/modules/git" "github.com/gogits/gogs/modules/log" @@ -77,6 +79,13 @@ type Action struct { Created time.Time `xorm:"created"` } +func (a *Action) AfterSet(colName string, _ xorm.Cell) { + switch colName { + case "created": + a.Created = a.Created.UTC() + } +} + func (a Action) GetOpType() int { return int(a.OpType) } diff --git a/models/issue.go b/models/issue.go index 1e49fda754..cd22f1a5a1 100644 --- a/models/issue.go +++ b/models/issue.go @@ -60,11 +60,6 @@ type Issue struct { Comments []*Comment `xorm:"-"` } -// HashTag returns unique hash tag for issue. -func (i *Issue) HashTag() string { - return "issue-" + com.ToStr(i.ID) -} - func (i *Issue) AfterSet(colName string, _ xorm.Cell) { var err error switch colName { @@ -97,9 +92,16 @@ func (i *Issue) AfterSet(colName string, _ xorm.Cell) { if err != nil { log.Error(3, "GetUserByID[%d]: %v", i.ID, err) } + case "created": + i.Created = i.Created.UTC() } } +// HashTag returns unique hash tag for issue. +func (i *Issue) HashTag() string { + return "issue-" + com.ToStr(i.ID) +} + // IsPoster returns true if given user by ID is the poster. func (i *Issue) IsPoster(uid int64) bool { return i.PosterID == uid @@ -1337,16 +1339,6 @@ type Comment struct { ShowTag CommentTag `xorm:"-"` } -// HashTag returns unique hash tag for comment. -func (c *Comment) HashTag() string { - return "issuecomment-" + com.ToStr(c.ID) -} - -// EventTag returns unique event hash tag for comment. -func (c *Comment) EventTag() string { - return "event-" + com.ToStr(c.ID) -} - func (c *Comment) AfterSet(colName string, _ xorm.Cell) { var err error switch colName { @@ -1366,9 +1358,21 @@ func (c *Comment) AfterSet(colName string, _ xorm.Cell) { log.Error(3, "GetUserByID[%d]: %v", c.ID, err) } } + case "created": + c.Created = c.Created.UTC() } } +// HashTag returns unique hash tag for comment. +func (c *Comment) HashTag() string { + return "issuecomment-" + com.ToStr(c.ID) +} + +// EventTag returns unique event hash tag for comment. +func (c *Comment) EventTag() string { + return "event-" + com.ToStr(c.ID) +} + func createComment(e *xorm.Session, u *User, repo *Repository, issue *Issue, commitID, line int64, cmtType CommentType, content string, uuids []string) (_ *Comment, err error) { comment := &Comment{ PosterID: u.Id,