Refactor User.Id to User.ID

tokarchuk/v1.17
Unknwon 8 years ago
parent 46e96c008c
commit 1f2e173a74
  1. 2
      README.md
  2. 4
      cmd/serve.go
  3. 2
      gogs.go
  4. 14
      models/access.go
  5. 20
      models/action.go
  6. 12
      models/issue.go
  7. 4
      models/issue_comment.go
  8. 2
      models/issue_mail.go
  9. 4
      models/login.go
  10. 8
      models/mail.go
  11. 46
      models/org.go
  12. 8
      models/org_team.go
  13. 6
      models/pull.go
  14. 28
      models/repo.go
  15. 2
      models/repo_collaboration.go
  16. 6
      models/ssh_key.go
  17. 6
      models/update.go
  18. 86
      models/user.go
  19. 6
      models/user_mail.go
  20. 2
      modules/context/context.go
  21. 6
      modules/context/org.go
  22. 6
      modules/context/repo.go
  23. 2
      routers/admin/repos.go
  24. 2
      routers/admin/users.go
  25. 6
      routers/api/v1/admin/org_team.go
  26. 2
      routers/api/v1/admin/user.go
  27. 2
      routers/api/v1/api.go
  28. 4
      routers/api/v1/convert/convert.go
  29. 2
      routers/api/v1/org/org.go
  30. 8
      routers/api/v1/repo/issue.go
  31. 22
      routers/api/v1/repo/repo.go
  32. 4
      routers/api/v1/user/app.go
  33. 4
      routers/api/v1/user/email.go
  34. 8
      routers/api/v1/user/follower.go
  35. 6
      routers/api/v1/user/key.go
  36. 4
      routers/api/v1/user/user.go
  37. 2
      routers/install.go
  38. 12
      routers/org/members.go
  39. 6
      routers/org/setting.go
  40. 10
      routers/org/teams.go
  41. 4
      routers/repo/http.go
  42. 24
      routers/repo/issue.go
  43. 10
      routers/repo/pull.go
  44. 2
      routers/repo/release.go
  45. 18
      routers/repo/repo.go
  46. 14
      routers/repo/setting.go
  47. 6
      routers/repo/webhook.go
  48. 8
      routers/user/auth.go
  49. 37
      routers/user/home.go
  50. 12
      routers/user/profile.go
  51. 20
      routers/user/setting.go
  52. 2
      templates/.VERSION
  53. 2
      templates/admin/org/list.tmpl
  54. 2
      templates/admin/user/edit.tmpl
  55. 4
      templates/admin/user/list.tmpl
  56. 4
      templates/org/home.tmpl
  57. 14
      templates/org/member/members.tmpl
  58. 4
      templates/org/team/members.tmpl
  59. 2
      templates/org/team/repositories.tmpl
  60. 6
      templates/org/team/sidebar.tmpl
  61. 6
      templates/org/team/teams.tmpl
  62. 6
      templates/repo/create.tmpl
  63. 2
      templates/repo/issue/list.tmpl
  64. 4
      templates/repo/issue/new_form.tmpl
  65. 14
      templates/repo/issue/view_content.tmpl
  66. 6
      templates/repo/issue/view_title.tmpl
  67. 6
      templates/repo/migrate.tmpl
  68. 8
      templates/repo/pulls/fork.tmpl
  69. 4
      templates/repo/settings/collaboration.tmpl
  70. 4
      templates/user/dashboard/navbar.tmpl
  71. 2
      templates/user/meta/header.tmpl
  72. 2
      templates/user/profile.tmpl

