This commit is contained in:
Unknwon 2015-08-20 00:12:43 +08:00
parent 87f5ca8e1f
commit b846f195c1
2 changed files with 28 additions and 15 deletions

View File

@ -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)
}

View File

@ -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,