diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2017-12-14 07:45:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-14 07:45:31 +0800 |
commit | f94c1b3943ebc4249e6240855c5414f735e8b25f (patch) | |
tree | 720895df7e78cd95e3803929332485b5619b611e /models | |
parent | b6d2243ac056be7997ef8d14be505873ce34a47e (diff) | |
download | gitea-f94c1b3943ebc4249e6240855c5414f735e8b25f.tar.gz gitea-f94c1b3943ebc4249e6240855c5414f735e8b25f.zip |
Improvements for supporting UI Location (#3146)
* improvements for supporting UI Location
* improved the comment
Diffstat (limited to 'models')
-rw-r--r-- | models/issue_tracked_time.go | 3 | ||||
-rw-r--r-- | models/ssh_key.go | 22 | ||||
-rw-r--r-- | models/user.go | 8 |
3 files changed, 14 insertions, 19 deletions
diff --git a/models/issue_tracked_time.go b/models/issue_tracked_time.go index 3b2360f68f..c314f8f44f 100644 --- a/models/issue_tracked_time.go +++ b/models/issue_tracked_time.go @@ -7,6 +7,7 @@ package models import ( "time" + "code.gitea.io/gitea/modules/setting" api "code.gitea.io/sdk/gitea" "github.com/go-xorm/builder" @@ -24,7 +25,7 @@ type TrackedTime struct { // AfterLoad is invoked from XORM after setting the values of all fields of this object. func (t *TrackedTime) AfterLoad() { - t.Created = time.Unix(t.CreatedUnix, 0).Local() + t.Created = time.Unix(t.CreatedUnix, 0).In(setting.UILocation) } // APIFormat converts TrackedTime to API format diff --git a/models/ssh_key.go b/models/ssh_key.go index ea313f147a..4d276ebeb7 100644 --- a/models/ssh_key.go +++ b/models/ssh_key.go @@ -600,20 +600,16 @@ type DeployKey struct { Fingerprint string Content string `xorm:"-"` - Created time.Time `xorm:"-"` - CreatedUnix int64 `xorm:"created"` - Updated time.Time `xorm:"-"` - UpdatedUnix int64 `xorm:"updated"` - HasRecentActivity bool `xorm:"-"` - HasUsed bool `xorm:"-"` + CreatedUnix util.TimeStamp `xorm:"created"` + UpdatedUnix util.TimeStamp `xorm:"updated"` + HasRecentActivity bool `xorm:"-"` + HasUsed bool `xorm:"-"` } // AfterLoad is invoked from XORM after setting the values of all fields of this object. func (key *DeployKey) AfterLoad() { - key.Created = time.Unix(key.CreatedUnix, 0).Local() - key.Updated = time.Unix(key.UpdatedUnix, 0).Local() - key.HasUsed = key.Updated.After(key.Created) - key.HasRecentActivity = key.Updated.Add(7 * 24 * time.Hour).After(time.Now()) + key.HasUsed = key.UpdatedUnix > key.CreatedUnix + key.HasRecentActivity = key.UpdatedUnix.AddDuration(7*24*time.Hour) > util.TimeStampNow() } // GetContent gets associated public key content. @@ -740,6 +736,12 @@ func GetDeployKeyByRepo(keyID, repoID int64) (*DeployKey, error) { return key, nil } +// UpdateDeployKeyCols updates deploy key information in the specified columns. +func UpdateDeployKeyCols(key *DeployKey, cols ...string) error { + _, err := x.ID(key.ID).Cols(cols...).Update(key) + return err +} + // UpdateDeployKey updates deploy key information. func UpdateDeployKey(key *DeployKey) error { _, err := x.ID(key.ID).AllCols().Update(key) diff --git a/models/user.go b/models/user.go index 0a2e2e9f92..fa5dc73deb 100644 --- a/models/user.go +++ b/models/user.go @@ -151,14 +151,6 @@ func (u *User) UpdateDiffViewStyle(style string) error { return UpdateUserCols(u, "diff_view_style") } -/* -// AfterLoad is invoked from XORM after setting the values of all fields of this object. -func (u *User) AfterLoad() { - u.Created = time.Unix(u.CreatedUnix, 0).Local() - u.Updated = time.Unix(u.UpdatedUnix, 0).Local() - u.LastLogin = time.Unix(u.LastLoginUnix, 0).Local() -}*/ - // getEmail returns an noreply email, if the user has set to keep his // email address private, otherwise the primary email address. func (u *User) getEmail() string { |