@ -3,7 +3,7 @@ Gogs - Go Git Service [![Build Status](https://travis-ci.org/gogits/gogs.svg?bra
![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true) ![](https://github.com/gogits/gogs/blob/master/public/img/gogs-large-resize.png?raw=true)
##### Current tip version: 0.9.52 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions) ##### Current tip version: 0.9.53 (see [Releases](https://github.com/gogits/gogs/releases) for binary versions)
| Web | UI | Preview | | Web | UI | Preview |
|:-------------:|:-------:|:-------:| |:-------------:|:-------:|:-------:|

@ -103,7 +103,7 @@ func handleUpdateTask(uuid string, user, repoUser *models.User, reponame string,
RefName: task.RefName, RefName: task.RefName,
OldCommitID: task.OldCommitID, OldCommitID: task.OldCommitID,
NewCommitID: task.NewCommitID, NewCommitID: task.NewCommitID,
PusherID: user.Id, PusherID: user.ID,
PusherName: user.Name, PusherName: user.Name,
RepoUserName: repoUser.Name, RepoUserName: repoUser.Name,
RepoName: reponame, RepoName: reponame,
@ -175,7 +175,7 @@ func runServ(c *cli.Context) error {
fail("Internal error", "Failed to get repository owner (%s): %v", username, err) fail("Internal error", "Failed to get repository owner (%s): %v", username, err)
} }
repo, err := models.GetRepositoryByName(repoUser.Id, reponame) repo, err := models.GetRepositoryByName(repoUser.ID, reponame)
if err != nil { if err != nil {
if models.IsErrRepoNotExist(err) { if models.IsErrRepoNotExist(err) {
fail(_ACCESS_DENIED_MESSAGE, "Repository does not exist: %s/%s", repoUser.Name, reponame) fail(_ACCESS_DENIED_MESSAGE, "Repository does not exist: %s/%s", repoUser.Name, reponame)

@ -17,7 +17,7 @@ import (
"github.com/gogits/gogs/modules/setting" "github.com/gogits/gogs/modules/setting"
) )
const APP_VER = "0.9.52.0723" const APP_VER = "0.9.53.0724"
func init() { func init() {
runtime.GOMAXPROCS(runtime.NumCPU()) runtime.GOMAXPROCS(runtime.NumCPU())

@ -67,11 +67,11 @@ func accessLevel(e Engine, u *User, repo *Repository) (AccessMode, error) {
return mode, nil return mode, nil
} }
if u.Id == repo.OwnerID { if u.ID == repo.OwnerID {
return ACCESS_MODE_OWNER, nil return ACCESS_MODE_OWNER, nil
} }
a := &Access{UserID: u.Id, RepoID: repo.ID} a := &Access{UserID: u.ID, RepoID: repo.ID}
if has, err := e.Get(a); !has || err != nil { if has, err := e.Get(a); !has || err != nil {
return mode, err return mode, err
} }
@ -97,7 +97,7 @@ func HasAccess(u *User, repo *Repository, testMode AccessMode) (bool, error) {
// GetRepositoryAccesses finds all repositories with their access mode where a user has access but does not own. // GetRepositoryAccesses finds all repositories with their access mode where a user has access but does not own.
func (u *User) GetRepositoryAccesses() (map[*Repository]AccessMode, error) { func (u *User) GetRepositoryAccesses() (map[*Repository]AccessMode, error) {
accesses := make([]*Access, 0, 10) accesses := make([]*Access, 0, 10)
if err := x.Find(&accesses, &Access{UserID: u.Id}); err != nil { if err := x.Find(&accesses, &Access{UserID: u.ID}); err != nil {
return nil, err return nil, err
} }
@ -113,7 +113,7 @@ func (u *User) GetRepositoryAccesses() (map[*Repository]AccessMode, error) {
} }
if err = repo.GetOwner(); err != nil { if err = repo.GetOwner(); err != nil {
return nil, err return nil, err
} else if repo.OwnerID == u.Id { } else if repo.OwnerID == u.ID {
continue continue
} }
repos[repo] = access.Mode repos[repo] = access.Mode
@ -124,7 +124,7 @@ func (u *User) GetRepositoryAccesses() (map[*Repository]AccessMode, error) {
// GetAccessibleRepositories finds all repositories where a user has access but does not own. // GetAccessibleRepositories finds all repositories where a user has access but does not own.
func (u *User) GetAccessibleRepositories() ([]*Repository, error) { func (u *User) GetAccessibleRepositories() ([]*Repository, error) {
accesses := make([]*Access, 0, 10) accesses := make([]*Access, 0, 10)
if err := x.Find(&accesses, &Access{UserID: u.Id}); err != nil { if err := x.Find(&accesses, &Access{UserID: u.ID}); err != nil {
return nil, err return nil, err
} }
@ -137,7 +137,7 @@ func (u *User) GetAccessibleRepositories() ([]*Repository, error) {
repoIDs = append(repoIDs, access.RepoID) repoIDs = append(repoIDs, access.RepoID)
} }
repos := make([]*Repository, 0, len(repoIDs)) repos := make([]*Repository, 0, len(repoIDs))
return repos, x.Where("owner_id != ?", u.Id).In("id", repoIDs).Desc("updated_unix").Find(&repos) return repos, x.Where("owner_id != ?", u.ID).In("id", repoIDs).Desc("updated_unix").Find(&repos)
} }
func maxAccessMode(modes ...AccessMode) AccessMode { func maxAccessMode(modes ...AccessMode) AccessMode {
@ -227,7 +227,7 @@ func (repo *Repository) recalculateTeamAccesses(e Engine, ignTeamID int64) (err
return fmt.Errorf("getMembers '%d': %v", t.ID, err) return fmt.Errorf("getMembers '%d': %v", t.ID, err)
} }
for _, m := range t.Members { for _, m := range t.Members {
accessMap[m.Id] = maxAccessMode(accessMap[m.Id], t.Authorize) accessMap[m.ID] = maxAccessMode(accessMap[m.ID], t.Authorize)
} }
} }

@ -184,7 +184,7 @@ func (a *Action) GetIssueContent() string {
func newRepoAction(e Engine, u *User, repo *Repository) (err error) { func newRepoAction(e Engine, u *User, repo *Repository) (err error) {
if err = notifyWatchers(e, &Action{ if err = notifyWatchers(e, &Action{
ActUserID: u.Id, ActUserID: u.ID,
ActUserName: u.Name, ActUserName: u.Name,
ActEmail: u.Email, ActEmail: u.Email,
OpType: ACTION_CREATE_REPO, OpType: ACTION_CREATE_REPO,
@ -193,7 +193,7 @@ func newRepoAction(e Engine, u *User, repo *Repository) (err error) {
RepoName: repo.Name, RepoName: repo.Name,
IsPrivate: repo.IsPrivate, IsPrivate: repo.IsPrivate,
}); err != nil { }); err != nil {
return fmt.Errorf("notify watchers '%d/%d': %v", u.Id, repo.ID, err) return fmt.Errorf("notify watchers '%d/%d': %v", u.ID, repo.ID, err)
} }
log.Trace("action.newRepoAction: %s/%s", u.Name, repo.Name) log.Trace("action.newRepoAction: %s/%s", u.Name, repo.Name)
@ -207,7 +207,7 @@ func NewRepoAction(u *User, repo *Repository) (err error) {
func renameRepoAction(e Engine, actUser *User, oldRepoName string, repo *Repository) (err error) { func renameRepoAction(e Engine, actUser *User, oldRepoName string, repo *Repository) (err error) {
if err = notifyWatchers(e, &Action{ if err = notifyWatchers(e, &Action{
ActUserID: actUser.Id, ActUserID: actUser.ID,
ActUserName: actUser.Name, ActUserName: actUser.Name,
ActEmail: actUser.Email, ActEmail: actUser.Email,
OpType: ACTION_RENAME_REPO, OpType: ACTION_RENAME_REPO,
@ -482,7 +482,7 @@ func CommitRepoAction(
refName := git.RefEndName(refFullName) refName := git.RefEndName(refFullName)
if err = NotifyWatchers(&Action{ if err = NotifyWatchers(&Action{
ActUserID: u.Id, ActUserID: u.ID,
ActUserName: userName, ActUserName: userName,
ActEmail: actEmail, ActEmail: actEmail,
OpType: opType, OpType: opType,
@ -506,7 +506,7 @@ func CommitRepoAction(
} }
payloadSender := &api.PayloadUser{ payloadSender := &api.PayloadUser{
UserName: pusher.Name, UserName: pusher.Name,
ID: pusher.Id, ID: pusher.ID,
AvatarUrl: pusher.AvatarLink(), AvatarUrl: pusher.AvatarLink(),
} }
@ -553,7 +553,7 @@ func CommitRepoAction(
func transferRepoAction(e Engine, actUser, oldOwner, newOwner *User, repo *Repository) (err error) { func transferRepoAction(e Engine, actUser, oldOwner, newOwner *User, repo *Repository) (err error) {
if err = notifyWatchers(e, &Action{ if err = notifyWatchers(e, &Action{
ActUserID: actUser.Id, ActUserID: actUser.ID,
ActUserName: actUser.Name, ActUserName: actUser.Name,
ActEmail: actUser.Email, ActEmail: actUser.Email,
OpType: ACTION_TRANSFER_REPO, OpType: ACTION_TRANSFER_REPO,
@ -563,12 +563,12 @@ func transferRepoAction(e Engine, actUser, oldOwner, newOwner *User, repo *Repos
IsPrivate: repo.IsPrivate, IsPrivate: repo.IsPrivate,
Content: path.Join(oldOwner.Name, repo.Name), Content: path.Join(oldOwner.Name, repo.Name),
}); err != nil { }); err != nil {
return fmt.Errorf("notify watchers '%d/%d': %v", actUser.Id, repo.ID, err) return fmt.Errorf("notify watchers '%d/%d': %v", actUser.ID, repo.ID, err)
} }
// Remove watch for organization. // Remove watch for organization.
if repo.Owner.IsOrganization() { if repo.Owner.IsOrganization() {
if err = watchRepo(e, repo.Owner.Id, repo.ID, false); err != nil { if err = watchRepo(e, repo.Owner.ID, repo.ID, false); err != nil {
return fmt.Errorf("watch repository: %v", err) return fmt.Errorf("watch repository: %v", err)
} }
} }
@ -584,7 +584,7 @@ func TransferRepoAction(actUser, oldOwner, newOwner *User, repo *Repository) err
func mergePullRequestAction(e Engine, actUser *User, repo *Repository, pull *Issue) error { func mergePullRequestAction(e Engine, actUser *User, repo *Repository, pull *Issue) error {
return notifyWatchers(e, &Action{ return notifyWatchers(e, &Action{
ActUserID: actUser.Id, ActUserID: actUser.ID,
ActUserName: actUser.Name, ActUserName: actUser.Name,
ActEmail: actUser.Email, ActEmail: actUser.Email,
OpType: ACTION_MERGE_PULL_REQUEST, OpType: ACTION_MERGE_PULL_REQUEST,
@ -610,7 +610,7 @@ func GetFeeds(ctxUserID, userID, offset int64, isProfile bool) ([]*Action, error
if isProfile { if isProfile {
sess.And("is_private=?", false).And("act_user_id=?", ctxUserID) sess.And("is_private=?", false).And("act_user_id=?", ctxUserID)
} else if ctxUserID != -1 { } else if ctxUserID != -1 {
ctxUser := &User{Id: ctxUserID} ctxUser := &User{ID: ctxUserID}
if err := ctxUser.GetUserRepositories(userID); err != nil { if err := ctxUser.GetUserRepositories(userID); err != nil {
return nil, err return nil, err
} }

@ -336,7 +336,7 @@ func newIssue(e *xorm.Session, repo *Repository, issue *Issue, labelIDs []int64,
if issue.AssigneeID > 0 { if issue.AssigneeID > 0 {
// Silently drop invalid assignee // Silently drop invalid assignee
valid, err := hasAccess(e, &User{Id: issue.AssigneeID}, repo, ACCESS_MODE_WRITE) valid, err := hasAccess(e, &User{ID: issue.AssigneeID}, repo, ACCESS_MODE_WRITE)
if err != nil { if err != nil {
return fmt.Errorf("hasAccess: %v", err) return fmt.Errorf("hasAccess: %v", err)
} else if !valid { } else if !valid {
@ -428,7 +428,7 @@ func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string)
// Notify watchers. // Notify watchers.
act := &Action{ act := &Action{
ActUserID: issue.Poster.Id, ActUserID: issue.Poster.ID,
ActUserName: issue.Poster.Name, ActUserName: issue.Poster.Name,
ActEmail: issue.Poster.Email, ActEmail: issue.Poster.Email,
OpType: ACTION_CREATE_ISSUE, OpType: ACTION_CREATE_ISSUE,
@ -632,7 +632,7 @@ func newIssueUsers(e *xorm.Session, repo *Repository, issue *Issue) error {
isNeedAddPoster := true isNeedAddPoster := true
for _, u := range users { for _, u := range users {
iu.ID = 0 iu.ID = 0
iu.UID = u.Id iu.UID = u.ID
iu.IsPoster = iu.UID == issue.PosterID iu.IsPoster = iu.UID == issue.PosterID
if isNeedAddPoster && iu.IsPoster { if isNeedAddPoster && iu.IsPoster {
isNeedAddPoster = false isNeedAddPoster = false
@ -736,15 +736,15 @@ func UpdateIssueMentions(issueID int64, mentions []string) error {
ids := make([]int64, 0, len(mentions)) ids := make([]int64, 0, len(mentions))
for _, user := range users { for _, user := range users {
ids = append(ids, user.Id) ids = append(ids, user.ID)
if !user.IsOrganization() || user.NumMembers == 0 { if !user.IsOrganization() || user.NumMembers == 0 {
continue continue
} }
memberIDs := make([]int64, 0, user.NumMembers) memberIDs := make([]int64, 0, user.NumMembers)
orgUsers, err := GetOrgUsersByOrgID(user.Id) orgUsers, err := GetOrgUsersByOrgID(user.ID)
if err != nil { if err != nil {
return fmt.Errorf("GetOrgUsersByOrgID [%d]: %v", user.Id, err) return fmt.Errorf("GetOrgUsersByOrgID [%d]: %v", user.ID, err)
} }
for _, orgUser := range orgUsers { for _, orgUser := range orgUsers {

@ -140,7 +140,7 @@ func (cmt *Comment) MailParticipants(opType ActionType, issue *Issue) (err error
func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err error) { func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err error) {
comment := &Comment{ comment := &Comment{
Type: opts.Type, Type: opts.Type,
PosterID: opts.Doer.Id, PosterID: opts.Doer.ID,
Poster: opts.Doer, Poster: opts.Doer,
IssueID: opts.Issue.ID, IssueID: opts.Issue.ID,
CommitID: opts.CommitID, CommitID: opts.CommitID,
@ -155,7 +155,7 @@ func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err
// Compose comment action, could be plain comment, close or reopen issue/pull request. // Compose comment action, could be plain comment, close or reopen issue/pull request.
// This object will be used to notify watchers in the end of function. // This object will be used to notify watchers in the end of function.
act := &Action{ act := &Action{
ActUserID: opts.Doer.Id, ActUserID: opts.Doer.ID,
ActUserName: opts.Doer.Name, ActUserName: opts.Doer.Name,
ActEmail: opts.Doer.Email, ActEmail: opts.Doer.Email,
Content: fmt.Sprintf("%d|%s", opts.Issue.Index, strings.Split(opts.Content, "\n")[0]), Content: fmt.Sprintf("%d|%s", opts.Issue.Index, strings.Split(opts.Content, "\n")[0]),

@ -33,7 +33,7 @@ func mailIssueCommentToParticipants(issue *Issue, doer *User, mentions []string)
tos := make([]string, 0, len(watchers)) // List of email addresses. tos := make([]string, 0, len(watchers)) // List of email addresses.
names := make([]string, 0, len(watchers)) names := make([]string, 0, len(watchers))
for i := range watchers { for i := range watchers {
if watchers[i].UserID == doer.Id { if watchers[i].UserID == doer.ID {
continue continue
} }

@ -534,7 +534,7 @@ func UserSignIn(uname, passwd string) (*User, error) {
return u, nil return u, nil
} }
return nil, ErrUserNotExist{u.Id, u.Name} return nil, ErrUserNotExist{u.ID, u.Name}
default: default:
var source LoginSource var source LoginSource
@ -563,5 +563,5 @@ func UserSignIn(uname, passwd string) (*User, error) {
log.Warn("Failed to login '%s' via '%s': %v", uname, source.Name, err) log.Warn("Failed to login '%s' via '%s': %v", uname, source.Name, err)
} }
return nil, ErrUserNotExist{u.Id, u.Name} return nil, ErrUserNotExist{u.ID, u.Name}
} }

@ -71,7 +71,7 @@ func SendUserMail(c *macaron.Context, u *User, tpl base.TplName, code, subject,
} }
msg := mailer.NewMessage([]string{u.Email}, subject, body) msg := mailer.NewMessage([]string{u.Email}, subject, body)
msg.Info = fmt.Sprintf("UID: %d, %s", u.Id, info) msg.Info = fmt.Sprintf("UID: %d, %s", u.ID, info)
mailer.SendAsync(msg) mailer.SendAsync(msg)
} }
@ -99,7 +99,7 @@ func SendActivateEmailMail(c *macaron.Context, u *User, email *EmailAddress) {
} }
msg := mailer.NewMessage([]string{email.Email}, c.Tr("mail.activate_email"), body) msg := mailer.NewMessage([]string{email.Email}, c.Tr("mail.activate_email"), body)
msg.Info = fmt.Sprintf("UID: %d, activate email", u.Id) msg.Info = fmt.Sprintf("UID: %d, activate email", u.ID)
mailer.SendAsync(msg) mailer.SendAsync(msg)
} }
@ -116,7 +116,7 @@ func SendRegisterNotifyMail(c *macaron.Context, u *User) {
} }
msg := mailer.NewMessage([]string{u.Email}, c.Tr("mail.register_notify"), body) msg := mailer.NewMessage([]string{u.Email}, c.Tr("mail.register_notify"), body)
msg.Info = fmt.Sprintf("UID: %d, registration notify", u.Id) msg.Info = fmt.Sprintf("UID: %d, registration notify", u.ID)
mailer.SendAsync(msg) mailer.SendAsync(msg)
} }
@ -138,7 +138,7 @@ func SendCollaboratorMail(u, doer *User, repo *Repository) {
} }
msg := mailer.NewMessage([]string{u.Email}, subject, body) msg := mailer.NewMessage([]string{u.Email}, subject, body)
msg.Info = fmt.Sprintf("UID: %d, add collaborator", u.Id) msg.Info = fmt.Sprintf("UID: %d, add collaborator", u.ID)
mailer.SendAsync(msg) mailer.SendAsync(msg)
} }

@ -21,16 +21,16 @@ var (
// IsOwnedBy returns true if given user is in the owner team. // IsOwnedBy returns true if given user is in the owner team.
func (org *User) IsOwnedBy(uid int64) bool { func (org *User) IsOwnedBy(uid int64) bool {
return IsOrganizationOwner(org.Id, uid) return IsOrganizationOwner(org.ID, uid)
} }
// IsOrgMember returns true if given user is member of organization. // IsOrgMember returns true if given user is member of organization.
func (org *User) IsOrgMember(uid int64) bool { func (org *User) IsOrgMember(uid int64) bool {
return org.IsOrganization() && IsOrganizationMember(org.Id, uid) return org.IsOrganization() && IsOrganizationMember(org.ID, uid)
} }
func (org *User) getTeam(e Engine, name string) (*Team, error) { func (org *User) getTeam(e Engine, name string) (*Team, error) {
return getTeam(e, org.Id, name) return getTeam(e, org.ID, name)
} }
// GetTeam returns named team of organization. // GetTeam returns named team of organization.
@ -48,7 +48,7 @@ func (org *User) GetOwnerTeam() (*Team, error) {
} }
func (org *User) getTeams(e Engine) error { func (org *User) getTeams(e Engine) error {
return e.Where("org_id=?", org.Id).Find(&org.Teams) return e.Where("org_id=?", org.ID).Find(&org.Teams)
} }
// GetTeams returns all teams that belong to organization. // GetTeams returns all teams that belong to organization.
@ -58,7 +58,7 @@ func (org *User) GetTeams() error {
// GetMembers returns all members of organization. // GetMembers returns all members of organization.
func (org *User) GetMembers() error { func (org *User) GetMembers() error {
ous, err := GetOrgUsersByOrgID(org.Id) ous, err := GetOrgUsersByOrgID(org.ID)
if err != nil { if err != nil {
return err return err
} }
@ -75,16 +75,16 @@ func (org *User) GetMembers() error {
// AddMember adds new member to organization. // AddMember adds new member to organization.
func (org *User) AddMember(uid int64) error { func (org *User) AddMember(uid int64) error {
return AddOrgUser(org.Id, uid) return AddOrgUser(org.ID, uid)
} }
// RemoveMember removes member from organization. // RemoveMember removes member from organization.
func (org *User) RemoveMember(uid int64) error { func (org *User) RemoveMember(uid int64) error {
return RemoveOrgUser(org.Id, uid) return RemoveOrgUser(org.ID, uid)
} }
func (org *User) removeOrgRepo(e Engine, repoID int64) error { func (org *User) removeOrgRepo(e Engine, repoID int64) error {
return removeOrgRepo(e, org.Id, repoID) return removeOrgRepo(e, org.ID, repoID)
} }
// RemoveOrgRepo removes all team-repository relations of organization. // RemoveOrgRepo removes all team-repository relations of organization.
@ -126,8 +126,8 @@ func CreateOrganization(org, owner *User) (err error) {
// Add initial creator to organization and owner team. // Add initial creator to organization and owner team.
if _, err = sess.Insert(&OrgUser{ if _, err = sess.Insert(&OrgUser{
Uid: owner.Id, Uid: owner.ID,
OrgID: org.Id, OrgID: org.ID,
IsOwner: true, IsOwner: true,
NumTeams: 1, NumTeams: 1,
}); err != nil { }); err != nil {
@ -136,7 +136,7 @@ func CreateOrganization(org, owner *User) (err error) {
// Create default owner team. // Create default owner team.
t := &Team{ t := &Team{
OrgID: org.Id, OrgID: org.ID,
LowerName: strings.ToLower(OWNER_TEAM), LowerName: strings.ToLower(OWNER_TEAM),
Name: OWNER_TEAM, Name: OWNER_TEAM,
Authorize: ACCESS_MODE_OWNER, Authorize: ACCESS_MODE_OWNER,
@ -147,8 +147,8 @@ func CreateOrganization(org, owner *User) (err error) {
} }
if _, err = sess.Insert(&TeamUser{ if _, err = sess.Insert(&TeamUser{
Uid: owner.Id, Uid: owner.ID,
OrgID: org.Id, OrgID: org.ID,
TeamID: t.ID, TeamID: t.ID,
}); err != nil { }); err != nil {
return fmt.Errorf("insert team-user relation: %v", err) return fmt.Errorf("insert team-user relation: %v", err)
@ -204,9 +204,9 @@ func DeleteOrganization(org *User) (err error) {
} }
if err = deleteBeans(sess, if err = deleteBeans(sess,
&Team{OrgID: org.Id}, &Team{OrgID: org.ID},
&OrgUser{OrgID: org.Id}, &OrgUser{OrgID: org.ID},
&TeamUser{OrgID: org.Id}, &TeamUser{OrgID: org.ID},
); err != nil { ); err != nil {
return fmt.Errorf("deleteBeans: %v", err) return fmt.Errorf("deleteBeans: %v", err)
} }
@ -401,23 +401,23 @@ func RemoveOrgUser(orgId, uid int64) error {
} }
// Delete all repository accesses. // Delete all repository accesses.
access := &Access{UserID: u.Id} access := &Access{UserID: u.ID}
for _, repo := range org.Repos { for _, repo := range org.Repos {
access.RepoID = repo.ID access.RepoID = repo.ID
if _, err = sess.Delete(access); err != nil { if _, err = sess.Delete(access); err != nil {
return err return err
} else if err = watchRepo(sess, u.Id, repo.ID, false); err != nil { } else if err = watchRepo(sess, u.ID, repo.ID, false); err != nil {
return err return err
} }
} }
// Delete member in his/her teams. // Delete member in his/her teams.
teams, err := getUserTeams(sess, org.Id, u.Id) teams, err := getUserTeams(sess, org.ID, u.ID)
if err != nil { if err != nil {
return err return err
} }
for _, t := range teams { for _, t := range teams {
if err = removeTeamMember(sess, org.Id, t.ID, u.Id); err != nil { if err = removeTeamMember(sess, org.ID, t.ID, u.ID); err != nil {
return err return err
} }
} }
@ -444,7 +444,7 @@ func (org *User) GetUserRepositories(userID int64) (err error) {
teams := make([]*Team, 0, org.NumTeams) teams := make([]*Team, 0, org.NumTeams)
if err = x.Sql(`SELECT team.id FROM team if err = x.Sql(`SELECT team.id FROM team
INNER JOIN team_user ON team_user.team_id = team.id INNER JOIN team_user ON team_user.team_id = team.id
WHERE team_user.org_id = ? AND team_user.uid = ?`, org.Id, userID).Find(&teams); err != nil { WHERE team_user.org_id = ? AND team_user.uid = ?`, org.ID, userID).Find(&teams); err != nil {
return fmt.Errorf("get teams: %v", err) return fmt.Errorf("get teams: %v", err)
} }
@ -461,7 +461,7 @@ WHERE team_user.org_id = ? AND team_user.uid = ?`, org.Id, userID).Find(&teams);
if err = x.Sql(fmt.Sprintf(`SELECT repository.* FROM repository if err = x.Sql(fmt.Sprintf(`SELECT repository.* FROM repository
INNER JOIN team_repo ON team_repo.repo_id = repository.id INNER JOIN team_repo ON team_repo.repo_id = repository.id
WHERE (repository.owner_id = ? AND repository.is_private = ?) OR team_repo.team_id IN (%s) WHERE (repository.owner_id = ? AND repository.is_private = ?) OR team_repo.team_id IN (%s)
GROUP BY repository.id`, strings.Join(teamIDs, ",")), org.Id, false).Find(&repos); err != nil { GROUP BY repository.id`, strings.Join(teamIDs, ",")), org.ID, false).Find(&repos); err != nil {
return fmt.Errorf("get repositories: %v", err) return fmt.Errorf("get repositories: %v", err)
} }
org.Repos = repos org.Repos = repos
@ -479,7 +479,7 @@ func (org *User) GetUserTeams(userID int64) error {
if err := x.Sql(`SELECT team.* FROM team if err := x.Sql(`SELECT team.* FROM team
INNER JOIN team_user ON team_user.team_id = team.id INNER JOIN team_user ON team_user.team_id = team.id
WHERE team_user.org_id = ? AND team_user.uid = ?`, WHERE team_user.org_id = ? AND team_user.uid = ?`,
org.Id, userID).Find(&teams); err != nil { org.ID, userID).Find(&teams); err != nil {
return fmt.Errorf("get teams: %v", err) return fmt.Errorf("get teams: %v", err)
} }

@ -106,7 +106,7 @@ func (t *Team) addRepository(e Engine, repo *Repository) (err error) {
return fmt.Errorf("getMembers: %v", err) return fmt.Errorf("getMembers: %v", err)
} }
for _, u := range t.Members { for _, u := range t.Members {
if err = watchRepo(e, u.Id, repo.ID, true); err != nil { if err = watchRepo(e, u.ID, repo.ID, true); err != nil {
return fmt.Errorf("watchRepo: %v", err) return fmt.Errorf("watchRepo: %v", err)
} }
} }
@ -162,7 +162,7 @@ func (t *Team) removeRepository(e Engine, repo *Repository, recalculate bool) (e
continue continue
} }
if err = watchRepo(e, u.Id, repo.ID, false); err != nil { if err = watchRepo(e, u.ID, repo.ID, false); err != nil {
return err return err
} }
} }
@ -341,7 +341,7 @@ func DeleteTeam(t *Team) error {
} }
// Delete team-user. // Delete team-user.
if _, err = sess.Where("org_id=?", org.Id).Where("team_id=?", t.ID).Delete(new(TeamUser)); err != nil { if _, err = sess.Where("org_id=?", org.ID).Where("team_id=?", t.ID).Delete(new(TeamUser)); err != nil {
return err return err
} }
@ -538,7 +538,7 @@ func removeTeamMember(e Engine, orgID, teamID, uid int64) error {
// This must exist. // This must exist.
ou := new(OrgUser) ou := new(OrgUser)
_, err = e.Where("uid = ?", uid).And("org_id = ?", org.Id).Get(ou) _, err = e.Where("uid = ?", uid).And("org_id = ?", org.ID).Get(ou)
if err != nil { if err != nil {
return err return err
} }

@ -163,7 +163,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error
pr.HasMerged = true pr.HasMerged = true
pr.Merged = time.Now() pr.Merged = time.Now()
pr.MergerID = doer.Id pr.MergerID = doer.ID
if _, err = sess.Id(pr.ID).AllCols().Update(pr); err != nil { if _, err = sess.Id(pr.ID).AllCols().Update(pr); err != nil {
return fmt.Errorf("update pull request: %v", err) return fmt.Errorf("update pull request: %v", err)
} }
@ -245,7 +245,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error
}, },
Sender: &api.PayloadUser{ Sender: &api.PayloadUser{
UserName: doer.Name, UserName: doer.Name,
ID: doer.Id, ID: doer.ID,
AvatarUrl: setting.AppUrl + doer.RelAvatarLink(), AvatarUrl: setting.AppUrl + doer.RelAvatarLink(),
}, },
} }
@ -332,7 +332,7 @@ func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []str
// Notify watchers. // Notify watchers.
act := &Action{ act := &Action{
ActUserID: pull.Poster.Id, ActUserID: pull.Poster.ID,
ActUserName: pull.Poster.Name, ActUserName: pull.Poster.Name,
ActEmail: pull.Poster.Email, ActEmail: pull.Poster.Email,
OpType: ACTION_CREATE_PULL_REQUEST, OpType: ACTION_CREATE_PULL_REQUEST,

@ -476,7 +476,7 @@ func (repo *Repository) ComposePayload() *api.PayloadRepo {
func isRepositoryExist(e Engine, u *User, repoName string) (bool, error) { func isRepositoryExist(e Engine, u *User, repoName string) (bool, error) {
has, err := e.Get(&Repository{ has, err := e.Get(&Repository{
OwnerID: u.Id, OwnerID: u.ID,
LowerName: strings.ToLower(repoName), LowerName: strings.ToLower(repoName),
}) })
return has && com.IsDir(RepoPath(u.Name, repoName)), err return has && com.IsDir(RepoPath(u.Name, repoName)), err
@ -958,7 +958,7 @@ func createRepository(e *xorm.Session, u *User, repo *Repository) (err error) {
} }
} }
if err = watchRepo(e, u.Id, repo.ID, true); err != nil { if err = watchRepo(e, u.ID, repo.ID, true); err != nil {
return fmt.Errorf("watchRepo: %v", err) return fmt.Errorf("watchRepo: %v", err)
} else if err = newRepoAction(e, u, repo); err != nil { } else if err = newRepoAction(e, u, repo); err != nil {
return fmt.Errorf("newRepoAction: %v", err) return fmt.Errorf("newRepoAction: %v", err)
@ -974,7 +974,7 @@ func CreateRepository(u *User, opts CreateRepoOptions) (_ *Repository, err error
} }
repo := &Repository{ repo := &Repository{
OwnerID: u.Id, OwnerID: u.ID,
Owner: u, Owner: u,
Name: opts.Name, Name: opts.Name,
LowerName: strings.ToLower(opts.Name), LowerName: strings.ToLower(opts.Name),
@ -1093,7 +1093,7 @@ func TransferOwnership(u *User, newOwnerName string, repo *Repository) error {
// Note: we have to set value here to make sure recalculate accesses is based on // Note: we have to set value here to make sure recalculate accesses is based on
// new owner. // new owner.
repo.OwnerID = newOwner.Id repo.OwnerID = newOwner.ID
repo.Owner = newOwner repo.Owner = newOwner
// Update repository. // Update repository.
@ -1110,10 +1110,10 @@ func TransferOwnership(u *User, newOwnerName string, repo *Repository) error {
// Dummy object. // Dummy object.
collaboration := &Collaboration{RepoID: repo.ID} collaboration := &Collaboration{RepoID: repo.ID}
for _, c := range collaborators { for _, c := range collaborators {
collaboration.UserID = c.Id collaboration.UserID = c.ID
if c.Id == newOwner.Id || newOwner.IsOrgMember(c.Id) { if c.ID == newOwner.ID || newOwner.IsOrgMember(c.ID) {
if _, err = sess.Delete(collaboration); err != nil { if _, err = sess.Delete(collaboration); err != nil {
return fmt.Errorf("remove collaborator '%d': %v", c.Id, err) return fmt.Errorf("remove collaborator '%d': %v", c.ID, err)
} }
} }
} }
@ -1154,13 +1154,13 @@ func TransferOwnership(u *User, newOwnerName string, repo *Repository) error {
} }
// Update repository count. // Update repository count.
if _, err = sess.Exec("UPDATE `user` SET num_repos=num_repos+1 WHERE id=?", newOwner.Id); err != nil { if _, err = sess.Exec("UPDATE `user` SET num_repos=num_repos+1 WHERE id=?", newOwner.ID); err != nil {
return fmt.Errorf("increase new owner repository count: %v", err) return fmt.Errorf("increase new owner repository count: %v", err)
} else if _, err = sess.Exec("UPDATE `user` SET num_repos=num_repos-1 WHERE id=?", owner.Id); err != nil { } else if _, err = sess.Exec("UPDATE `user` SET num_repos=num_repos-1 WHERE id=?", owner.ID); err != nil {
return fmt.Errorf("decrease old owner repository count: %v", err) return fmt.Errorf("decrease old owner repository count: %v", err)
} }
if err = watchRepo(sess, newOwner.Id, repo.ID, true); err != nil { if err = watchRepo(sess, newOwner.ID, repo.ID, true); err != nil {
return fmt.Errorf("watchRepo: %v", err) return fmt.Errorf("watchRepo: %v", err)
} else if err = transferRepoAction(sess, u, owner, newOwner, repo); err != nil { } else if err = transferRepoAction(sess, u, owner, newOwner, repo); err != nil {
return fmt.Errorf("transferRepoAction: %v", err) return fmt.Errorf("transferRepoAction: %v", err)
@ -1200,7 +1200,7 @@ func ChangeRepositoryName(u *User, oldRepoName, newRepoName string) (err error)
return ErrRepoAlreadyExist{u.Name, newRepoName} return ErrRepoAlreadyExist{u.Name, newRepoName}
} }
repo, err := GetRepositoryByName(u.Id, oldRepoName) repo, err := GetRepositoryByName(u.ID, oldRepoName)
if err != nil { if err != nil {
return fmt.Errorf("GetRepositoryByName: %v", err) return fmt.Errorf("GetRepositoryByName: %v", err)
} }
@ -1414,7 +1414,7 @@ func GetRepositoryByRef(ref string) (*Repository, error) {
return nil, err return nil, err
} }
return GetRepositoryByName(user.Id, repoName) return GetRepositoryByName(user.ID, repoName)
} }
// GetRepositoryByName returns the repository by given name under user if exists. // GetRepositoryByName returns the repository by given name under user if exists.
@ -1467,7 +1467,7 @@ func GetRecentUpdatedRepositories(page, pageSize int) (repos []*Repository, err
} }
func getRepositoryCount(e Engine, u *User) (int64, error) { func getRepositoryCount(e Engine, u *User) (int64, error) {
return x.Count(&Repository{OwnerID: u.Id}) return x.Count(&Repository{OwnerID: u.ID})
} }
// GetRepositoryCount returns the total number of repositories of user. // GetRepositoryCount returns the total number of repositories of user.
@ -2025,7 +2025,7 @@ func HasForkedRepo(ownerID, repoID int64) (*Repository, bool) {
func ForkRepository(u *User, oldRepo *Repository, name, desc string) (_ *Repository, err error) { func ForkRepository(u *User, oldRepo *Repository, name, desc string) (_ *Repository, err error) {
repo := &Repository{ repo := &Repository{
OwnerID: u.Id, OwnerID: u.ID,
Owner: u, Owner: u,
Name: name, Name: name,
LowerName: strings.ToLower(name), LowerName: strings.ToLower(name),

@ -33,7 +33,7 @@ func (c *Collaboration) ModeI18nKey() string {
func (repo *Repository) AddCollaborator(u *User) error { func (repo *Repository) AddCollaborator(u *User) error {
collaboration := &Collaboration{ collaboration := &Collaboration{
RepoID: repo.ID, RepoID: repo.ID,
UserID: u.Id, UserID: u.ID,
} }
has, err := x.Get(collaboration) has, err := x.Get(collaboration)

@ -562,8 +562,8 @@ func DeletePublicKey(doer *User, id int64) (err error) {
} }
// Check if user has access to delete this key. // Check if user has access to delete this key.
if !doer.IsAdmin && doer.Id != key.OwnerID { if !doer.IsAdmin && doer.ID != key.OwnerID {
return ErrKeyAccessDenied{doer.Id, key.ID, "public"} return ErrKeyAccessDenied{doer.ID, key.ID, "public"}
} }
sess := x.NewSession() sess := x.NewSession()
@ -797,7 +797,7 @@ func DeleteDeployKey(doer *User, id int64) error {
if err != nil { if err != nil {
return fmt.Errorf("HasAccess: %v", err) return fmt.Errorf("HasAccess: %v", err)
} else if !yes { } else if !yes {
return ErrKeyAccessDenied{doer.Id, key.ID, "deploy"} return ErrKeyAccessDenied{doer.ID, key.ID, "deploy"}
} }
} }

@ -108,7 +108,7 @@ func PushUpdate(opts PushUpdateOptions) (err error) {
return fmt.Errorf("GetUserByName: %v", err) return fmt.Errorf("GetUserByName: %v", err)
} }
repo, err := GetRepositoryByName(repoUser.Id, opts.RepoName) repo, err := GetRepositoryByName(repoUser.ID, opts.RepoName)
if err != nil { if err != nil {
return fmt.Errorf("GetRepositoryByName: %v", err) return fmt.Errorf("GetRepositoryByName: %v", err)
} }
@ -133,7 +133,7 @@ func PushUpdate(opts PushUpdateOptions) (err error) {
} }
commit := &PushCommits{} commit := &PushCommits{}
if err = CommitRepoAction(opts.PusherID, repoUser.Id, opts.PusherName, actEmail, if err = CommitRepoAction(opts.PusherID, repoUser.ID, opts.PusherName, actEmail,
repo.ID, opts.RepoUserName, opts.RepoName, opts.RefName, commit, opts.OldCommitID, opts.NewCommitID); err != nil { repo.ID, opts.RepoUserName, opts.RepoName, opts.RefName, commit, opts.OldCommitID, opts.NewCommitID); err != nil {
return fmt.Errorf("CommitRepoAction (tag): %v", err) return fmt.Errorf("CommitRepoAction (tag): %v", err)
} }
@ -159,7 +159,7 @@ func PushUpdate(opts PushUpdateOptions) (err error) {
} }
} }
if err = CommitRepoAction(opts.PusherID, repoUser.Id, opts.PusherName, repoUser.Email, if err = CommitRepoAction(opts.PusherID, repoUser.ID, opts.PusherName, repoUser.Email,
repo.ID, opts.RepoUserName, opts.RepoName, opts.RefName, ListToPushCommits(l), repo.ID, opts.RepoUserName, opts.RepoName, opts.RefName, ListToPushCommits(l),
opts.OldCommitID, opts.NewCommitID); err != nil { opts.OldCommitID, opts.NewCommitID); err != nil {
return fmt.Errorf("CommitRepoAction (branch): %v", err) return fmt.Errorf("CommitRepoAction (branch): %v", err)

@ -52,7 +52,7 @@ var (
// User represents the object of individual and member of organization. // User represents the object of individual and member of organization.
type User struct { type User struct {
Id int64 ID int64 `xorm:"pk autoincr"`
LowerName string `xorm:"UNIQUE NOT NULL"` LowerName string `xorm:"UNIQUE NOT NULL"`
Name string `xorm:"UNIQUE NOT NULL"` Name string `xorm:"UNIQUE NOT NULL"`
FullName string FullName string
@ -137,7 +137,7 @@ func (u *User) IsLocal() bool {
// HasForkedRepo checks if user has already forked a repository with given ID. // HasForkedRepo checks if user has already forked a repository with given ID.
func (u *User) HasForkedRepo(repoID int64) bool { func (u *User) HasForkedRepo(repoID int64) bool {
_, has := HasForkedRepo(u.Id, repoID) _, has := HasForkedRepo(u.ID, repoID)
return has return has
} }
@ -184,7 +184,7 @@ func (u *User) HomeLink() string {
// GenerateEmailActivateCode generates an activate code based on user information and given e-mail. // GenerateEmailActivateCode generates an activate code based on user information and given e-mail.
func (u *User) GenerateEmailActivateCode(email string) string { func (u *User) GenerateEmailActivateCode(email string) string {
code := base.CreateTimeLimitCode( code := base.CreateTimeLimitCode(
com.ToStr(u.Id)+email+u.LowerName+u.Passwd+u.Rands, com.ToStr(u.ID)+email+u.LowerName+u.Passwd+u.Rands,
setting.Service.ActiveCodeLives, nil) setting.Service.ActiveCodeLives, nil)
// Add tail hex username // Add tail hex username
@ -199,7 +199,7 @@ func (u *User) GenerateActivateCode() string {
// CustomAvatarPath returns user custom avatar file path. // CustomAvatarPath returns user custom avatar file path.
func (u *User) CustomAvatarPath() string { func (u *User) CustomAvatarPath() string {
return filepath.Join(setting.AvatarUploadPath, com.ToStr(u.Id)) return filepath.Join(setting.AvatarUploadPath, com.ToStr(u.ID))
} }
// GenerateRandomAvatar generates a random avatar for user. // GenerateRandomAvatar generates a random avatar for user.
@ -226,13 +226,13 @@ func (u *User) GenerateRandomAvatar() error {
return fmt.Errorf("Encode: %v", err) return fmt.Errorf("Encode: %v", err)
} }
log.Info("New random avatar created: %d", u.Id) log.Info("New random avatar created: %d", u.ID)
return nil return nil
} }
func (u *User) RelAvatarLink() string { func (u *User) RelAvatarLink() string {
defaultImgUrl := "/img/avatar_default.png" defaultImgUrl := "/img/avatar_default.png"
if u.Id == -1 { if u.ID == -1 {
return defaultImgUrl return defaultImgUrl
} }
@ -241,7 +241,7 @@ func (u *User) RelAvatarLink() string {
if !com.IsExist(u.CustomAvatarPath()) { if !com.IsExist(u.CustomAvatarPath()) {
return defaultImgUrl return defaultImgUrl
} }
return "/avatars/" + com.ToStr(u.Id) return "/avatars/" + com.ToStr(u.ID)
case setting.DisableGravatar, setting.OfflineMode: case setting.DisableGravatar, setting.OfflineMode:
if !com.IsExist(u.CustomAvatarPath()) { if !com.IsExist(u.CustomAvatarPath()) {
if err := u.GenerateRandomAvatar(); err != nil { if err := u.GenerateRandomAvatar(); err != nil {
@ -249,7 +249,7 @@ func (u *User) RelAvatarLink() string {
} }
} }
return "/avatars/" + com.ToStr(u.Id) return "/avatars/" + com.ToStr(u.ID)
} }
return setting.GravatarSource + u.Avatar return setting.GravatarSource + u.Avatar
} }
@ -266,7 +266,7 @@ func (u *User) AvatarLink() string {
// User.GetFollwoers returns range of user's followers. // User.GetFollwoers returns range of user's followers.
func (u *User) GetFollowers(page int) ([]*User, error) { func (u *User) GetFollowers(page int) ([]*User, error) {
users := make([]*User, 0, ItemsPerPage) users := make([]*User, 0, ItemsPerPage)
sess := x.Limit(ItemsPerPage, (page-1)*ItemsPerPage).Where("follow.follow_id=?", u.Id) sess := x.Limit(ItemsPerPage, (page-1)*ItemsPerPage).Where("follow.follow_id=?", u.ID)
if setting.UsePostgreSQL { if setting.UsePostgreSQL {
sess = sess.Join("LEFT", "follow", `"user".id=follow.user_id`) sess = sess.Join("LEFT", "follow", `"user".id=follow.user_id`)
} else { } else {
@ -276,13 +276,13 @@ func (u *User) GetFollowers(page int) ([]*User, error) {
} }
func (u *User) IsFollowing(followID int64) bool { func (u *User) IsFollowing(followID int64) bool {
return IsFollowing(u.Id, followID) return IsFollowing(u.ID, followID)
} }
// GetFollowing returns range of user's following. // GetFollowing returns range of user's following.
func (u *User) GetFollowing(page int) ([]*User, error) { func (u *User) GetFollowing(page int) ([]*User, error) {
users := make([]*User, 0, ItemsPerPage) users := make([]*User, 0, ItemsPerPage)
sess := x.Limit(ItemsPerPage, (page-1)*ItemsPerPage).Where("follow.user_id=?", u.Id) sess := x.Limit(ItemsPerPage, (page-1)*ItemsPerPage).Where("follow.user_id=?", u.ID)
if setting.UsePostgreSQL { if setting.UsePostgreSQL {
sess = sess.Join("LEFT", "follow", `"user".id=follow.follow_id`) sess = sess.Join("LEFT", "follow", `"user".id=follow.follow_id`)
} else { } else {
@ -350,7 +350,7 @@ func (u *User) UploadAvatar(data []byte) error {
// DeleteAvatar deletes the user's custom avatar. // DeleteAvatar deletes the user's custom avatar.
func (u *User) DeleteAvatar() error { func (u *User) DeleteAvatar() error {
log.Trace("DeleteAvatar[%d]: %s", u.Id, u.CustomAvatarPath()) log.Trace("DeleteAvatar[%d]: %s", u.ID, u.CustomAvatarPath())
os.Remove(u.CustomAvatarPath()) os.Remove(u.CustomAvatarPath())
u.UseCustomAvatar = false u.UseCustomAvatar = false
@ -385,16 +385,16 @@ func (u *User) IsOrganization() bool {
// IsUserOrgOwner returns true if user is in the owner team of given organization. // IsUserOrgOwner returns true if user is in the owner team of given organization.
func (u *User) IsUserOrgOwner(orgId int64) bool { func (u *User) IsUserOrgOwner(orgId int64) bool {
return IsOrganizationOwner(orgId, u.Id) return IsOrganizationOwner(orgId, u.ID)
} }
// IsPublicMember returns true if user public his/her membership in give organization. // IsPublicMember returns true if user public his/her membership in give organization.
func (u *User) IsPublicMember(orgId int64) bool { func (u *User) IsPublicMember(orgId int64) bool {
return IsPublicMembership(orgId, u.Id) return IsPublicMembership(orgId, u.ID)
} }
func (u *User) getOrganizationCount(e Engine) (int64, error) { func (u *User) getOrganizationCount(e Engine) (int64, error) {
return e.Where("uid=?", u.Id).Count(new(OrgUser)) return e.Where("uid=?", u.ID).Count(new(OrgUser))
} }
// GetOrganizationCount returns count of membership of organization of user. // GetOrganizationCount returns count of membership of organization of user.
@ -404,19 +404,19 @@ func (u *User) GetOrganizationCount() (int64, error) {
// GetRepositories returns all repositories that user owns, including private repositories. // GetRepositories returns all repositories that user owns, including private repositories.
func (u *User) GetRepositories() (err error) { func (u *User) GetRepositories() (err error) {
u.Repos, err = GetRepositories(u.Id, true) u.Repos, err = GetRepositories(u.ID, true)
return err return err
} }
// GetOwnedOrganizations returns all organizations that user owns. // GetOwnedOrganizations returns all organizations that user owns.
func (u *User) GetOwnedOrganizations() (err error) { func (u *User) GetOwnedOrganizations() (err error) {
u.OwnedOrgs, err = GetOwnedOrgsByUserID(u.Id) u.OwnedOrgs, err = GetOwnedOrgsByUserID(u.ID)
return err return err
} }
// GetOrganizations returns all organizations that user belongs to. // GetOrganizations returns all organizations that user belongs to.
func (u *User) GetOrganizations(all bool) error { func (u *User) GetOrganizations(all bool) error {
ous, err := GetOrgUsersByUserID(u.Id, all) ous, err := GetOrgUsersByUserID(u.ID, all)
if err != nil { if err != nil {
return err return err
} }
@ -463,7 +463,7 @@ func GetUserSalt() string {
// NewFakeUser creates and returns a fake user for someone has deleted his/her account. // NewFakeUser creates and returns a fake user for someone has deleted his/her account.
func NewFakeUser() *User { func NewFakeUser() *User {
return &User{ return &User{
Id: -1, ID: -1,
Name: "Someone", Name: "Someone",
LowerName: "someone", LowerName: "someone",
} }
@ -588,7 +588,7 @@ func VerifyUserActiveCode(code string) (user *User) {
if user = getVerifyUser(code); user != nil { if user = getVerifyUser(code); user != nil {
// time limit code // time limit code
prefix := code[:base.TimeLimitCodeLength] prefix := code[:base.TimeLimitCodeLength]
data := com.ToStr(user.Id) + user.Email + user.LowerName + user.Passwd + user.Rands data := com.ToStr(user.ID) + user.Email + user.LowerName + user.Passwd + user.Rands
if base.VerifyTimeLimitCode(data, minutes, prefix) { if base.VerifyTimeLimitCode(data, minutes, prefix) {
return user return user
@ -604,7 +604,7 @@ func VerifyActiveEmailCode(code, email string) *EmailAddress {
if user := getVerifyUser(code); user != nil { if user := getVerifyUser(code); user != nil {
// time limit code // time limit code
prefix := code[:base.TimeLimitCodeLength] prefix := code[:base.TimeLimitCodeLength]
data := com.ToStr(user.Id) + email + user.LowerName + user.Passwd + user.Rands data := com.ToStr(user.ID) + email + user.LowerName + user.Passwd + user.Rands
if base.VerifyTimeLimitCode(data, minutes, prefix) { if base.VerifyTimeLimitCode(data, minutes, prefix) {
emailAddress := &EmailAddress{Email: email} emailAddress := &EmailAddress{Email: email}
@ -634,7 +634,7 @@ func ChangeUserName(u *User, newUserName string) (err error) {
} }
// Delete all local copies of repository wiki that user owns. // Delete all local copies of repository wiki that user owns.
if err = x.Where("owner_id=?", u.Id).Iterate(new(Repository), func(idx int, bean interface{}) error { if err = x.Where("owner_id=?", u.ID).Iterate(new(Repository), func(idx int, bean interface{}) error {
repo := bean.(*Repository) repo := bean.(*Repository)
RemoveAllWithNotice("Delete repository wiki local copy", repo.LocalWikiPath()) RemoveAllWithNotice("Delete repository wiki local copy", repo.LocalWikiPath())
return nil return nil
@ -649,7 +649,7 @@ func updateUser(e Engine, u *User) error {
// Organization does not need email // Organization does not need email
if !u.IsOrganization() { if !u.IsOrganization() {
u.Email = strings.ToLower(u.Email) u.Email = strings.ToLower(u.Email)
has, err := e.Where("id!=?", u.Id).And("type=?", u.Type).And("email=?", u.Email).Get(new(User)) has, err := e.Where("id!=?", u.ID).And("type=?", u.Type).And("email=?", u.Email).Get(new(User))
if err != nil { if err != nil {
return err return err
} else if has { } else if has {
@ -668,7 +668,7 @@ func updateUser(e Engine, u *User) error {
u.Description = base.TruncateString(u.Description, 255) u.Description = base.TruncateString(u.Description, 255)
u.FullName = markdown.Sanitizer.Sanitize(u.FullName) u.FullName = markdown.Sanitizer.Sanitize(u.FullName)
_, err := e.Id(u.Id).AllCols().Update(u) _, err := e.Id(u.ID).AllCols().Update(u)
return err return err
} }
@ -697,7 +697,7 @@ func deleteUser(e *xorm.Session, u *User) error {
if err != nil { if err != nil {
return fmt.Errorf("GetRepositoryCount: %v", err) return fmt.Errorf("GetRepositoryCount: %v", err)
} else if count > 0 { } else if count > 0 {
return ErrUserOwnRepos{UID: u.Id} return ErrUserOwnRepos{UID: u.ID}
} }
// Check membership of organization. // Check membership of organization.
@ -705,12 +705,12 @@ func deleteUser(e *xorm.Session, u *User) error {
if err != nil { if err != nil {
return fmt.Errorf("GetOrganizationCount: %v", err) return fmt.Errorf("GetOrganizationCount: %v", err)
} else if count > 0 { } else if count > 0 {
return ErrUserHasOrgs{UID: u.Id} return ErrUserHasOrgs{UID: u.ID}
} }
// ***** START: Watch ***** // ***** START: Watch *****
watches := make([]*Watch, 0, 10) watches := make([]*Watch, 0, 10)
if err = e.Find(&watches, &Watch{UserID: u.Id}); err != nil { if err = e.Find(&watches, &Watch{UserID: u.ID}); err != nil {
return fmt.Errorf("get all watches: %v", err) return fmt.Errorf("get all watches: %v", err)
} }
for i := range watches { for i := range watches {
@ -722,7 +722,7 @@ func deleteUser(e *xorm.Session, u *User) error {
// ***** START: Star ***** // ***** START: Star *****
stars := make([]*Star, 0, 10) stars := make([]*Star, 0, 10)
if err = e.Find(&stars, &Star{UID: u.Id}); err != nil { if err = e.Find(&stars, &Star{UID: u.ID}); err != nil {
return fmt.Errorf("get all stars: %v", err) return fmt.Errorf("get all stars: %v", err)
} }
for i := range stars { for i := range stars {
@ -734,7 +734,7 @@ func deleteUser(e *xorm.Session, u *User) error {
// ***** START: Follow ***** // ***** START: Follow *****
followers := make([]*Follow, 0, 10) followers := make([]*Follow, 0, 10)
if err = e.Find(&followers, &Follow{UserID: u.Id}); err != nil { if err = e.Find(&followers, &Follow{UserID: u.ID}); err != nil {
return fmt.Errorf("get all followers: %v", err) return fmt.Errorf("get all followers: %v", err)
} }
for i := range followers { for i := range followers {
@ -745,22 +745,22 @@ func deleteUser(e *xorm.Session, u *User) error {
// ***** END: Follow ***** // ***** END: Follow *****
if err = deleteBeans(e, if err = deleteBeans(e,
&AccessToken{UID: u.Id}, &AccessToken{UID: u.ID},
&Collaboration{UserID: u.Id}, &Collaboration{UserID: u.ID},
&Access{UserID: u.Id}, &Access{UserID: u.ID},
&Watch{UserID: u.Id}, &Watch{UserID: u.ID},
&Star{UID: u.Id}, &Star{UID: u.ID},
&Follow{FollowID: u.Id}, &Follow{FollowID: u.ID},
&Action{UserID: u.Id}, &Action{UserID: u.ID},
&IssueUser{UID: u.Id}, &IssueUser{UID: u.ID},
&EmailAddress{UID: u.Id}, &EmailAddress{UID: u.ID},
); err != nil { ); err != nil {
return fmt.Errorf("deleteBeans: %v", err) return fmt.Errorf("deleteBeans: %v", err)
} }
// ***** START: PublicKey ***** // ***** START: PublicKey *****
keys := make([]*PublicKey, 0, 10) keys := make([]*PublicKey, 0, 10)
if err = e.Find(&keys, &PublicKey{OwnerID: u.Id}); err != nil { if err = e.Find(&keys, &PublicKey{OwnerID: u.ID}); err != nil {
return fmt.Errorf("get all public keys: %v", err) return fmt.Errorf("get all public keys: %v", err)
} }
for _, key := range keys { for _, key := range keys {
@ -771,11 +771,11 @@ func deleteUser(e *xorm.Session, u *User) error {
// ***** END: PublicKey ***** // ***** END: PublicKey *****
// Clear assignee. // Clear assignee.
if _, err = e.Exec("UPDATE `issue` SET assignee_id=0 WHERE assignee_id=?", u.Id); err != nil { if _, err = e.Exec("UPDATE `issue` SET assignee_id=0 WHERE assignee_id=?", u.ID); err != nil {
return fmt.Errorf("clear assignee: %v", err) return fmt.Errorf("clear assignee: %v", err)
} }
if _, err = e.Id(u.Id).Delete(new(User)); err != nil { if _, err = e.Id(u.ID).Delete(new(User)); err != nil {
return fmt.Errorf("Delete: %v", err) return fmt.Errorf("Delete: %v", err)
} }
@ -861,7 +861,7 @@ func GetUserByID(id int64) (*User, error) {
// GetAssigneeByID returns the user with write access of repository by given ID. // GetAssigneeByID returns the user with write access of repository by given ID.
func GetAssigneeByID(repo *Repository, userID int64) (*User, error) { func GetAssigneeByID(repo *Repository, userID int64) (*User, error) {
has, err := HasAccess(&User{Id: userID}, repo, ACCESS_MODE_WRITE) has, err := HasAccess(&User{ID: userID}, repo, ACCESS_MODE_WRITE)
if err != nil { if err != nil {
return nil, err return nil, err
} else if !has { } else if !has {
@ -906,7 +906,7 @@ func GetUserIDsByNames(names []string) []int64 {
if err != nil { if err != nil {
continue continue
} }
ids = append(ids, u.Id) ids = append(ids, u.ID)
} }
return ids return ids
} }

@ -160,7 +160,7 @@ func MakeEmailPrimary(email *EmailAddress) error {
return ErrEmailNotActivated return ErrEmailNotActivated
} }
user := &User{Id: email.UID} user := &User{ID: email.UID}
has, err = x.Get(user) has, err = x.Get(user)
if err != nil { if err != nil {
return err return err
@ -182,7 +182,7 @@ func MakeEmailPrimary(email *EmailAddress) error {
} }
if !has { if !has {
formerPrimaryEmail.UID = user.Id formerPrimaryEmail.UID = user.ID
formerPrimaryEmail.IsActivated = user.IsActive formerPrimaryEmail.IsActivated = user.IsActive
if _, err = sess.Insert(formerPrimaryEmail); err != nil { if _, err = sess.Insert(formerPrimaryEmail); err != nil {
return err return err
@ -190,7 +190,7 @@ func MakeEmailPrimary(email *EmailAddress) error {
} }
user.Email = email.Email user.Email = email.Email
if _, err = sess.Id(user.Id).AllCols().Update(user); err != nil { if _, err = sess.Id(user.ID).AllCols().Update(user); err != nil {
return err return err
} }

@ -156,7 +156,7 @@ func Contexter() macaron.Handler {
ctx.IsSigned = true ctx.IsSigned = true
ctx.Data["IsSigned"] = ctx.IsSigned ctx.Data["IsSigned"] = ctx.IsSigned
ctx.Data["SignedUser"] = ctx.User ctx.Data["SignedUser"] = ctx.User
ctx.Data["SignedUserID"] = ctx.User.Id ctx.Data["SignedUserID"] = ctx.User.ID
ctx.Data["SignedUserName"] = ctx.User.Name ctx.Data["SignedUserName"] = ctx.User.Name
ctx.Data["IsAdmin"] = ctx.User.IsAdmin ctx.Data["IsAdmin"] = ctx.User.IsAdmin
} else { } else {

@ -72,13 +72,13 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
ctx.Org.IsTeamMember = true ctx.Org.IsTeamMember = true
ctx.Org.IsTeamAdmin = true ctx.Org.IsTeamAdmin = true
} else if ctx.IsSigned { } else if ctx.IsSigned {
ctx.Org.IsOwner = org.IsOwnedBy(ctx.User.Id) ctx.Org.IsOwner = org.IsOwnedBy(ctx.User.ID)
if ctx.Org.IsOwner { if ctx.Org.IsOwner {
ctx.Org.IsMember = true ctx.Org.IsMember = true
ctx.Org.IsTeamMember = true ctx.Org.IsTeamMember = true
ctx.Org.IsTeamAdmin = true ctx.Org.IsTeamAdmin = true
} else { } else {
if org.IsOrgMember(ctx.User.Id) { if org.IsOrgMember(ctx.User.ID) {
ctx.Org.IsMember = true ctx.Org.IsMember = true
} }
} }
@ -105,7 +105,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) {
return return
} }
} else { } else {
if err := org.GetUserTeams(ctx.User.Id); err != nil { if err := org.GetUserTeams(ctx.User.ID); err != nil {
ctx.Handle(500, "GetUserTeams", err) ctx.Handle(500, "GetUserTeams", err)
return return
} }

@ -122,7 +122,7 @@ func RepoAssignment(args ...bool) macaron.Handler {
ctx.Repo.Owner = owner ctx.Repo.Owner = owner
// Get repository. // Get repository.
repo, err := models.GetRepositoryByName(owner.Id, repoName) repo, err := models.GetRepositoryByName(owner.ID, repoName)
if err != nil { if err != nil {
if models.IsErrRepoNotExist(err) { if models.IsErrRepoNotExist(err) {
ctx.Handle(404, "GetRepositoryByName", err) ctx.Handle(404, "GetRepositoryByName", err)
@ -198,8 +198,8 @@ func RepoAssignment(args ...bool) macaron.Handler {
ctx.Data["WikiCloneLink"] = repo.WikiCloneLink() ctx.Data["WikiCloneLink"] = repo.WikiCloneLink()
if ctx.IsSigned { if ctx.IsSigned {
ctx.Data["IsWatchingRepo"] = models.IsWatching(ctx.User.Id, repo.ID) ctx.Data["IsWatchingRepo"] = models.IsWatching(ctx.User.ID, repo.ID)
ctx.Data["IsStaringRepo"] = models.IsStaring(ctx.User.Id, repo.ID) ctx.Data["IsStaringRepo"] = models.IsStaring(ctx.User.ID, repo.ID)
} }
// repo is bare and display enable // repo is bare and display enable

@ -39,7 +39,7 @@ func DeleteRepo(ctx *context.Context) {
return return
} }
if err := models.DeleteRepository(repo.MustOwner().Id, repo.ID); err != nil { if err := models.DeleteRepository(repo.MustOwner().ID, repo.ID); err != nil {
ctx.Handle(500, "DeleteRepository", err) ctx.Handle(500, "DeleteRepository", err)
return return
} }

@ -120,7 +120,7 @@ func NewUserPost(ctx *context.Context, form auth.AdminCrateUserForm) {
} }
ctx.Flash.Success(ctx.Tr("admin.users.new_success", u.Name)) ctx.Flash.Success(ctx.Tr("admin.users.new_success", u.Name))
ctx.Redirect(setting.AppSubUrl + "/admin/users/" + com.ToStr(u.Id)) ctx.Redirect(setting.AppSubUrl + "/admin/users/" + com.ToStr(u.ID))
} }
func prepareUserInfo(ctx *context.Context) *models.User { func prepareUserInfo(ctx *context.Context) *models.User {

@ -15,7 +15,7 @@ import (
func CreateTeam(ctx *context.APIContext, form api.CreateTeamOption) { func CreateTeam(ctx *context.APIContext, form api.CreateTeamOption) {
team := &models.Team{ team := &models.Team{
OrgID: ctx.Org.Organization.Id, OrgID: ctx.Org.Organization.ID,
Name: form.Name, Name: form.Name,
Description: form.Description, Description: form.Description,
Authorize: models.ParseAccessMode(form.Permission), Authorize: models.ParseAccessMode(form.Permission),
@ -37,7 +37,7 @@ func AddTeamMember(ctx *context.APIContext) {
if ctx.Written() { if ctx.Written() {
return return
} }
if err := ctx.Org.Team.AddMember(u.Id); err != nil { if err := ctx.Org.Team.AddMember(u.ID); err != nil {
ctx.Error(500, "AddMember", err) ctx.Error(500, "AddMember", err)
return return
} }
@ -51,7 +51,7 @@ func RemoveTeamMember(ctx *context.APIContext) {
return return
} }
if err := ctx.Org.Team.RemoveMember(u.Id); err != nil { if err := ctx.Org.Team.RemoveMember(u.ID); err != nil {
ctx.Error(500, "RemoveMember", err) ctx.Error(500, "RemoveMember", err)
return return
} }

@ -147,5 +147,5 @@ func CreatePublicKey(ctx *context.APIContext, form api.CreateKeyOption) {
if ctx.Written() { if ctx.Written() {
return return
} }
user.CreateUserPublicKey(ctx, form, u.Id) user.CreateUserPublicKey(ctx, form, u.ID)
} }

@ -49,7 +49,7 @@ func RepoAssignment() macaron.Handler {
ctx.Repo.Owner = owner ctx.Repo.Owner = owner
// Get repository. // Get repository.
repo, err := models.GetRepositoryByName(owner.Id, repoName) repo, err := models.GetRepositoryByName(owner.ID, repoName)
if err != nil { if err != nil {
if models.IsErrRepoNotExist(err) { if models.IsErrRepoNotExist(err) {
ctx.Status(404) ctx.Status(404)

@ -23,7 +23,7 @@ func ToUser(u *models.User) *api.User {
} }
return &api.User{ return &api.User{
ID: u.Id, ID: u.ID,
UserName: u.Name, UserName: u.Name,
FullName: u.FullName, FullName: u.FullName,
Email: u.Email, Email: u.Email,
@ -194,7 +194,7 @@ func ToIssue(issue *models.Issue) *api.Issue {
func ToOrganization(org *models.User) *api.Organization { func ToOrganization(org *models.User) *api.Organization {
return &api.Organization{ return &api.Organization{
ID: org.Id, ID: org.ID,
AvatarUrl: org.AvatarLink(), AvatarUrl: org.AvatarLink(),
UserName: org.Name, UserName: org.Name,
FullName: org.FullName, FullName: org.FullName,

@ -48,7 +48,7 @@ func Get(ctx *context.APIContext) {
// https://github.com/gogits/go-gogs-client/wiki/Organizations#edit-an-organization // https://github.com/gogits/go-gogs-client/wiki/Organizations#edit-an-organization
func Edit(ctx *context.APIContext, form api.EditOrgOption) { func Edit(ctx *context.APIContext, form api.EditOrgOption) {
org := ctx.Org.Organization org := ctx.Org.Organization
if !org.IsOwnedBy(ctx.User.Id) { if !org.IsOwnedBy(ctx.User.ID) {
ctx.Status(403) ctx.Status(403)
return return
} }

@ -53,7 +53,7 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
issue := &models.Issue{ issue := &models.Issue{
RepoID: ctx.Repo.Repository.ID, RepoID: ctx.Repo.Repository.ID,
Name: form.Title, Name: form.Title,
PosterID: ctx.User.Id, PosterID: ctx.User.ID,
Poster: ctx.User, Poster: ctx.User,
Content: form.Body, Content: form.Body,
} }
@ -69,7 +69,7 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) {
} }
return return
} }
issue.AssigneeID = assignee.Id issue.AssigneeID = assignee.ID
} }
issue.MilestoneID = form.Milestone issue.MilestoneID = form.Milestone
} else { } else {
@ -109,7 +109,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
return return
} }
if !issue.IsPoster(ctx.User.Id) && !ctx.Repo.IsWriter() { if !issue.IsPoster(ctx.User.ID) && !ctx.Repo.IsWriter() {
ctx.Status(403) ctx.Status(403)
return return
} }
@ -135,7 +135,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) {
} }
return return
} }
issue.AssigneeID = assignee.Id issue.AssigneeID = assignee.ID
} }
if err = models.UpdateIssueUserByAssignee(issue); err != nil { if err = models.UpdateIssueUserByAssignee(issue); err != nil {

@ -27,7 +27,7 @@ func Search(ctx *context.APIContext) {
// Check visibility. // Check visibility.
if ctx.IsSigned && opts.OwnerID > 0 { if ctx.IsSigned && opts.OwnerID > 0 {
if ctx.User.Id == opts.OwnerID { if ctx.User.ID == opts.OwnerID {
opts.Private = true opts.Private = true
} else { } else {
u, err := models.GetUserByID(opts.OwnerID) u, err := models.GetUserByID(opts.OwnerID)
@ -38,7 +38,7 @@ func Search(ctx *context.APIContext) {
}) })
return return
} }
if u.IsOrganization() && u.IsOwnedBy(ctx.User.Id) { if u.IsOrganization() && u.IsOwnedBy(ctx.User.ID) {
opts.Private = true opts.Private = true
} }
// FIXME: how about collaborators? // FIXME: how about collaborators?
@ -78,7 +78,7 @@ func Search(ctx *context.APIContext) {
// https://github.com/gogits/go-gogs-client/wiki/Repositories#list-your-repositories // https://github.com/gogits/go-gogs-client/wiki/Repositories#list-your-repositories
func ListMyRepos(ctx *context.APIContext) { func ListMyRepos(ctx *context.APIContext) {
ownRepos, err := models.GetRepositories(ctx.User.Id, true) ownRepos, err := models.GetRepositories(ctx.User.ID, true)
if err != nil { if err != nil {
ctx.Error(500, "GetRepositories", err) ctx.Error(500, "GetRepositories", err)
return return
@ -126,7 +126,7 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR
ctx.Error(422, "", err) ctx.Error(422, "", err)
} else { } else {
if repo != nil { if repo != nil {
if err = models.DeleteRepository(ctx.User.Id, repo.ID); err != nil { if err = models.DeleteRepository(ctx.User.ID, repo.ID); err != nil {
log.Error(4, "DeleteRepository: %v", err) log.Error(4, "DeleteRepository: %v", err)
} }
} }
@ -159,7 +159,7 @@ func CreateOrgRepo(ctx *context.APIContext, opt api.CreateRepoOption) {
return return
} }
if !org.IsOwnedBy(ctx.User.Id) { if !org.IsOwnedBy(ctx.User.ID) {
ctx.Error(403, "", "Given user is not owner of organization.") ctx.Error(403, "", "Given user is not owner of organization.")
return return
} }
@ -171,7 +171,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
ctxUser := ctx.User ctxUser := ctx.User
// Not equal means context user is an organization, // Not equal means context user is an organization,
// or is another user/organization if current user is admin. // or is another user/organization if current user is admin.
if form.Uid != ctxUser.Id { if form.Uid != ctxUser.ID {
org, err := models.GetUserByID(form.Uid) org, err := models.GetUserByID(form.Uid)
if err != nil { if err != nil {
if models.IsErrUserNotExist(err) { if models.IsErrUserNotExist(err) {
@ -191,7 +191,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
if ctxUser.IsOrganization() && !ctx.User.IsAdmin { if ctxUser.IsOrganization() && !ctx.User.IsAdmin {
// Check ownership of organization. // Check ownership of organization.
if !ctxUser.IsOwnedBy(ctx.User.Id) { if !ctxUser.IsOwnedBy(ctx.User.ID) {
ctx.Error(403, "", "Given user is not owner of organization.") ctx.Error(403, "", "Given user is not owner of organization.")
return return
} }
@ -226,7 +226,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) {
}) })
if err != nil { if err != nil {
if repo != nil { if repo != nil {
if errDelete := models.DeleteRepository(ctxUser.Id, repo.ID); errDelete != nil { if errDelete := models.DeleteRepository(ctxUser.ID, repo.ID); errDelete != nil {
log.Error(4, "DeleteRepository: %v", errDelete) log.Error(4, "DeleteRepository: %v", errDelete)
} }
} }
@ -249,7 +249,7 @@ func parseOwnerAndRepo(ctx *context.APIContext) (*models.User, *models.Repositor
return nil, nil return nil, nil
} }
repo, err := models.GetRepositoryByName(owner.Id, ctx.Params(":reponame")) repo, err := models.GetRepositoryByName(owner.ID, ctx.Params(":reponame"))
if err != nil { if err != nil {
if models.IsErrRepoNotExist(err) { if models.IsErrRepoNotExist(err) {
ctx.Status(404) ctx.Status(404)
@ -279,12 +279,12 @@ func Delete(ctx *context.APIContext) {
return return
} }
if owner.IsOrganization() && !owner.IsOwnedBy(ctx.User.Id) { if owner.IsOrganization() && !owner.IsOwnedBy(ctx.User.ID) {
ctx.Error(403, "", "Given user is not owner of organization.") ctx.Error(403, "", "Given user is not owner of organization.")
return return
} }
if err := models.DeleteRepository(owner.Id, repo.ID); err != nil { if err := models.DeleteRepository(owner.ID, repo.ID); err != nil {
ctx.Error(500, "DeleteRepository", err) ctx.Error(500, "DeleteRepository", err)
return return
} }

@ -13,7 +13,7 @@ import (
// https://github.com/gogits/go-gogs-client/wiki/Users#list-access-tokens-for-a-user // https://github.com/gogits/go-gogs-client/wiki/Users#list-access-tokens-for-a-user
func ListAccessTokens(ctx *context.APIContext) { func ListAccessTokens(ctx *context.APIContext) {
tokens, err := models.ListAccessTokens(ctx.User.Id) tokens, err := models.ListAccessTokens(ctx.User.ID)
if err != nil { if err != nil {
ctx.Error(500, "ListAccessTokens", err) ctx.Error(500, "ListAccessTokens", err)
return return
@ -29,7 +29,7 @@ func ListAccessTokens(ctx *context.APIContext) {
// https://github.com/gogits/go-gogs-client/wiki/Users#create-a-access-token // https://github.com/gogits/go-gogs-client/wiki/Users#create-a-access-token
func CreateAccessToken(ctx *context.APIContext, form api.CreateAccessTokenOption) { func CreateAccessToken(ctx *context.APIContext, form api.CreateAccessTokenOption) {
t := &models.AccessToken{ t := &models.AccessToken{
UID: ctx.User.Id, UID: ctx.User.ID,
Name: form.Name, Name: form.Name,
} }
if err := models.NewAccessToken(t); err != nil { if err := models.NewAccessToken(t); err != nil {

@ -15,7 +15,7 @@ import (
// https://github.com/gogits/go-gogs-client/wiki/Users-Emails#list-email-addresses-for-a-user // https://github.com/gogits/go-gogs-client/wiki/Users-Emails#list-email-addresses-for-a-user
func ListEmails(ctx *context.APIContext) { func ListEmails(ctx *context.APIContext) {
emails, err := models.GetEmailAddresses(ctx.User.Id) emails, err := models.GetEmailAddresses(ctx.User.ID)
if err != nil { if err != nil {
ctx.Error(500, "GetEmailAddresses", err) ctx.Error(500, "GetEmailAddresses", err)
return return
@ -37,7 +37,7 @@ func AddEmail(ctx *context.APIContext, form api.CreateEmailOption) {
emails := make([]*models.EmailAddress, len(form.Emails)) emails := make([]*models.EmailAddress, len(form.Emails))
for i := range form.Emails { for i := range form.Emails {
emails[i] = &models.EmailAddress{ emails[i] = &models.EmailAddress{
UID: ctx.User.Id, UID: ctx.User.ID,
Email: form.Emails[i], Email: form.Emails[i],
IsActivated: !setting.Service.RegisterEmailConfirm, IsActivated: !setting.Service.RegisterEmailConfirm,
} }

@ -78,7 +78,7 @@ func CheckMyFollowing(ctx *context.APIContext) {
if ctx.Written() { if ctx.Written() {
return return
} }
checkUserFollowing(ctx, ctx.User, target.Id) checkUserFollowing(ctx, ctx.User, target.ID)
} }
// https://github.com/gogits/go-gogs-client/wiki/Users-Followers#check-if-one-user-follows-another // https://github.com/gogits/go-gogs-client/wiki/Users-Followers#check-if-one-user-follows-another
@ -91,7 +91,7 @@ func CheckFollowing(ctx *context.APIContext) {
if ctx.Written() { if ctx.Written() {
return return
} }
checkUserFollowing(ctx, u, target.Id) checkUserFollowing(ctx, u, target.ID)
} }
// https://github.com/gogits/go-gogs-client/wiki/Users-Followers#follow-a-user // https://github.com/gogits/go-gogs-client/wiki/Users-Followers#follow-a-user
@ -100,7 +100,7 @@ func Follow(ctx *context.APIContext) {
if ctx.Written() { if ctx.Written() {
return return
} }
if err := models.FollowUser(ctx.User.Id, target.Id); err != nil { if err := models.FollowUser(ctx.User.ID, target.ID); err != nil {
ctx.Error(500, "FollowUser", err) ctx.Error(500, "FollowUser", err)
return return
} }
@ -113,7 +113,7 @@ func Unfollow(ctx *context.APIContext) {
if ctx.Written() { if ctx.Written() {
return return
} }
if err := models.UnfollowUser(ctx.User.Id, target.Id); err != nil { if err := models.UnfollowUser(ctx.User.ID, target.ID); err != nil {
ctx.Error(500, "UnfollowUser", err) ctx.Error(500, "UnfollowUser", err)
return return
} }

@ -54,7 +54,7 @@ func listPublicKeys(ctx *context.APIContext, uid int64) {
// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-your-public-keys // https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-your-public-keys
func ListMyPublicKeys(ctx *context.APIContext) { func ListMyPublicKeys(ctx *context.APIContext) {
listPublicKeys(ctx, ctx.User.Id) listPublicKeys(ctx, ctx.User.ID)
} }
// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-public-keys-for-a-user // https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#list-public-keys-for-a-user
@ -63,7 +63,7 @@ func ListPublicKeys(ctx *context.APIContext) {
if ctx.Written() { if ctx.Written() {
return return
} }
listPublicKeys(ctx, user.Id) listPublicKeys(ctx, user.ID)
} }
// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#get-a-single-public-key // https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#get-a-single-public-key
@ -101,7 +101,7 @@ func CreateUserPublicKey(ctx *context.APIContext, form api.CreateKeyOption, uid
// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#create-a-public-key // https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#create-a-public-key
func CreatePublicKey(ctx *context.APIContext, form api.CreateKeyOption) { func CreatePublicKey(ctx *context.APIContext, form api.CreateKeyOption) {
CreateUserPublicKey(ctx, form, ctx.User.Id) CreateUserPublicKey(ctx, form, ctx.User.ID)
} }
// https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#delete-a-public-key // https://github.com/gogits/go-gogs-client/wiki/Users-Public-Keys#delete-a-public-key

@ -36,7 +36,7 @@ func Search(ctx *context.APIContext) {
results := make([]*api.User, len(users)) results := make([]*api.User, len(users))
for i := range users { for i := range users {
results[i] = &api.User{ results[i] = &api.User{
ID: users[i].Id, ID: users[i].ID,
UserName: users[i].Name, UserName: users[i].Name,
AvatarUrl: users[i].AvatarLink(), AvatarUrl: users[i].AvatarLink(),
FullName: users[i].FullName, FullName: users[i].FullName,
@ -68,5 +68,5 @@ func GetInfo(ctx *context.APIContext) {
if !ctx.IsSigned { if !ctx.IsSigned {
u.Email = "" u.Email = ""
} }
ctx.JSON(200, &api.User{u.Id, u.Name, u.FullName, u.Email, u.AvatarLink()}) ctx.JSON(200, &api.User{u.ID, u.Name, u.FullName, u.Email, u.AvatarLink()})
} }

@ -374,7 +374,7 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) {
} }
// Auto-login for admin // Auto-login for admin
ctx.Session.Set("uid", u.Id) ctx.Session.Set("uid", u.ID)
ctx.Session.Set("uname", u.Name) ctx.Session.Set("uname", u.Name)
} }

@ -44,17 +44,17 @@ func MembersAction(ctx *context.Context) {
var err error var err error
switch ctx.Params(":action") { switch ctx.Params(":action") {
case "private": case "private":
if ctx.User.Id != uid && !ctx.Org.IsOwner { if ctx.User.ID != uid && !ctx.Org.IsOwner {
ctx.Error(404) ctx.Error(404)
return return
} }
err = models.ChangeOrgUserStatus(org.Id, uid, false) err = models.ChangeOrgUserStatus(org.ID, uid, false)
case "public": case "public":
if ctx.User.Id != uid && !ctx.Org.IsOwner { if ctx.User.ID != uid && !ctx.Org.IsOwner {
ctx.Error(404) ctx.Error(404)
return return
} }
err = models.ChangeOrgUserStatus(org.Id, uid, true) err = models.ChangeOrgUserStatus(org.ID, uid, true)
case "remove": case "remove":
if !ctx.Org.IsOwner { if !ctx.Org.IsOwner {
ctx.Error(404) ctx.Error(404)
@ -67,7 +67,7 @@ func MembersAction(ctx *context.Context) {
return return
} }
case "leave": case "leave":
err = org.RemoveMember(ctx.User.Id) err = org.RemoveMember(ctx.User.ID)
if models.IsErrLastOrgOwner(err) { if models.IsErrLastOrgOwner(err) {
ctx.Flash.Error(ctx.Tr("form.last_org_owner")) ctx.Flash.Error(ctx.Tr("form.last_org_owner"))
ctx.Redirect(ctx.Org.OrgLink + "/members") ctx.Redirect(ctx.Org.OrgLink + "/members")
@ -109,7 +109,7 @@ func Invitation(ctx *context.Context) {
return return
} }
if err = org.AddMember(u.Id); err != nil { if err = org.AddMember(u.ID); err != nil {
ctx.Handle(500, " AddMember", err) ctx.Handle(500, " AddMember", err)
return return
} }

@ -41,7 +41,7 @@ func SettingsPost(ctx *context.Context, form auth.UpdateOrgSettingForm) {
// Check if organization name has been changed. // Check if organization name has been changed.
if org.LowerName != strings.ToLower(form.Name) { if org.LowerName != strings.ToLower(form.Name) {
isExist, err := models.IsUserExist(org.Id, form.Name) isExist, err := models.IsUserExist(org.ID, form.Name)
if err != nil { if err != nil {
ctx.Handle(500, "IsUserExist", err) ctx.Handle(500, "IsUserExist", err)
return return
@ -140,7 +140,7 @@ func Webhooks(ctx *context.Context) {
ctx.Data["BaseLink"] = ctx.Org.OrgLink ctx.Data["BaseLink"] = ctx.Org.OrgLink
ctx.Data["Description"] = ctx.Tr("org.settings.hooks_desc") ctx.Data["Description"] = ctx.Tr("org.settings.hooks_desc")
ws, err := models.GetWebhooksByOrgID(ctx.Org.Organization.Id) ws, err := models.GetWebhooksByOrgID(ctx.Org.Organization.ID)
if err != nil { if err != nil {
ctx.Handle(500, "GetWebhooksByOrgId", err) ctx.Handle(500, "GetWebhooksByOrgId", err)
return return
@ -151,7 +151,7 @@ func Webhooks(ctx *context.Context) {
} }
func DeleteWebhook(ctx *context.Context) { func DeleteWebhook(ctx *context.Context) {
if err := models.DeleteWebhookByOrgID(ctx.Org.Organization.Id, ctx.QueryInt64("id")); err != nil { if err := models.DeleteWebhookByOrgID(ctx.Org.Organization.ID, ctx.QueryInt64("id")); err != nil {
ctx.Flash.Error("DeleteWebhookByOrgID: " + err.Error()) ctx.Flash.Error("DeleteWebhookByOrgID: " + err.Error())
} else { } else {
ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success")) ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success"))

@ -54,9 +54,9 @@ func TeamsAction(ctx *context.Context) {
ctx.Error(404) ctx.Error(404)
return return
} }
err = ctx.Org.Team.AddMember(ctx.User.Id) err = ctx.Org.Team.AddMember(ctx.User.ID)
case "leave": case "leave":
err = ctx.Org.Team.RemoveMember(ctx.User.Id) err = ctx.Org.Team.RemoveMember(ctx.User.ID)
case "remove": case "remove":
if !ctx.Org.IsOwner { if !ctx.Org.IsOwner {
ctx.Error(404) ctx.Error(404)
@ -82,7 +82,7 @@ func TeamsAction(ctx *context.Context) {
return return
} }
err = ctx.Org.Team.AddMember(u.Id) err = ctx.Org.Team.AddMember(u.ID)
page = "team" page = "team"
} }
@ -118,7 +118,7 @@ func TeamsRepoAction(ctx *context.Context) {
case "add": case "add":
repoName := path.Base(ctx.Query("repo_name")) repoName := path.Base(ctx.Query("repo_name"))
var repo *models.Repository var repo *models.Repository
repo, err = models.GetRepositoryByName(ctx.Org.Organization.Id, repoName) repo, err = models.GetRepositoryByName(ctx.Org.Organization.ID, repoName)
if err != nil { if err != nil {
if models.IsErrRepoNotExist(err) { if models.IsErrRepoNotExist(err) {
ctx.Flash.Error(ctx.Tr("org.teams.add_nonexistent_repo")) ctx.Flash.Error(ctx.Tr("org.teams.add_nonexistent_repo"))
@ -155,7 +155,7 @@ func NewTeamPost(ctx *context.Context, form auth.CreateTeamForm) {
ctx.Data["PageIsOrgTeamsNew"] = true ctx.Data["PageIsOrgTeamsNew"] = true
t := &models.Team{ t := &models.Team{
OrgID: ctx.Org.Organization.Id, OrgID: ctx.Org.Organization.ID,
Name: form.TeamName, Name: form.TeamName,
Description: form.Description, Description: form.Description,
Authorize: models.ParseAccessMode(form.Permission), Authorize: models.ParseAccessMode(form.Permission),

@ -59,7 +59,7 @@ func HTTP(ctx *context.Context) {
return return
} }
repo, err := models.GetRepositoryByName(repoUser.Id, reponame) repo, err := models.GetRepositoryByName(repoUser.ID, reponame)
if err != nil { if err != nil {
if models.IsErrRepoNotExist(err) { if models.IsErrRepoNotExist(err) {
ctx.Handle(http.StatusNotFound, "GetRepositoryByName", nil) ctx.Handle(http.StatusNotFound, "GetRepositoryByName", nil)
@ -200,7 +200,7 @@ func HTTP(ctx *context.Context) {
RefName: refName, RefName: refName,
OldCommitID: oldCommitId, OldCommitID: oldCommitId,
NewCommitID: newCommitId, NewCommitID: newCommitId,
PusherID: authUser.Id, PusherID: authUser.ID,
PusherName: authUser.Name, PusherName: authUser.Name,
RepoUserName: username, RepoUserName: username,
RepoName: reponame, RepoName: reponame,

@ -125,17 +125,17 @@ func Issues(ctx *context.Context) {
switch viewType { switch viewType {
case "assigned": case "assigned":
filterMode = models.FM_ASSIGN filterMode = models.FM_ASSIGN
assigneeID = ctx.User.Id assigneeID = ctx.User.ID
case "created_by": case "created_by":
filterMode = models.FM_CREATE filterMode = models.FM_CREATE
posterID = ctx.User.Id posterID = ctx.User.ID
case "mentioned": case "mentioned":
filterMode = models.FM_MENTION filterMode = models.FM_MENTION
} }
var uid int64 = -1 var uid int64 = -1
if ctx.IsSigned { if ctx.IsSigned {
uid = ctx.User.Id uid = ctx.User.ID
} }
repo := ctx.Repo.Repository repo := ctx.Repo.Repository
@ -200,7 +200,7 @@ func Issues(ctx *context.Context) {
} }
// Check read status. // Check read status.
idx := models.PairsContains(pairs, issues[i].ID, ctx.User.Id) idx := models.PairsContains(pairs, issues[i].ID, ctx.User.ID)
if idx > -1 { if idx > -1 {
issues[i].IsRead = pairs[idx].IsRead issues[i].IsRead = pairs[idx].IsRead
} else { } else {
@ -425,7 +425,7 @@ func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) {
issue := &models.Issue{ issue := &models.Issue{
RepoID: repo.ID, RepoID: repo.ID,
Name: form.Title, Name: form.Title,
PosterID: ctx.User.Id, PosterID: ctx.User.ID,
Poster: ctx.User, Poster: ctx.User,
MilestoneID: milestoneID, MilestoneID: milestoneID,
AssigneeID: assigneeID, AssigneeID: assigneeID,
@ -581,7 +581,7 @@ func ViewIssue(ctx *context.Context) {
if ctx.IsSigned { if ctx.IsSigned {
// Update issue-user. // Update issue-user.
if err = issue.ReadBy(ctx.User.Id); err != nil { if err = issue.ReadBy(ctx.User.ID); err != nil {
ctx.Handle(500, "ReadBy", err) ctx.Handle(500, "ReadBy", err)
return return
} }
@ -627,7 +627,7 @@ func ViewIssue(ctx *context.Context) {
break break
} }
} }
if !isAdded && !issue.IsPoster(comment.Poster.Id) { if !isAdded && !issue.IsPoster(comment.Poster.ID) {
participants = append(participants, comment.Poster) participants = append(participants, comment.Poster)
} }
} }
@ -636,7 +636,7 @@ func ViewIssue(ctx *context.Context) {
ctx.Data["Participants"] = participants ctx.Data["Participants"] = participants
ctx.Data["NumParticipants"] = len(participants) ctx.Data["NumParticipants"] = len(participants)
ctx.Data["Issue"] = issue ctx.Data["Issue"] = issue
ctx.Data["IsIssueOwner"] = ctx.Repo.IsWriter() || (ctx.IsSigned && issue.IsPoster(ctx.User.Id)) ctx.Data["IsIssueOwner"] = ctx.Repo.IsWriter() || (ctx.IsSigned && issue.IsPoster(ctx.User.ID))
ctx.Data["SignInLink"] = setting.AppSubUrl + "/user/login" ctx.Data["SignInLink"] = setting.AppSubUrl + "/user/login"
ctx.Data["RequireHighlightJS"] = true ctx.Data["RequireHighlightJS"] = true
@ -663,7 +663,7 @@ func UpdateIssueTitle(ctx *context.Context) {
return return
} }
if !ctx.IsSigned || (!issue.IsPoster(ctx.User.Id) && !ctx.Repo.IsWriter()) { if !ctx.IsSigned || (!issue.IsPoster(ctx.User.ID) && !ctx.Repo.IsWriter()) {
ctx.Error(403) ctx.Error(403)
return return
} }
@ -690,7 +690,7 @@ func UpdateIssueContent(ctx *context.Context) {
return return
} }
if !ctx.IsSigned || (ctx.User.Id != issue.PosterID && !ctx.Repo.IsWriter()) { if !ctx.IsSigned || (ctx.User.ID != issue.PosterID && !ctx.Repo.IsWriter()) {
ctx.Error(403) ctx.Error(403)
return return
} }
@ -831,7 +831,7 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) {
var comment *models.Comment var comment *models.Comment
defer func() { defer func() {
// Check if issue admin/poster changes the status of issue. // Check if issue admin/poster changes the status of issue.
if (ctx.Repo.IsWriter() || (ctx.IsSigned && issue.IsPoster(ctx.User.Id))) && if (ctx.Repo.IsWriter() || (ctx.IsSigned && issue.IsPoster(ctx.User.ID))) &&
(form.Status == "reopen" || form.Status == "close") && (form.Status == "reopen" || form.Status == "close") &&
!(issue.IsPull && issue.HasMerged) { !(issue.IsPull && issue.HasMerged) {
@ -907,7 +907,7 @@ func UpdateCommentContent(ctx *context.Context) {
return return
} }
if !ctx.IsSigned || (ctx.User.Id != comment.PosterID && !ctx.Repo.IsAdmin()) { if !ctx.IsSigned || (ctx.User.ID != comment.PosterID && !ctx.Repo.IsAdmin()) {
ctx.Error(403) ctx.Error(403)
return return
} else if comment.Type != models.COMMENT_TYPE_COMMENT { } else if comment.Type != models.COMMENT_TYPE_COMMENT {

@ -104,7 +104,7 @@ func ForkPost(ctx *context.Context, form auth.CreateRepoForm) {
return return
} }
repo, has := models.HasForkedRepo(ctxUser.Id, forkRepo.ID) repo, has := models.HasForkedRepo(ctxUser.ID, forkRepo.ID)
if has { if has {
ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + repo.Name) ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + repo.Name)
return return
@ -112,7 +112,7 @@ func ForkPost(ctx *context.Context, form auth.CreateRepoForm) {
// Check ownership of organization. // Check ownership of organization.
if ctxUser.IsOrganization() { if ctxUser.IsOrganization() {
if !ctxUser.IsOwnedBy(ctx.User.Id) { if !ctxUser.IsOwnedBy(ctx.User.ID) {
ctx.Error(403) ctx.Error(403)
return return
} }
@ -166,7 +166,7 @@ func checkPullInfo(ctx *context.Context) *models.Issue {
if ctx.IsSigned { if ctx.IsSigned {
// Update issue-user. // Update issue-user.
if err = issue.ReadBy(ctx.User.Id); err != nil { if err = issue.ReadBy(ctx.User.ID); err != nil {
ctx.Handle(500, "ReadBy", err) ctx.Handle(500, "ReadBy", err)
return nil return nil
} }
@ -478,7 +478,7 @@ func ParseCompareInfo(ctx *context.Context) (*models.User, *models.Repository, *
} }
// Check if current user has fork of repository or in the same repository. // Check if current user has fork of repository or in the same repository.
headRepo, has := models.HasForkedRepo(headUser.Id, baseRepo.ID) headRepo, has := models.HasForkedRepo(headUser.ID, baseRepo.ID)
if !has && !isSameRepo { if !has && !isSameRepo {
log.Trace("ParseCompareInfo[%d]: does not have fork or in same repository", baseRepo.ID) log.Trace("ParseCompareInfo[%d]: does not have fork or in same repository", baseRepo.ID)
ctx.Handle(404, "ParseCompareInfo", nil) ctx.Handle(404, "ParseCompareInfo", nil)
@ -666,7 +666,7 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm)
RepoID: repo.ID, RepoID: repo.ID,
Index: repo.NextIssueIndex(), Index: repo.NextIssueIndex(),
Name: form.Title, Name: form.Title,
PosterID: ctx.User.Id, PosterID: ctx.User.ID,
Poster: ctx.User, Poster: ctx.User,
MilestoneID: milestoneID, MilestoneID: milestoneID,
AssigneeID: assigneeID, AssigneeID: assigneeID,

@ -176,7 +176,7 @@ func NewReleasePost(ctx *context.Context, form auth.NewReleaseForm) {
rel := &models.Release{ rel := &models.Release{
RepoID: ctx.Repo.Repository.ID, RepoID: ctx.Repo.Repository.ID,
PublisherID: ctx.User.Id, PublisherID: ctx.User.ID,
Title: form.Title, Title: form.Title,
TagName: form.TagName, TagName: form.TagName,
Target: form.Target, Target: form.Target,

@ -34,7 +34,7 @@ func MustBeNotBare(ctx *context.Context) {
} }
func checkContextUser(ctx *context.Context, uid int64) *models.User { func checkContextUser(ctx *context.Context, uid int64) *models.User {
orgs, err := models.GetOwnedOrgsByUserIDDesc(ctx.User.Id, "updated_unix") orgs, err := models.GetOwnedOrgsByUserIDDesc(ctx.User.ID, "updated_unix")
if err != nil { if err != nil {
ctx.Handle(500, "GetOwnedOrgsByUserIDDesc", err) ctx.Handle(500, "GetOwnedOrgsByUserIDDesc", err)
return nil return nil
@ -42,7 +42,7 @@ func checkContextUser(ctx *context.Context, uid int64) *models.User {
ctx.Data["Orgs"] = orgs ctx.Data["Orgs"] = orgs
// Not equal means current user is an organization. // Not equal means current user is an organization.
if uid == ctx.User.Id || uid == 0 { if uid == ctx.User.ID || uid == 0 {
return ctx.User return ctx.User
} }
@ -57,7 +57,7 @@ func checkContextUser(ctx *context.Context, uid int64) *models.User {
} }
// Check ownership of organization. // Check ownership of organization.
if !org.IsOrganization() || !(ctx.User.IsAdmin || org.IsOwnedBy(ctx.User.Id)) { if !org.IsOrganization() || !(ctx.User.IsAdmin || org.IsOwnedBy(ctx.User.ID)) {
ctx.Error(403) ctx.Error(403)
return nil return nil
} }
@ -136,7 +136,7 @@ func CreatePost(ctx *context.Context, form auth.CreateRepoForm) {
} }
if repo != nil { if repo != nil {
if errDelete := models.DeleteRepository(ctxUser.Id, repo.ID); errDelete != nil { if errDelete := models.DeleteRepository(ctxUser.ID, repo.ID); errDelete != nil {
log.Error(4, "DeleteRepository: %v", errDelete) log.Error(4, "DeleteRepository: %v", errDelete)
} }
} }
@ -208,7 +208,7 @@ func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) {
} }
if repo != nil { if repo != nil {
if errDelete := models.DeleteRepository(ctxUser.Id, repo.ID); errDelete != nil { if errDelete := models.DeleteRepository(ctxUser.ID, repo.ID); errDelete != nil {
log.Error(4, "DeleteRepository: %v", errDelete) log.Error(4, "DeleteRepository: %v", errDelete)
} }
} }
@ -231,13 +231,13 @@ func Action(ctx *context.Context) {
var err error var err error
switch ctx.Params(":action") { switch ctx.Params(":action") {
case "watch": case "watch":
err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.ID, true) err = models.WatchRepo(ctx.User.ID, ctx.Repo.Repository.ID, true)
case "unwatch": case "unwatch":
err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.ID, false) err = models.WatchRepo(ctx.User.ID, ctx.Repo.Repository.ID, false)
case "star": case "star":
err = models.StarRepo(ctx.User.Id, ctx.Repo.Repository.ID, true) err = models.StarRepo(ctx.User.ID, ctx.Repo.Repository.ID, true)
case "unstar": case "unstar":
err = models.StarRepo(ctx.User.Id, ctx.Repo.Repository.ID, false) err = models.StarRepo(ctx.User.ID, ctx.Repo.Repository.ID, false)
case "desc": // FIXME: this is not used case "desc": // FIXME: this is not used
if !ctx.Repo.IsOwner() { if !ctx.Repo.IsOwner() {
ctx.Error(404) ctx.Error(404)

@ -162,7 +162,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
} }
if ctx.Repo.Owner.IsOrganization() { if ctx.Repo.Owner.IsOrganization() {
if !ctx.Repo.Owner.IsOwnedBy(ctx.User.Id) { if !ctx.Repo.Owner.IsOwnedBy(ctx.User.ID) {
ctx.Error(404) ctx.Error(404)
return return
} }
@ -196,7 +196,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
} }
if ctx.Repo.Owner.IsOrganization() { if ctx.Repo.Owner.IsOrganization() {
if !ctx.Repo.Owner.IsOwnedBy(ctx.User.Id) { if !ctx.Repo.Owner.IsOwnedBy(ctx.User.ID) {
ctx.Error(404) ctx.Error(404)
return return
} }
@ -235,13 +235,13 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
} }
if ctx.Repo.Owner.IsOrganization() { if ctx.Repo.Owner.IsOrganization() {
if !ctx.Repo.Owner.IsOwnedBy(ctx.User.Id) { if !ctx.Repo.Owner.IsOwnedBy(ctx.User.ID) {
ctx.Error(404) ctx.Error(404)
return return
} }
} }
if err := models.DeleteRepository(ctx.Repo.Owner.Id, repo.ID); err != nil { if err := models.DeleteRepository(ctx.Repo.Owner.ID, repo.ID); err != nil {
ctx.Handle(500, "DeleteRepository", err) ctx.Handle(500, "DeleteRepository", err)
return return
} }
@ -261,7 +261,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) {
} }
if ctx.Repo.Owner.IsOrganization() { if ctx.Repo.Owner.IsOrganization() {
if !ctx.Repo.Owner.IsOwnedBy(ctx.User.Id) { if !ctx.Repo.Owner.IsOwnedBy(ctx.User.ID) {
ctx.Error(404) ctx.Error(404)
return return
} }
@ -321,7 +321,7 @@ func CollaborationPost(ctx *context.Context) {
} }
// Check if user is organization member. // Check if user is organization member.
if ctx.Repo.Owner.IsOrganization() && ctx.Repo.Owner.IsOrgMember(u.Id) { if ctx.Repo.Owner.IsOrganization() && ctx.Repo.Owner.IsOrgMember(u.ID) {
ctx.Flash.Info(ctx.Tr("repo.settings.user_is_org_member")) ctx.Flash.Info(ctx.Tr("repo.settings.user_is_org_member"))
ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration") ctx.Redirect(ctx.Repo.RepoLink + "/settings/collaboration")
return return
@ -371,7 +371,7 @@ func parseOwnerAndRepo(ctx *context.Context) (*models.User, *models.Repository)
return nil, nil return nil, nil
} }
repo, err := models.GetRepositoryByName(owner.Id, ctx.Params(":reponame")) repo, err := models.GetRepositoryByName(owner.ID, ctx.Params(":reponame"))
if err != nil { if err != nil {
if models.IsErrRepoNotExist(err) { if models.IsErrRepoNotExist(err) {
ctx.Handle(404, "GetRepositoryByName", err) ctx.Handle(404, "GetRepositoryByName", err)

@ -63,7 +63,7 @@ func getOrgRepoCtx(ctx *context.Context) (*OrgRepoCtx, error) {
if len(ctx.Org.OrgLink) > 0 { if len(ctx.Org.OrgLink) > 0 {
return &OrgRepoCtx{ return &OrgRepoCtx{
OrgID: ctx.Org.Organization.Id, OrgID: ctx.Org.Organization.ID,
Link: ctx.Org.OrgLink, Link: ctx.Org.OrgLink,
NewTemplate: ORG_HOOK_NEW, NewTemplate: ORG_HOOK_NEW,
}, nil }, nil
@ -224,7 +224,7 @@ func checkWebhook(ctx *context.Context) (*OrgRepoCtx, *models.Webhook) {
if orCtx.RepoID > 0 { if orCtx.RepoID > 0 {
w, err = models.GetWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) w, err = models.GetWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id"))
} else { } else {
w, err = models.GetWebhookByOrgID(ctx.Org.Organization.Id, ctx.ParamsInt64(":id")) w, err = models.GetWebhookByOrgID(ctx.Org.Organization.ID, ctx.ParamsInt64(":id"))
} }
if err != nil { if err != nil {
if models.IsErrWebhookNotExist(err) { if models.IsErrWebhookNotExist(err) {
@ -369,7 +369,7 @@ func TestWebhook(ctx *context.Context) {
}, },
Sender: &api.PayloadUser{ Sender: &api.PayloadUser{
UserName: ctx.User.Name, UserName: ctx.User.Name,
ID: ctx.User.Id, ID: ctx.User.ID,
AvatarUrl: ctx.User.AvatarLink(), AvatarUrl: ctx.User.AvatarLink(),
}, },
} }

@ -60,7 +60,7 @@ func AutoSignIn(ctx *context.Context) (bool, error) {
} }
isSucceed = true isSucceed = true
ctx.Session.Set("uid", u.Id) ctx.Session.Set("uid", u.ID)
ctx.Session.Set("uname", u.Name) ctx.Session.Set("uname", u.Name)
ctx.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubUrl) ctx.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubUrl)
return true, nil return true, nil
@ -114,7 +114,7 @@ func SignInPost(ctx *context.Context, form auth.SignInForm) {
setting.CookieRememberName, u.Name, days, setting.AppSubUrl) setting.CookieRememberName, u.Name, days, setting.AppSubUrl)
} }
ctx.Session.Set("uid", u.Id) ctx.Session.Set("uid", u.ID)
ctx.Session.Set("uname", u.Name) ctx.Session.Set("uname", u.Name)
// Clear whatever CSRF has right now, force to generate a new one // Clear whatever CSRF has right now, force to generate a new one
@ -220,7 +220,7 @@ func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, form auth.RegisterFo
} }
// Send confirmation email, no need for social account. // Send confirmation email, no need for social account.
if setting.Service.RegisterEmailConfirm && u.Id > 1 { if setting.Service.RegisterEmailConfirm && u.ID > 1 {
models.SendActivateAccountMail(ctx.Context, u) models.SendActivateAccountMail(ctx.Context, u)
ctx.Data["IsSendRegisterMail"] = true ctx.Data["IsSendRegisterMail"] = true
ctx.Data["Email"] = u.Email ctx.Data["Email"] = u.Email
@ -278,7 +278,7 @@ func Activate(ctx *context.Context) {
log.Trace("User activated: %s", user.Name) log.Trace("User activated: %s", user.Name)
ctx.Session.Set("uid", user.Id) ctx.Session.Set("uid", user.ID)
ctx.Session.Set("uname", user.Name) ctx.Session.Set("uname", user.Name)
ctx.Redirect(setting.AppSubUrl + "/") ctx.Redirect(setting.AppSubUrl + "/")
return return

@ -24,6 +24,7 @@ const (
ORG_HOME base.TplName = "org/home" ORG_HOME base.TplName = "org/home"
) )
// getDashboardContextUser finds out dashboard is viewing as which context user.
func getDashboardContextUser(ctx *context.Context) *models.User { func getDashboardContextUser(ctx *context.Context) *models.User {
ctxUser := ctx.User ctxUser := ctx.User
orgName := ctx.Params(":org") orgName := ctx.Params(":org")
@ -51,6 +52,9 @@ func getDashboardContextUser(ctx *context.Context) *models.User {
return ctxUser return ctxUser
} }
// retrieveFeeds loads feeds from database by given context user.
// The user could be organization so it is not always the logged in user,
// which is why we have to explicitly pass the context user ID.
func retrieveFeeds(ctx *context.Context, ctxUserID, userID, offset int64, isProfile bool) { func retrieveFeeds(ctx *context.Context, ctxUserID, userID, offset int64, isProfile bool) {
actions, err := models.GetFeeds(ctxUserID, userID, offset, isProfile) actions, err := models.GetFeeds(ctxUserID, userID, offset, isProfile)
if err != nil { if err != nil {
@ -84,14 +88,15 @@ func retrieveFeeds(ctx *context.Context, ctxUserID, userID, offset int64, isProf
func Dashboard(ctx *context.Context) { func Dashboard(ctx *context.Context) {
ctxUser := getDashboardContextUser(ctx) ctxUser := getDashboardContextUser(ctx)
ctx.Data["Title"] = ctxUser.DisplayName() + " - " + ctx.Tr("dashboard")
ctx.Data["PageIsDashboard"] = true
ctx.Data["PageIsNews"] = true
if ctx.Written() { if ctx.Written() {
return return
} }
ctx.Data["Title"] = ctxUser.DisplayName() + " - " + ctx.Tr("dashboard")
ctx.Data["PageIsDashboard"] = true
ctx.Data["PageIsNews"] = true
// Only user can have collaborative repositories.
if !ctxUser.IsOrganization() { if !ctxUser.IsOrganization() {
collaborateRepos, err := ctx.User.GetAccessibleRepositories() collaborateRepos, err := ctx.User.GetAccessibleRepositories()
if err != nil { if err != nil {
@ -111,14 +116,14 @@ func Dashboard(ctx *context.Context) {
var repos []*models.Repository var repos []*models.Repository
if ctxUser.IsOrganization() { if ctxUser.IsOrganization() {
if err := ctxUser.GetUserRepositories(ctx.User.Id); err != nil { if err := ctxUser.GetUserRepositories(ctx.User.ID); err != nil {
ctx.Handle(500, "GetUserRepositories", err) ctx.Handle(500, "GetUserRepositories", err)
return return
} }
repos = ctxUser.Repos repos = ctxUser.Repos
} else { } else {
var err error var err error
repos, err = models.GetRepositories(ctxUser.Id, true) repos, err = models.GetRepositories(ctxUser.ID, true)
if err != nil { if err != nil {
ctx.Handle(500, "GetRepositories", err) ctx.Handle(500, "GetRepositories", err)
return return
@ -140,7 +145,7 @@ func Dashboard(ctx *context.Context) {
ctx.Data["MirrorCount"] = len(mirrors) ctx.Data["MirrorCount"] = len(mirrors)
ctx.Data["Mirrors"] = mirrors ctx.Data["Mirrors"] = mirrors
retrieveFeeds(ctx, ctxUser.Id, ctx.User.Id, 0, false) retrieveFeeds(ctx, ctxUser.ID, ctx.User.ID, 0, false)
if ctx.Written() { if ctx.Written() {
return return
} }
@ -182,10 +187,10 @@ func Issues(ctx *context.Context) {
switch viewType { switch viewType {
case "assigned": case "assigned":
filterMode = models.FM_ASSIGN filterMode = models.FM_ASSIGN
assigneeID = ctxUser.Id assigneeID = ctxUser.ID
case "created_by": case "created_by":
filterMode = models.FM_CREATE filterMode = models.FM_CREATE
posterID = ctxUser.Id posterID = ctxUser.ID
} }
} }
@ -194,7 +199,7 @@ func Issues(ctx *context.Context) {
// Get repositories. // Get repositories.
if ctxUser.IsOrganization() { if ctxUser.IsOrganization() {
if err := ctxUser.GetUserRepositories(ctx.User.Id); err != nil { if err := ctxUser.GetUserRepositories(ctx.User.ID); err != nil {
ctx.Handle(500, "GetRepositories", err) ctx.Handle(500, "GetRepositories", err)
return return
} }
@ -227,7 +232,7 @@ func Issues(ctx *context.Context) {
if filterMode != models.FM_ALL { if filterMode != models.FM_ALL {
// Calculate repository issue count with filter mode. // Calculate repository issue count with filter mode.
numOpen, numClosed := repo.IssueStats(ctxUser.Id, filterMode, isPullList) numOpen, numClosed := repo.IssueStats(ctxUser.ID, filterMode, isPullList)
repo.NumOpenIssues, repo.NumClosedIssues = int(numOpen), int(numClosed) repo.NumOpenIssues, repo.NumClosedIssues = int(numOpen), int(numClosed)
} }
@ -239,7 +244,7 @@ func Issues(ctx *context.Context) {
} }
ctx.Data["Repos"] = showRepos ctx.Data["Repos"] = showRepos
issueStats := models.GetUserIssueStats(repoID, ctxUser.Id, repoIDs, filterMode, isPullList) issueStats := models.GetUserIssueStats(repoID, ctxUser.ID, repoIDs, filterMode, isPullList)
issueStats.AllCount = int64(allCount) issueStats.AllCount = int64(allCount)
page := ctx.QueryInt("page") page := ctx.QueryInt("page")
@ -257,7 +262,7 @@ func Issues(ctx *context.Context) {
// Get issues. // Get issues.
issues, err := models.Issues(&models.IssuesOptions{ issues, err := models.Issues(&models.IssuesOptions{
UserID: ctxUser.Id, UserID: ctxUser.ID,
AssigneeID: assigneeID, AssigneeID: assigneeID,
RepoID: repoID, RepoID: repoID,
PosterID: posterID, PosterID: posterID,
@ -328,21 +333,21 @@ func showOrgProfile(ctx *context.Context) {
if ctx.IsSigned { if ctx.IsSigned {
if ctx.User.IsAdmin { if ctx.User.IsAdmin {
repos, err := models.GetRepositories(org.Id, true) repos, err := models.GetRepositories(org.ID, true)
if err != nil { if err != nil {
ctx.Handle(500, "GetRepositoriesAsAdmin", err) ctx.Handle(500, "GetRepositoriesAsAdmin", err)
return return
} }
ctx.Data["Repos"] = repos ctx.Data["Repos"] = repos
} else { } else {
if err := org.GetUserRepositories(ctx.User.Id); err != nil { if err := org.GetUserRepositories(ctx.User.ID); err != nil {
ctx.Handle(500, "GetUserRepositories", err) ctx.Handle(500, "GetUserRepositories", err)
return return
} }
ctx.Data["Repos"] = org.Repos ctx.Data["Repos"] = org.Repos
} }
} else { } else {
repos, err := models.GetRepositories(org.Id, false) repos, err := models.GetRepositories(org.ID, false)
if err != nil { if err != nil {
ctx.Handle(500, "GetRepositories", err) ctx.Handle(500, "GetRepositories", err)
return return

@ -62,7 +62,7 @@ func Profile(ctx *context.Context) {
// Show SSH keys. // Show SSH keys.
if isShowKeys { if isShowKeys {
ShowSSHKeys(ctx, u.Id) ShowSSHKeys(ctx, u.ID)
return return
} }
@ -75,7 +75,7 @@ func Profile(ctx *context.Context) {
ctx.Data["PageIsUserProfile"] = true ctx.Data["PageIsUserProfile"] = true
ctx.Data["Owner"] = u ctx.Data["Owner"] = u
orgs, err := models.GetOrgsByUserID(u.Id, ctx.IsSigned && (ctx.User.IsAdmin || ctx.User.Id == u.Id)) orgs, err := models.GetOrgsByUserID(u.ID, ctx.IsSigned && (ctx.User.IsAdmin || ctx.User.ID == u.ID))
if err != nil { if err != nil {
ctx.Handle(500, "GetOrgsByUserIDDesc", err) ctx.Handle(500, "GetOrgsByUserIDDesc", err)
return return
@ -87,13 +87,13 @@ func Profile(ctx *context.Context) {
ctx.Data["TabName"] = tab ctx.Data["TabName"] = tab
switch tab { switch tab {
case "activity": case "activity":
retrieveFeeds(ctx, u.Id, -1, 0, true) retrieveFeeds(ctx, u.ID, -1, 0, true)
if ctx.Written() { if ctx.Written() {
return return
} }
default: default:
var err error var err error
ctx.Data["Repos"], err = models.GetRepositories(u.Id, ctx.IsSigned && ctx.User.Id == u.Id) ctx.Data["Repos"], err = models.GetRepositories(u.ID, ctx.IsSigned && ctx.User.ID == u.ID)
if err != nil { if err != nil {
ctx.Handle(500, "GetRepositories", err) ctx.Handle(500, "GetRepositories", err)
return return
@ -140,9 +140,9 @@ func Action(ctx *context.Context) {
var err error var err error
switch ctx.Params(":action") { switch ctx.Params(":action") {
case "follow": case "follow":
err = models.FollowUser(ctx.User.Id, u.Id) err = models.FollowUser(ctx.User.ID, u.ID)
case "unfollow": case "unfollow":
err = models.UnfollowUser(ctx.User.Id, u.Id) err = models.UnfollowUser(ctx.User.ID, u.ID)
} }
if err != nil { if err != nil {

@ -131,7 +131,7 @@ func UpdateAvatarSetting(ctx *context.Context, form auth.UploadAvatarForm, ctxUs
// generate a random one when needed. // generate a random one when needed.
if form.Enable && !com.IsFile(ctxUser.CustomAvatarPath()) { if form.Enable && !com.IsFile(ctxUser.CustomAvatarPath()) {
if err := ctxUser.GenerateRandomAvatar(); err != nil { if err := ctxUser.GenerateRandomAvatar(); err != nil {
log.Error(4, "GenerateRandomAvatar[%d]: %v", ctxUser.Id, err) log.Error(4, "GenerateRandomAvatar[%d]: %v", ctxUser.ID, err)
} }
} }
} }
@ -199,7 +199,7 @@ func SettingsEmails(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsEmails"] = true ctx.Data["PageIsSettingsEmails"] = true
emails, err := models.GetEmailAddresses(ctx.User.Id) emails, err := models.GetEmailAddresses(ctx.User.ID)
if err != nil { if err != nil {
ctx.Handle(500, "GetEmailAddresses", err) ctx.Handle(500, "GetEmailAddresses", err)
return return
@ -226,7 +226,7 @@ func SettingsEmailPost(ctx *context.Context, form auth.AddEmailForm) {
} }
// Add Email address. // Add Email address.
emails, err := models.GetEmailAddresses(ctx.User.Id) emails, err := models.GetEmailAddresses(ctx.User.ID)
if err != nil { if err != nil {
ctx.Handle(500, "GetEmailAddresses", err) ctx.Handle(500, "GetEmailAddresses", err)
return return
@ -239,7 +239,7 @@ func SettingsEmailPost(ctx *context.Context, form auth.AddEmailForm) {
} }
email := &models.EmailAddress{ email := &models.EmailAddress{
UID: ctx.User.Id, UID: ctx.User.ID,
Email: form.Email, Email: form.Email,
IsActivated: !setting.Service.RegisterEmailConfirm, IsActivated: !setting.Service.RegisterEmailConfirm,
} }
@ -285,7 +285,7 @@ func SettingsSSHKeys(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsSSHKeys"] = true ctx.Data["PageIsSettingsSSHKeys"] = true
keys, err := models.ListPublicKeys(ctx.User.Id) keys, err := models.ListPublicKeys(ctx.User.ID)
if err != nil { if err != nil {
ctx.Handle(500, "ListPublicKeys", err) ctx.Handle(500, "ListPublicKeys", err)
return return
@ -299,7 +299,7 @@ func SettingsSSHKeysPost(ctx *context.Context, form auth.AddSSHKeyForm) {
ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsSSHKeys"] = true ctx.Data["PageIsSettingsSSHKeys"] = true
keys, err := models.ListPublicKeys(ctx.User.Id) keys, err := models.ListPublicKeys(ctx.User.ID)
if err != nil { if err != nil {
ctx.Handle(500, "ListPublicKeys", err) ctx.Handle(500, "ListPublicKeys", err)
return return
@ -322,7 +322,7 @@ func SettingsSSHKeysPost(ctx *context.Context, form auth.AddSSHKeyForm) {
} }
} }
if _, err = models.AddPublicKey(ctx.User.Id, form.Title, content); err != nil { if _, err = models.AddPublicKey(ctx.User.ID, form.Title, content); err != nil {
ctx.Data["HasError"] = true ctx.Data["HasError"] = true
switch { switch {
case models.IsErrKeyAlreadyExist(err): case models.IsErrKeyAlreadyExist(err):
@ -357,7 +357,7 @@ func SettingsApplications(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["Title"] = ctx.Tr("settings")
ctx.Data["PageIsSettingsApplications"] = true ctx.Data["PageIsSettingsApplications"] = true
tokens, err := models.ListAccessTokens(ctx.User.Id) tokens, err := models.ListAccessTokens(ctx.User.ID)
if err != nil { if err != nil {
ctx.Handle(500, "ListAccessTokens", err) ctx.Handle(500, "ListAccessTokens", err)
return return
@ -372,7 +372,7 @@ func SettingsApplicationsPost(ctx *context.Context, form auth.NewAccessTokenForm
ctx.Data["PageIsSettingsApplications"] = true ctx.Data["PageIsSettingsApplications"] = true
if ctx.HasError() { if ctx.HasError() {
tokens, err := models.ListAccessTokens(ctx.User.Id) tokens, err := models.ListAccessTokens(ctx.User.ID)
if err != nil { if err != nil {
ctx.Handle(500, "ListAccessTokens", err) ctx.Handle(500, "ListAccessTokens", err)
return return
@ -383,7 +383,7 @@ func SettingsApplicationsPost(ctx *context.Context, form auth.NewAccessTokenForm
} }
t := &models.AccessToken{ t := &models.AccessToken{
UID: ctx.User.Id, UID: ctx.User.ID,
Name: form.Name, Name: form.Name,
} }
if err := models.NewAccessToken(t); err != nil { if err := models.NewAccessToken(t); err != nil {

@ -1 +1 @@
0.9.52.0723 0.9.53.0724

@ -27,7 +27,7 @@
<tbody> <tbody>
{{range .Users}} {{range .Users}}
<tr> <tr>
<td>{{.Id}}</td> <td>{{.ID}}</td>
<td><a href="{{.HomeLink}}">{{.Name}}</a></td> <td><a href="{{.HomeLink}}">{{.Name}}</a></td>
<td>{{.NumTeams}}</td> <td>{{.NumTeams}}</td>
<td>{{.NumMembers}}</td> <td>{{.NumMembers}}</td>

@ -102,7 +102,7 @@
<div class="field"> <div class="field">
<button class="ui green button">{{.i18n.Tr "admin.users.update_profile"}}</button> <button class="ui green button">{{.i18n.Tr "admin.users.update_profile"}}</button>
<div class="ui red button delete-button" data-url="{{$.Link}}/delete" data-id="{{.User.Id}}">{{.i18n.Tr "admin.users.delete_account"}}</div> <div class="ui red button delete-button" data-url="{{$.Link}}/delete" data-id="{{.User.ID}}">{{.i18n.Tr "admin.users.delete_account"}}</div>
</div> </div>
</form> </form>
</div> </div>

@ -31,14 +31,14 @@
<tbody> <tbody>
{{range .Users}} {{range .Users}}
<tr> <tr>
<td>{{.Id}}</td> <td>{{.ID}}</td>
<td><a href="{{AppSubUrl}}/{{.Name}}">{{.Name}}</a></td> <td><a href="{{AppSubUrl}}/{{.Name}}">{{.Name}}</a></td>
<td><span class="text truncate email">{{.Email}}</span></td> <td><span class="text truncate email">{{.Email}}</span></td>
<td><i class="fa fa{{if .IsActive}}-check{{end}}-square-o"></i></td> <td><i class="fa fa{{if .IsActive}}-check{{end}}-square-o"></i></td>
<td><i class="fa fa{{if .IsAdmin}}-check{{end}}-square-o"></i></td> <td><i class="fa fa{{if .IsAdmin}}-check{{end}}-square-o"></i></td>
<td>{{.NumRepos}}</td> <td>{{.NumRepos}}</td>
<td><span title="{{DateFmtLong .Created}}">{{DateFmtShort .Created }}</span></td> <td><span title="{{DateFmtLong .Created}}">{{DateFmtShort .Created }}</span></td>
<td><a href="{{$.Link}}/{{.Id}}"><i class="fa fa-pencil-square-o"></i></a></td> <td><a href="{{$.Link}}/{{.ID}}"><i class="fa fa-pencil-square-o"></i></a></td>
</tr> </tr>
{{end}} {{end}}
</tbody> </tbody>

@ -27,7 +27,7 @@
<div class="ui eleven wide column"> <div class="ui eleven wide column">
{{if .IsOrganizationOwner}} {{if .IsOrganizationOwner}}
<div class="text right"> <div class="text right">
<a class="ui green button" href="{{AppSubUrl}}/repo/create?org={{.Org.Id}}"><i class="octicon octicon-repo-create"></i> {{.i18n.Tr "new_repo"}}</a> <a class="ui green button" href="{{AppSubUrl}}/repo/create?org={{.Org.ID}}"><i class="octicon octicon-repo-create"></i> {{.i18n.Tr "new_repo"}}</a>
</div> </div>
<div class="ui divider"></div> <div class="ui divider"></div>
{{end}} {{end}}
@ -46,7 +46,7 @@
<div class="ui attached segment members"> <div class="ui attached segment members">
{{$isMember := .IsOrganizationMember}} {{$isMember := .IsOrganizationMember}}
{{range .Members}} {{range .Members}}
{{if or $isMember (.IsPublicMember $.Org.Id)}} {{if or $isMember (.IsPublicMember $.Org.ID)}}
<a href="{{.HomeLink}}" title="{{.Name}}{{if .FullName}} ({{.FullName}}){{end}}"><img class="ui avatar" src="{{.AvatarLink}}"></a> <a href="{{.HomeLink}}" title="{{.Name}}{{if .FullName}} ({{.FullName}}){{end}}"><img class="ui avatar" src="{{.AvatarLink}}"></a>
{{end}} {{end}}
{{end}} {{end}}

@ -25,13 +25,13 @@
{{$.i18n.Tr "org.members.membership_visibility"}} {{$.i18n.Tr "org.members.membership_visibility"}}
</div> </div>
<div class="meta"> <div class="meta">
{{ $isPublic := .IsPublicMember $.Org.Id}} {{ $isPublic := .IsPublicMember $.Org.ID}}
{{if $isPublic}} {{if $isPublic}}
<strong>{{$.i18n.Tr "org.members.public"}}</strong> <strong>{{$.i18n.Tr "org.members.public"}}</strong>
{{if or (eq $.SignedUser.Id .Id) $.IsOrganizationOwner}}(<a href="{{$.OrgLink}}/members/action/private?uid={{.Id}}">{{$.i18n.Tr "org.members.public_helper"}}</a>){{end}} {{if or (eq $.SignedUser.ID .ID) $.IsOrganizationOwner}}(<a href="{{$.OrgLink}}/members/action/private?uid={{.ID}}">{{$.i18n.Tr "org.members.public_helper"}}</a>){{end}}
{{else}} {{else}}
<strong>{{$.i18n.Tr "org.members.private"}}</strong> <strong>{{$.i18n.Tr "org.members.private"}}</strong>
{{if or (eq $.SignedUser.Id .Id) $.IsOrganizationOwner}}(<a href="{{$.OrgLink}}/members/action/public?uid={{.Id}}">{{$.i18n.Tr "org.members.private_helper"}}</a>){{end}} {{if or (eq $.SignedUser.ID .ID) $.IsOrganizationOwner}}(<a href="{{$.OrgLink}}/members/action/public?uid={{.ID}}">{{$.i18n.Tr "org.members.private_helper"}}</a>){{end}}
{{end}} {{end}}
</div> </div>
</div> </div>
@ -40,15 +40,15 @@
{{$.i18n.Tr "org.members.member_role"}} {{$.i18n.Tr "org.members.member_role"}}
</div> </div>
<div class="meta"> <div class="meta">
<strong>{{if .IsUserOrgOwner $.Org.Id}}<span class="octicon octicon-shield"></span> {{$.i18n.Tr "org.members.owner"}}{{else}}{{$.i18n.Tr "org.members.member"}}{{end}}</strong> <strong>{{if .IsUserOrgOwner $.Org.ID}}<span class="octicon octicon-shield"></span> {{$.i18n.Tr "org.members.owner"}}{{else}}{{$.i18n.Tr "org.members.member"}}{{end}}</strong>
</div> </div>
</div> </div>
<div class="ui four wide column"> <div class="ui four wide column">
<div class="text right"> <div class="text right">
{{if eq $.SignedUser.Id .Id}} {{if eq $.SignedUser.ID .ID}}
<a class="ui red small button" href="{{$.OrgLink}}/members/action/leave?uid={{.Id}}">{{$.i18n.Tr "org.members.leave"}}</a> <a class="ui red small button" href="{{$.OrgLink}}/members/action/leave?uid={{.ID}}">{{$.i18n.Tr "org.members.leave"}}</a>
{{else if $.IsOrganizationOwner}} {{else if $.IsOrganizationOwner}}
<a class="ui red small button" href="{{$.OrgLink}}/members/action/remove?uid={{.Id}}">{{$.i18n.Tr "org.members.remove"}}</a> <a class="ui red small button" href="{{$.OrgLink}}/members/action/remove?uid={{.ID}}">{{$.i18n.Tr "org.members.remove"}}</a>
{{end}} {{end}}
</div> </div>
</div> </div>

@ -13,7 +13,7 @@
{{range .Team.Members}} {{range .Team.Members}}
<div class="item"> <div class="item">
{{if $.IsOrganizationOwner}} {{if $.IsOrganizationOwner}}
<a class="ui red small button right" href="{{$.OrgLink}}/teams/{{$.Team.LowerName}}/action/remove?uid={{.Id}}">{{$.i18n.Tr "org.members.remove"}}</a> <a class="ui red small button right" href="{{$.OrgLink}}/teams/{{$.Team.LowerName}}/action/remove?uid={{.ID}}">{{$.i18n.Tr "org.members.remove"}}</a>
{{end}} {{end}}
<a href="{{.HomeLink}}"> <a href="{{.HomeLink}}">
<img class="ui avatar image" src="{{.AvatarLink}}"> <img class="ui avatar image" src="{{.AvatarLink}}">
@ -26,7 +26,7 @@
<div class="ui bottom attached segment"> <div class="ui bottom attached segment">
<form class="ui form" id="add-member-form" action="{{$.OrgLink}}/teams/{{$.Team.LowerName}}/action/add" method="post"> <form class="ui form" id="add-member-form" action="{{$.OrgLink}}/teams/{{$.Team.LowerName}}/action/add" method="post">
{{.CsrfTokenHtml}} {{.CsrfTokenHtml}}
<input type="hidden" name="uid" value="{{.SignedUser.Id}}"> <input type="hidden" name="uid" value="{{.SignedUser.ID}}">
<div class="inline field ui left"> <div class="inline field ui left">
<div id="search-user-box"> <div id="search-user-box">
<div class="ui input"> <div class="ui input">

@ -28,7 +28,7 @@
<form class="ui form" id="add-repo-form" action="{{$.OrgLink}}/teams/{{$.Team.LowerName}}/action/repo/add" method="post"> <form class="ui form" id="add-repo-form" action="{{$.OrgLink}}/teams/{{$.Team.LowerName}}/action/repo/add" method="post">
{{.CsrfTokenHtml}} {{.CsrfTokenHtml}}
<div class="inline field ui left"> <div class="inline field ui left">
<div id="search-repo-box" data-uid="{{.Org.Id}}"> <div id="search-repo-box" data-uid="{{.Org.ID}}">
<div class="ui input"> <div class="ui input">
<input class="prompt" name="repo_name" placeholder="{{.i18n.Tr "org.teams.search_repo_placeholder"}}" autocomplete="off" required> <input class="prompt" name="repo_name" placeholder="{{.i18n.Tr "org.teams.search_repo_placeholder"}}" autocomplete="off" required>
</div> </div>

@ -2,10 +2,10 @@
<h4 class="ui top attached header"> <h4 class="ui top attached header">
<strong>{{.Team.Name}}</strong> <strong>{{.Team.Name}}</strong>
<div class="ui right"> <div class="ui right">
{{if .Team.IsMember $.SignedUser.Id}} {{if .Team.IsMember $.SignedUser.ID}}
<a class="ui red tiny button" href="{{.OrgLink}}/teams/{{.Team.LowerName}}/action/leave?uid={{$.SignedUser.Id}}&page=team">{{$.i18n.Tr "org.teams.leave"}}</a> <a class="ui red tiny button" href="{{.OrgLink}}/teams/{{.Team.LowerName}}/action/leave?uid={{$.SignedUser.ID}}&page=team">{{$.i18n.Tr "org.teams.leave"}}</a>
{{else if .IsOrganizationOwner}} {{else if .IsOrganizationOwner}}
<a class="ui blue tiny button" href="{{.OrgLink}}/teams/{{.Team.LowerName}}/action/join?uid={{$.SignedUser.Id}}&page=team">{{$.i18n.Tr "org.teams.join"}}</a> <a class="ui blue tiny button" href="{{.OrgLink}}/teams/{{.Team.LowerName}}/action/join?uid={{$.SignedUser.ID}}&page=team">{{$.i18n.Tr "org.teams.join"}}</a>
{{end}} {{end}}
</div> </div>
</h4> </h4>

@ -16,10 +16,10 @@
<div class="ui top attached header"> <div class="ui top attached header">
<a class="text black" href="{{$.OrgLink}}/teams/{{.LowerName}}"><strong>{{.Name}}</strong></a> <a class="text black" href="{{$.OrgLink}}/teams/{{.LowerName}}"><strong>{{.Name}}</strong></a>
<div class="ui right"> <div class="ui right">
{{if .IsMember $.SignedUser.Id}} {{if .IsMember $.SignedUser.ID}}
<a class="ui red small button" href="{{$.OrgLink}}/teams/{{.LowerName}}/action/leave?uid={{$.SignedUser.Id}}">{{$.i18n.Tr "org.teams.leave"}}</a> <a class="ui red small button" href="{{$.OrgLink}}/teams/{{.LowerName}}/action/leave?uid={{$.SignedUser.ID}}">{{$.i18n.Tr "org.teams.leave"}}</a>
{{else if $.IsOrganizationOwner}} {{else if $.IsOrganizationOwner}}
<a class="ui blue small button" href="{{$.OrgLink}}/teams/{{.LowerName}}/action/join?uid={{$.SignedUser.Id}}">{{$.i18n.Tr "org.teams.join"}}</a> <a class="ui blue small button" href="{{$.OrgLink}}/teams/{{.LowerName}}/action/join?uid={{$.SignedUser.ID}}">{{$.i18n.Tr "org.teams.join"}}</a>
{{end}} {{end}}
</div> </div>
</div> </div>

@ -12,19 +12,19 @@
<div class="inline required field {{if .Err_Owner}}error{{end}}"> <div class="inline required field {{if .Err_Owner}}error{{end}}">
<label>{{.i18n.Tr "repo.owner"}}</label> <label>{{.i18n.Tr "repo.owner"}}</label>
<div class="ui selection owner dropdown"> <div class="ui selection owner dropdown">
<input type="hidden" id="uid" name="uid" value="{{.ContextUser.Id}}" required> <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required>
<span class="text"> <span class="text">
<img class="ui mini image" src="{{.ContextUser.AvatarLink}}"> <img class="ui mini image" src="{{.ContextUser.AvatarLink}}">
{{.ContextUser.ShortName 20}} {{.ContextUser.ShortName 20}}
</span> </span>
<i class="dropdown icon"></i> <i class="dropdown icon"></i>
<div class="menu"> <div class="menu">
<div class="item" data-value="{{.SignedUser.Id}}"> <div class="item" data-value="{{.SignedUser.ID}}">
<img class="ui mini image" src="{{.SignedUser.AvatarLink}}"> <img class="ui mini image" src="{{.SignedUser.AvatarLink}}">
{{.SignedUser.ShortName 20}} {{.SignedUser.ShortName 20}}
</div> </div>
{{range .Orgs}} {{range .Orgs}}
<div class="item" data-value="{{.Id}}"> <div class="item" data-value="{{.ID}}">
<img class="ui mini image" src="{{.AvatarLink}}"> <img class="ui mini image" src="{{.AvatarLink}}">
{{.ShortName 20}} {{.ShortName 20}}
</div> </div>

@ -61,7 +61,7 @@
<div class="menu"> <div class="menu">
<a class="item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}">{{.i18n.Tr "repo.issues.filter_assginee_no_select"}}</a> <a class="item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{.SelectLabels}}&milestone={{$.MilestoneID}}">{{.i18n.Tr "repo.issues.filter_assginee_no_select"}}</a>
{{range .Assignees}} {{range .Assignees}}
<a class="{{if eq $.AssigneeID .Id}}active selected{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&assignee={{.Id}}"><img src="{{.AvatarLink}}"> {{.Name}}</a> <a class="{{if eq $.AssigneeID .ID}}active selected{{end}} item" href="{{$.Link}}?type={{$.ViewType}}&sort={{$.SortType}}&state={{$.State}}&labels={{$.SelectLabels}}&milestone={{$.MilestoneID}}&assignee={{.ID}}"><img src="{{.AvatarLink}}"> {{.Name}}</a>
{{end}} {{end}}
</div> </div>
</div> </div>

@ -104,7 +104,7 @@
<div class="menu"> <div class="menu">
<div class="no-select item">{{.i18n.Tr "repo.issues.new.clear_assignee"}}</div> <div class="no-select item">{{.i18n.Tr "repo.issues.new.clear_assignee"}}</div>
{{range .Assignees}} {{range .Assignees}}
<div class="item" data-id="{{.Id}}" data-href="{{$.RepoLink}}/issues?assignee={{.Id}}" data-avatar="{{.AvatarLink}}"><img src="{{.AvatarLink}}"> {{.Name}}</div> <div class="item" data-id="{{.ID}}" data-href="{{$.RepoLink}}/issues?assignee={{.ID}}" data-avatar="{{.AvatarLink}}"><img src="{{.AvatarLink}}"> {{.Name}}</div>
{{end}} {{end}}
</div> </div>
</div> </div>
@ -112,7 +112,7 @@
<span class="no-select item {{if .Assignee}}hide{{end}}">{{.i18n.Tr "repo.issues.new.no_assignee"}}</span> <span class="no-select item {{if .Assignee}}hide{{end}}">{{.i18n.Tr "repo.issues.new.no_assignee"}}</span>
<div class="selected"> <div class="selected">
{{if .Assignee}} {{if .Assignee}}
<a class="item" href="{{.RepoLink}}/issues?assignee={{.Assignee.Id}}"><img class="ui avatar image" src="{{.Assignee.AvatarLink}}"> {{.Assignee.Name}}</a> <a class="item" href="{{.RepoLink}}/issues?assignee={{.Assignee.ID}}"><img class="ui avatar image" src="{{.Assignee.AvatarLink}}"> {{.Assignee.Name}}</a>
{{end}} {{end}}
</div> </div>
</div> </div>

@ -12,12 +12,12 @@
<div class="twelve wide column comment-list"> <div class="twelve wide column comment-list">
<ui class="ui comments"> <ui class="ui comments">
<div class="comment"> <div class="comment">
<a class="avatar" {{if gt .Issue.Poster.Id 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}> <a class="avatar" {{if gt .Issue.Poster.ID 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}>
<img src="{{.Issue.Poster.AvatarLink}}"> <img src="{{.Issue.Poster.AvatarLink}}">
</a> </a>
<div class="content"> <div class="content">
<div class="ui top attached header"> <div class="ui top attached header">
<span class="text grey"><a {{if gt .Issue.Poster.Id 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}>{{.Issue.Poster.Name}}</a> {{.i18n.Tr "repo.issues.commented_at" .Issue.HashTag $createdStr | Safe}}</span> <span class="text grey"><a {{if gt .Issue.Poster.ID 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}>{{.Issue.Poster.Name}}</a> {{.i18n.Tr "repo.issues.commented_at" .Issue.HashTag $createdStr | Safe}}</span>
<div class="ui right actions"> <div class="ui right actions">
{{if .IsIssueOwner}} {{if .IsIssueOwner}}
<a class="edit-content item" href="#"><i class="octicon octicon-pencil"></i></a> <a class="edit-content item" href="#"><i class="octicon octicon-pencil"></i></a>
@ -53,12 +53,12 @@
<!-- 0 = COMMENT, 1 = REOPEN, 2 = CLOSE, 3 = ISSUE_REF, 4 = COMMIT_REF, 5 = COMMENT_REF, 6 = PULL_REF --> <!-- 0 = COMMENT, 1 = REOPEN, 2 = CLOSE, 3 = ISSUE_REF, 4 = COMMIT_REF, 5 = COMMENT_REF, 6 = PULL_REF -->
{{if eq .Type 0}} {{if eq .Type 0}}
<div class="comment"> <div class="comment">
<a class="avatar" {{if gt .Poster.Id 0}}href="{{.Poster.HomeLink}}"{{end}}> <a class="avatar" {{if gt .Poster.ID 0}}href="{{.Poster.HomeLink}}"{{end}}>
<img src="{{.Poster.AvatarLink}}"> <img src="{{.Poster.AvatarLink}}">
</a> </a>
<div class="content"> <div class="content">
<div class="ui top attached header"> <div class="ui top attached header">
<span class="text grey"><a {{if gt .Poster.Id 0}}href="{{.Poster.HomeLink}}"{{end}}>{{.Poster.Name}}</a> {{$.i18n.Tr "repo.issues.commented_at" .HashTag $createdStr | Safe}}</span> <span class="text grey"><a {{if gt .Poster.ID 0}}href="{{.Poster.HomeLink}}"{{end}}>{{.Poster.Name}}</a> {{$.i18n.Tr "repo.issues.commented_at" .HashTag $createdStr | Safe}}</span>
<div class="ui right actions"> <div class="ui right actions">
{{if gt .ShowTag 0}} {{if gt .ShowTag 0}}
<div class="item tag"> <div class="item tag">
@ -71,7 +71,7 @@
{{end}} {{end}}
</div> </div>
{{end}} {{end}}
{{if or $.IsRepositoryAdmin (eq .Poster.Id $.SignedUserID)}} {{if or $.IsRepositoryAdmin (eq .Poster.ID $.SignedUserID)}}
<a class="edit-content item" href="#"><i class="octicon octicon-pencil"></i></a> <a class="edit-content item" href="#"><i class="octicon octicon-pencil"></i></a>
{{end}} {{end}}
</div> </div>
@ -304,7 +304,7 @@
<div class="menu" data-action="update" data-update-url="{{$.RepoLink}}/issues/{{$.Issue.Index}}/assignee"> <div class="menu" data-action="update" data-update-url="{{$.RepoLink}}/issues/{{$.Issue.Index}}/assignee">
<div class="no-select item">{{.i18n.Tr "repo.issues.new.clear_assignee"}}</div> <div class="no-select item">{{.i18n.Tr "repo.issues.new.clear_assignee"}}</div>
{{range .Assignees}} {{range .Assignees}}
<div class="item" data-id="{{.Id}}" data-href="{{$.RepoLink}}/issues?assignee={{.Id}}" data-avatar="{{.AvatarLink}}"><img src="{{.AvatarLink}}"> {{.Name}}</div> <div class="item" data-id="{{.ID}}" data-href="{{$.RepoLink}}/issues?assignee={{.ID}}" data-avatar="{{.AvatarLink}}"><img src="{{.AvatarLink}}"> {{.Name}}</div>
{{end}} {{end}}
</div> </div>
</div> </div>
@ -312,7 +312,7 @@
<span class="no-select item {{if .Issue.Assignee}}hide{{end}}">{{.i18n.Tr "repo.issues.new.no_assignee"}}</span> <span class="no-select item {{if .Issue.Assignee}}hide{{end}}">{{.i18n.Tr "repo.issues.new.no_assignee"}}</span>
<div class="selected"> <div class="selected">
{{if .Issue.Assignee}} {{if .Issue.Assignee}}
<a class="item" href="{{$.RepoLink}}/issues?assignee={{.Issue.Assignee.Id}}"><img class="ui avatar image" src="{{.Issue.Assignee.AvatarLink}}"> {{.Issue.Assignee.Name}}</a> <a class="item" href="{{$.RepoLink}}/issues?assignee={{.Issue.Assignee.ID}}"><img class="ui avatar image" src="{{.Issue.Assignee.AvatarLink}}"> {{.Issue.Assignee.Name}}</a>
{{end}} {{end}}
</div> </div>
</div> </div>

@ -27,16 +27,16 @@
{{if .Issue.IsPull}} {{if .Issue.IsPull}}
{{if .Issue.HasMerged}} {{if .Issue.HasMerged}}
{{ $mergedStr:= TimeSince .Issue.Merged $.Lang }} {{ $mergedStr:= TimeSince .Issue.Merged $.Lang }}
<a {{if gt .Issue.Merger.Id 0}}href="{{.Issue.Merger.HomeLink}}"{{end}}>{{.Issue.Merger.Name}}</a> <a {{if gt .Issue.Merger.ID 0}}href="{{.Issue.Merger.HomeLink}}"{{end}}>{{.Issue.Merger.Name}}</a>
<span class="pull-desc">{{$.i18n.Tr "repo.pulls.merged_title_desc" .NumCommits .HeadTarget .BaseTarget $mergedStr | Safe}}</span> <span class="pull-desc">{{$.i18n.Tr "repo.pulls.merged_title_desc" .NumCommits .HeadTarget .BaseTarget $mergedStr | Safe}}</span>
{{else}} {{else}}
<a {{if gt .Issue.Poster.Id 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}>{{.Issue.Poster.Name}}</a> <a {{if gt .Issue.Poster.ID 0}}href="{{.Issue.Poster.HomeLink}}"{{end}}>{{.Issue.Poster.Name}}</a>
<span class="pull-desc">{{$.i18n.Tr "repo.pulls.title_desc" .NumCommits .HeadTarget .BaseTarget | Str2html}}</span> <span class="pull-desc">{{$.i18n.Tr "repo.pulls.title_desc" .NumCommits .HeadTarget .BaseTarget | Str2html}}</span>
{{end}} {{end}}
{{else}} {{else}}
{{ $createdStr:= TimeSince .Issue.Created $.Lang }} {{ $createdStr:= TimeSince .Issue.Created $.Lang }}
<span class="time-desc"> <span class="time-desc">
{{if gt .Issue.Poster.Id 0}} {{if gt .Issue.Poster.ID 0}}
{{$.i18n.Tr "repo.issues.opened_by" $createdStr .Issue.Poster.HomeLink .Issue.Poster.Name | Safe}} {{$.i18n.Tr "repo.issues.opened_by" $createdStr .Issue.Poster.HomeLink .Issue.Poster.Name | Safe}}
{{else}} {{else}}
{{$.i18n.Tr "repo.issues.opened_by_fake" $createdStr .Issue.Poster.Name | Safe}} {{$.i18n.Tr "repo.issues.opened_by_fake" $createdStr .Issue.Poster.Name | Safe}}

@ -37,19 +37,19 @@
<div class="inline required field {{if .Err_Owner}}error{{end}}"> <div class="inline required field {{if .Err_Owner}}error{{end}}">
<label>{{.i18n.Tr "repo.owner"}}</label> <label>{{.i18n.Tr "repo.owner"}}</label>
<div class="ui selection owner dropdown"> <div class="ui selection owner dropdown">
<input type="hidden" id="uid" name="uid" value="{{.ContextUser.Id}}" required> <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required>
<span class="text"> <span class="text">
<img class="ui mini image" src="{{.ContextUser.AvatarLink}}"> <img class="ui mini image" src="{{.ContextUser.AvatarLink}}">
{{.ContextUser.ShortName 20}} {{.ContextUser.ShortName 20}}
</span> </span>
<i class="dropdown icon"></i> <i class="dropdown icon"></i>
<div class="menu"> <div class="menu">
<div class="item" data-value="{{.SignedUser.Id}}"> <div class="item" data-value="{{.SignedUser.ID}}">
<img class="ui mini image" src="{{.SignedUser.AvatarLink}}"> <img class="ui mini image" src="{{.SignedUser.AvatarLink}}">
{{.SignedUser.ShortName 20}} {{.SignedUser.ShortName 20}}
</div> </div>
{{range .Orgs}} {{range .Orgs}}
<div class="item" data-value="{{.Id}}"> <div class="item" data-value="{{.ID}}">
<img class="ui mini image" src="{{.AvatarLink}}"> <img class="ui mini image" src="{{.AvatarLink}}">
{{.ShortName 20}} {{.ShortName 20}}
</div> </div>

@ -12,20 +12,20 @@
<div class="inline required field {{if .Err_Owner}}error{{end}}"> <div class="inline required field {{if .Err_Owner}}error{{end}}">
<label>{{.i18n.Tr "repo.owner"}}</label> <label>{{.i18n.Tr "repo.owner"}}</label>
<div class="ui selection owner dropdown"> <div class="ui selection owner dropdown">
<input type="hidden" id="uid" name="uid" value="{{.ContextUser.Id}}" required> <input type="hidden" id="uid" name="uid" value="{{.ContextUser.ID}}" required>
<span class="text"> <span class="text">
<img class="ui mini image" src="{{.ContextUser.AvatarLink}}"> <img class="ui mini image" src="{{.ContextUser.AvatarLink}}">
{{.ContextUser.ShortName 20}} {{.ContextUser.ShortName 20}}
</span> </span>
<i class="dropdown icon"></i> <i class="dropdown icon"></i>
<div class="menu"> <div class="menu">
<div class="item" data-value="{{.SignedUser.Id}}"> <div class="item" data-value="{{.SignedUser.ID}}">
<img class="ui mini image" src="{{.SignedUser.AvatarLink}}"> <img class="ui mini image" src="{{.SignedUser.AvatarLink}}">
{{.SignedUser.ShortName 20}} {{.SignedUser.ShortName 20}}
</div> </div>
{{range .Orgs}} {{range .Orgs}}
{{if .IsOwnedBy $.SignedUser.Id}} {{if .IsOwnedBy $.SignedUser.ID}}
<div class="item" data-value="{{.Id}}"> <div class="item" data-value="{{.ID}}">
<img class="ui mini image" src="{{.AvatarLink}}"> <img class="ui mini image" src="{{.AvatarLink}}">
{{.ShortName 20}} {{.ShortName 20}}
</div> </div>

@ -23,7 +23,7 @@
<div class="ui inline dropdown"> <div class="ui inline dropdown">
<div class="text">{{$.i18n.Tr .Collaboration.ModeI18nKey}}</div> <div class="text">{{$.i18n.Tr .Collaboration.ModeI18nKey}}</div>
<i class="dropdown icon"></i> <i class="dropdown icon"></i>
<div class="access-mode menu" data-url="{{$.Link}}/access_mode" data-uid="{{.Id}}"> <div class="access-mode menu" data-url="{{$.Link}}/access_mode" data-uid="{{.ID}}">
<div class="item" data-text="{{$.i18n.Tr "repo.settings.collaboration.admin"}}" data-value="3">{{$.i18n.Tr "repo.settings.collaboration.admin"}}</div> <div class="item" data-text="{{$.i18n.Tr "repo.settings.collaboration.admin"}}" data-value="3">{{$.i18n.Tr "repo.settings.collaboration.admin"}}</div>
<div class="item" data-text="{{$.i18n.Tr "repo.settings.collaboration.write"}}" data-value="2">{{$.i18n.Tr "repo.settings.collaboration.write"}}</div> <div class="item" data-text="{{$.i18n.Tr "repo.settings.collaboration.write"}}" data-value="2">{{$.i18n.Tr "repo.settings.collaboration.write"}}</div>
<div class="item" data-text="{{$.i18n.Tr "repo.settings.collaboration.read"}}" data-value="1">{{$.i18n.Tr "repo.settings.collaboration.read"}}</div> <div class="item" data-text="{{$.i18n.Tr "repo.settings.collaboration.read"}}" data-value="1">{{$.i18n.Tr "repo.settings.collaboration.read"}}</div>
@ -31,7 +31,7 @@
</div> </div>
</div> </div>
<div class="ui two wide column"> <div class="ui two wide column">
<button class="ui red tiny button inline text-thin delete-button" data-url="{{$.Link}}/delete" data-id="{{.Id}}"> <button class="ui red tiny button inline text-thin delete-button" data-url="{{$.Link}}/delete" data-id="{{.ID}}">
{{$.i18n.Tr "repo.settings.delete_collaborator"}} {{$.i18n.Tr "repo.settings.delete_collaborator"}}
</button> </button>
</div> </div>

@ -10,12 +10,12 @@
{{.i18n.Tr "home.switch_dashboard_context"}} {{.i18n.Tr "home.switch_dashboard_context"}}
</div> </div>
<div class="items"> <div class="items">
<a class="{{if eq .ContextUser.Id .SignedUser.Id}}active selected{{end}} item" href="{{AppSubUrl}}/{{if .PageIsIssues}}issues{{else if .PageIsPulls}}pulls{{end}}"> <a class="{{if eq .ContextUser.ID .SignedUser.ID}}active selected{{end}} item" href="{{AppSubUrl}}/{{if .PageIsIssues}}issues{{else if .PageIsPulls}}pulls{{end}}">
<img class="ui avatar image" src="{{.SignedUser.AvatarLink}}"> <img class="ui avatar image" src="{{.SignedUser.AvatarLink}}">
{{.SignedUser.Name}} {{.SignedUser.Name}}
</a> </a>
{{range .Orgs}} {{range .Orgs}}
<a class="{{if eq $.ContextUser.Id .Id}}active selected{{end}} item" href="{{AppSubUrl}}/org/{{.Name}}/{{if $.PageIsIssues}}issues{{else if $.PageIsPulls}}pulls{{else}}dashboard{{end}}"> <a class="{{if eq $.ContextUser.ID .ID}}active selected{{end}} item" href="{{AppSubUrl}}/org/{{.Name}}/{{if $.PageIsIssues}}issues{{else if $.PageIsPulls}}pulls{{else}}dashboard{{end}}">
<img class="ui avatar image" src="{{.AvatarLink}}"> <img class="ui avatar image" src="{{.AvatarLink}}">
{{.ShortName 20}} {{.ShortName 20}}
</a> </a>

@ -11,7 +11,7 @@
{{if or $.PageIsFollowers $.PageIsFollowing}} {{if or $.PageIsFollowers $.PageIsFollowing}}
{{if and $.IsSigned (ne $.SignedUserName .Name)}} {{if and $.IsSigned (ne $.SignedUserName .Name)}}
<div class="follow"> <div class="follow">
{{if $.SignedUser.IsFollowing .Id}} {{if $.SignedUser.IsFollowing .ID}}
<a class="ui small basic red button" href="{{.HomeLink}}/action/unfollow?redirect_to={{$.Link}}"><i class="octicon octicon-person"></i> {{$.i18n.Tr "user.unfollow"}}</a> <a class="ui small basic red button" href="{{.HomeLink}}/action/unfollow?redirect_to={{$.Link}}"><i class="octicon octicon-person"></i> {{$.i18n.Tr "user.unfollow"}}</a>
{{else}} {{else}}
<a class="ui small basic green button" href="{{.HomeLink}}/action/follow?redirect_to={{$.Link}}"><i class="octicon octicon-person"></i> {{$.i18n.Tr "user.follow"}}</a> <a class="ui small basic green button" href="{{.HomeLink}}/action/follow?redirect_to={{$.Link}}"><i class="octicon octicon-person"></i> {{$.i18n.Tr "user.follow"}}</a>

@ -62,7 +62,7 @@
{{end}} {{end}}
{{if and .IsSigned (ne .SignedUserName .Owner.Name)}} {{if and .IsSigned (ne .SignedUserName .Owner.Name)}}
<li class="follow"> <li class="follow">
{{if .SignedUser.IsFollowing .Owner.Id}} {{if .SignedUser.IsFollowing .Owner.ID}}
<a class="ui basic red button" href="{{.Link}}/action/unfollow?redirect_to={{$.Link}}"><i class="octicon octicon-person"></i> {{.i18n.Tr "user.unfollow"}}</a> <a class="ui basic red button" href="{{.Link}}/action/unfollow?redirect_to={{$.Link}}"><i class="octicon octicon-person"></i> {{.i18n.Tr "user.unfollow"}}</a>
{{else}} {{else}}
<a class="ui basic green button" href="{{.Link}}/action/follow?redirect_to={{$.Link}}"><i class="octicon octicon-person"></i> {{.i18n.Tr "user.follow"}}</a> <a class="ui basic green button" href="{{.Link}}/action/follow?redirect_to={{$.Link}}"><i class="octicon octicon-person"></i> {{.i18n.Tr "user.follow"}}</a>

Loading…
Cancel
Save