diff --git a/README.md b/README.md index f1428768b..848a2fb1e 100644 --- a/README.md +++ b/README.md @@ -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) -##### 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 | |:-------------:|:-------:|:-------:| diff --git a/cmd/serve.go b/cmd/serve.go index 2759e1b57..ccbddeacf 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -103,7 +103,7 @@ func handleUpdateTask(uuid string, user, repoUser *models.User, reponame string, RefName: task.RefName, OldCommitID: task.OldCommitID, NewCommitID: task.NewCommitID, - PusherID: user.Id, + PusherID: user.ID, PusherName: user.Name, RepoUserName: repoUser.Name, RepoName: reponame, @@ -175,7 +175,7 @@ func runServ(c *cli.Context) error { 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 models.IsErrRepoNotExist(err) { fail(_ACCESS_DENIED_MESSAGE, "Repository does not exist: %s/%s", repoUser.Name, reponame) diff --git a/gogs.go b/gogs.go index 64bb1980e..494d10923 100644 --- a/gogs.go +++ b/gogs.go @@ -17,7 +17,7 @@ import ( "github.com/gogits/gogs/modules/setting" ) -const APP_VER = "0.9.52.0723" +const APP_VER = "0.9.53.0724" func init() { runtime.GOMAXPROCS(runtime.NumCPU()) diff --git a/models/access.go b/models/access.go index b4c1349b6..32e9b6ea8 100644 --- a/models/access.go +++ b/models/access.go @@ -67,11 +67,11 @@ func accessLevel(e Engine, u *User, repo *Repository) (AccessMode, error) { return mode, nil } - if u.Id == repo.OwnerID { + if u.ID == repo.OwnerID { 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 { 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. func (u *User) GetRepositoryAccesses() (map[*Repository]AccessMode, error) { 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 } @@ -113,7 +113,7 @@ func (u *User) GetRepositoryAccesses() (map[*Repository]AccessMode, error) { } if err = repo.GetOwner(); err != nil { return nil, err - } else if repo.OwnerID == u.Id { + } else if repo.OwnerID == u.ID { continue } 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. func (u *User) GetAccessibleRepositories() ([]*Repository, error) { 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 } @@ -137,7 +137,7 @@ func (u *User) GetAccessibleRepositories() ([]*Repository, error) { repoIDs = append(repoIDs, access.RepoID) } 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 { @@ -227,7 +227,7 @@ func (repo *Repository) recalculateTeamAccesses(e Engine, ignTeamID int64) (err return fmt.Errorf("getMembers '%d': %v", t.ID, err) } for _, m := range t.Members { - accessMap[m.Id] = maxAccessMode(accessMap[m.Id], t.Authorize) + accessMap[m.ID] = maxAccessMode(accessMap[m.ID], t.Authorize) } } diff --git a/models/action.go b/models/action.go index 62252c6c5..23b526ee9 100644 --- a/models/action.go +++ b/models/action.go @@ -184,7 +184,7 @@ func (a *Action) GetIssueContent() string { func newRepoAction(e Engine, u *User, repo *Repository) (err error) { if err = notifyWatchers(e, &Action{ - ActUserID: u.Id, + ActUserID: u.ID, ActUserName: u.Name, ActEmail: u.Email, OpType: ACTION_CREATE_REPO, @@ -193,7 +193,7 @@ func newRepoAction(e Engine, u *User, repo *Repository) (err error) { RepoName: repo.Name, IsPrivate: repo.IsPrivate, }); 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) @@ -207,7 +207,7 @@ func NewRepoAction(u *User, repo *Repository) (err error) { func renameRepoAction(e Engine, actUser *User, oldRepoName string, repo *Repository) (err error) { if err = notifyWatchers(e, &Action{ - ActUserID: actUser.Id, + ActUserID: actUser.ID, ActUserName: actUser.Name, ActEmail: actUser.Email, OpType: ACTION_RENAME_REPO, @@ -482,7 +482,7 @@ func CommitRepoAction( refName := git.RefEndName(refFullName) if err = NotifyWatchers(&Action{ - ActUserID: u.Id, + ActUserID: u.ID, ActUserName: userName, ActEmail: actEmail, OpType: opType, @@ -506,7 +506,7 @@ func CommitRepoAction( } payloadSender := &api.PayloadUser{ UserName: pusher.Name, - ID: pusher.Id, + ID: pusher.ID, AvatarUrl: pusher.AvatarLink(), } @@ -553,7 +553,7 @@ func CommitRepoAction( func transferRepoAction(e Engine, actUser, oldOwner, newOwner *User, repo *Repository) (err error) { if err = notifyWatchers(e, &Action{ - ActUserID: actUser.Id, + ActUserID: actUser.ID, ActUserName: actUser.Name, ActEmail: actUser.Email, OpType: ACTION_TRANSFER_REPO, @@ -563,12 +563,12 @@ func transferRepoAction(e Engine, actUser, oldOwner, newOwner *User, repo *Repos IsPrivate: repo.IsPrivate, Content: path.Join(oldOwner.Name, repo.Name), }); 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. 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) } } @@ -584,7 +584,7 @@ func TransferRepoAction(actUser, oldOwner, newOwner *User, repo *Repository) err func mergePullRequestAction(e Engine, actUser *User, repo *Repository, pull *Issue) error { return notifyWatchers(e, &Action{ - ActUserID: actUser.Id, + ActUserID: actUser.ID, ActUserName: actUser.Name, ActEmail: actUser.Email, OpType: ACTION_MERGE_PULL_REQUEST, @@ -610,7 +610,7 @@ func GetFeeds(ctxUserID, userID, offset int64, isProfile bool) ([]*Action, error if isProfile { sess.And("is_private=?", false).And("act_user_id=?", ctxUserID) } else if ctxUserID != -1 { - ctxUser := &User{Id: ctxUserID} + ctxUser := &User{ID: ctxUserID} if err := ctxUser.GetUserRepositories(userID); err != nil { return nil, err } diff --git a/models/issue.go b/models/issue.go index f3cbb71e8..b8183b94e 100644 --- a/models/issue.go +++ b/models/issue.go @@ -336,7 +336,7 @@ func newIssue(e *xorm.Session, repo *Repository, issue *Issue, labelIDs []int64, if issue.AssigneeID > 0 { // 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 { return fmt.Errorf("hasAccess: %v", err) } else if !valid { @@ -428,7 +428,7 @@ func NewIssue(repo *Repository, issue *Issue, labelIDs []int64, uuids []string) // Notify watchers. act := &Action{ - ActUserID: issue.Poster.Id, + ActUserID: issue.Poster.ID, ActUserName: issue.Poster.Name, ActEmail: issue.Poster.Email, OpType: ACTION_CREATE_ISSUE, @@ -632,7 +632,7 @@ func newIssueUsers(e *xorm.Session, repo *Repository, issue *Issue) error { isNeedAddPoster := true for _, u := range users { iu.ID = 0 - iu.UID = u.Id + iu.UID = u.ID iu.IsPoster = iu.UID == issue.PosterID if isNeedAddPoster && iu.IsPoster { isNeedAddPoster = false @@ -736,15 +736,15 @@ func UpdateIssueMentions(issueID int64, mentions []string) error { ids := make([]int64, 0, len(mentions)) for _, user := range users { - ids = append(ids, user.Id) + ids = append(ids, user.ID) if !user.IsOrganization() || user.NumMembers == 0 { continue } memberIDs := make([]int64, 0, user.NumMembers) - orgUsers, err := GetOrgUsersByOrgID(user.Id) + orgUsers, err := GetOrgUsersByOrgID(user.ID) 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 { diff --git a/models/issue_comment.go b/models/issue_comment.go index 479da9206..faa257789 100644 --- a/models/issue_comment.go +++ b/models/issue_comment.go @@ -140,7 +140,7 @@ func (cmt *Comment) MailParticipants(opType ActionType, issue *Issue) (err error func createComment(e *xorm.Session, opts *CreateCommentOptions) (_ *Comment, err error) { comment := &Comment{ Type: opts.Type, - PosterID: opts.Doer.Id, + PosterID: opts.Doer.ID, Poster: opts.Doer, IssueID: opts.Issue.ID, 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. // This object will be used to notify watchers in the end of function. act := &Action{ - ActUserID: opts.Doer.Id, + ActUserID: opts.Doer.ID, ActUserName: opts.Doer.Name, ActEmail: opts.Doer.Email, Content: fmt.Sprintf("%d|%s", opts.Issue.Index, strings.Split(opts.Content, "\n")[0]), diff --git a/models/issue_mail.go b/models/issue_mail.go index 3260de271..5441a4546 100644 --- a/models/issue_mail.go +++ b/models/issue_mail.go @@ -33,7 +33,7 @@ func mailIssueCommentToParticipants(issue *Issue, doer *User, mentions []string) tos := make([]string, 0, len(watchers)) // List of email addresses. names := make([]string, 0, len(watchers)) for i := range watchers { - if watchers[i].UserID == doer.Id { + if watchers[i].UserID == doer.ID { continue } diff --git a/models/login.go b/models/login.go index 84a5c2191..1f8d3c8da 100644 --- a/models/login.go +++ b/models/login.go @@ -534,7 +534,7 @@ func UserSignIn(uname, passwd string) (*User, error) { return u, nil } - return nil, ErrUserNotExist{u.Id, u.Name} + return nil, ErrUserNotExist{u.ID, u.Name} default: 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) } - return nil, ErrUserNotExist{u.Id, u.Name} + return nil, ErrUserNotExist{u.ID, u.Name} } diff --git a/models/mail.go b/models/mail.go index 9f34bbf38..6daf84f23 100644 --- a/models/mail.go +++ b/models/mail.go @@ -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.Info = fmt.Sprintf("UID: %d, %s", u.Id, info) + msg.Info = fmt.Sprintf("UID: %d, %s", u.ID, info) 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.Info = fmt.Sprintf("UID: %d, activate email", u.Id) + msg.Info = fmt.Sprintf("UID: %d, activate email", u.ID) 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.Info = fmt.Sprintf("UID: %d, registration notify", u.Id) + msg.Info = fmt.Sprintf("UID: %d, registration notify", u.ID) mailer.SendAsync(msg) } @@ -138,7 +138,7 @@ func SendCollaboratorMail(u, doer *User, repo *Repository) { } 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) } diff --git a/models/org.go b/models/org.go index 9cb862dec..c85e88d61 100644 --- a/models/org.go +++ b/models/org.go @@ -21,16 +21,16 @@ var ( // IsOwnedBy returns true if given user is in the owner team. 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. 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) { - return getTeam(e, org.Id, name) + return getTeam(e, org.ID, name) } // GetTeam returns named team of organization. @@ -48,7 +48,7 @@ func (org *User) GetOwnerTeam() (*Team, 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. @@ -58,7 +58,7 @@ func (org *User) GetTeams() error { // GetMembers returns all members of organization. func (org *User) GetMembers() error { - ous, err := GetOrgUsersByOrgID(org.Id) + ous, err := GetOrgUsersByOrgID(org.ID) if err != nil { return err } @@ -75,16 +75,16 @@ func (org *User) GetMembers() error { // AddMember adds new member to organization. func (org *User) AddMember(uid int64) error { - return AddOrgUser(org.Id, uid) + return AddOrgUser(org.ID, uid) } // RemoveMember removes member from organization. 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 { - return removeOrgRepo(e, org.Id, repoID) + return removeOrgRepo(e, org.ID, repoID) } // 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. if _, err = sess.Insert(&OrgUser{ - Uid: owner.Id, - OrgID: org.Id, + Uid: owner.ID, + OrgID: org.ID, IsOwner: true, NumTeams: 1, }); err != nil { @@ -136,7 +136,7 @@ func CreateOrganization(org, owner *User) (err error) { // Create default owner team. t := &Team{ - OrgID: org.Id, + OrgID: org.ID, LowerName: strings.ToLower(OWNER_TEAM), Name: OWNER_TEAM, Authorize: ACCESS_MODE_OWNER, @@ -147,8 +147,8 @@ func CreateOrganization(org, owner *User) (err error) { } if _, err = sess.Insert(&TeamUser{ - Uid: owner.Id, - OrgID: org.Id, + Uid: owner.ID, + OrgID: org.ID, TeamID: t.ID, }); err != nil { return fmt.Errorf("insert team-user relation: %v", err) @@ -204,9 +204,9 @@ func DeleteOrganization(org *User) (err error) { } if err = deleteBeans(sess, - &Team{OrgID: org.Id}, - &OrgUser{OrgID: org.Id}, - &TeamUser{OrgID: org.Id}, + &Team{OrgID: org.ID}, + &OrgUser{OrgID: org.ID}, + &TeamUser{OrgID: org.ID}, ); err != nil { return fmt.Errorf("deleteBeans: %v", err) } @@ -401,23 +401,23 @@ func RemoveOrgUser(orgId, uid int64) error { } // Delete all repository accesses. - access := &Access{UserID: u.Id} + access := &Access{UserID: u.ID} for _, repo := range org.Repos { access.RepoID = repo.ID if _, err = sess.Delete(access); err != nil { 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 } } // 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 { return err } 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 } } @@ -444,7 +444,7 @@ func (org *User) GetUserRepositories(userID int64) (err error) { teams := make([]*Team, 0, org.NumTeams) if err = x.Sql(`SELECT team.id FROM team 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) } @@ -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 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) -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) } org.Repos = repos @@ -479,7 +479,7 @@ func (org *User) GetUserTeams(userID int64) error { if err := x.Sql(`SELECT team.* FROM team 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 { + org.ID, userID).Find(&teams); err != nil { return fmt.Errorf("get teams: %v", err) } diff --git a/models/org_team.go b/models/org_team.go index 85af2d983..6a6754cc9 100644 --- a/models/org_team.go +++ b/models/org_team.go @@ -106,7 +106,7 @@ func (t *Team) addRepository(e Engine, repo *Repository) (err error) { return fmt.Errorf("getMembers: %v", err) } 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) } } @@ -162,7 +162,7 @@ func (t *Team) removeRepository(e Engine, repo *Repository, recalculate bool) (e 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 } } @@ -341,7 +341,7 @@ func DeleteTeam(t *Team) error { } // 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 } @@ -538,7 +538,7 @@ func removeTeamMember(e Engine, orgID, teamID, uid int64) error { // This must exist. 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 { return err } diff --git a/models/pull.go b/models/pull.go index 38fd94571..78c8d1564 100644 --- a/models/pull.go +++ b/models/pull.go @@ -163,7 +163,7 @@ func (pr *PullRequest) Merge(doer *User, baseGitRepo *git.Repository) (err error pr.HasMerged = true pr.Merged = time.Now() - pr.MergerID = doer.Id + pr.MergerID = doer.ID if _, err = sess.Id(pr.ID).AllCols().Update(pr); err != nil { 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{ UserName: doer.Name, - ID: doer.Id, + ID: doer.ID, AvatarUrl: setting.AppUrl + doer.RelAvatarLink(), }, } @@ -332,7 +332,7 @@ func NewPullRequest(repo *Repository, pull *Issue, labelIDs []int64, uuids []str // Notify watchers. act := &Action{ - ActUserID: pull.Poster.Id, + ActUserID: pull.Poster.ID, ActUserName: pull.Poster.Name, ActEmail: pull.Poster.Email, OpType: ACTION_CREATE_PULL_REQUEST, diff --git a/models/repo.go b/models/repo.go index 44e227550..1c395e583 100644 --- a/models/repo.go +++ b/models/repo.go @@ -476,7 +476,7 @@ func (repo *Repository) ComposePayload() *api.PayloadRepo { func isRepositoryExist(e Engine, u *User, repoName string) (bool, error) { has, err := e.Get(&Repository{ - OwnerID: u.Id, + OwnerID: u.ID, LowerName: strings.ToLower(repoName), }) 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) } else if err = newRepoAction(e, u, repo); err != nil { return fmt.Errorf("newRepoAction: %v", err) @@ -974,7 +974,7 @@ func CreateRepository(u *User, opts CreateRepoOptions) (_ *Repository, err error } repo := &Repository{ - OwnerID: u.Id, + OwnerID: u.ID, Owner: u, Name: 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 // new owner. - repo.OwnerID = newOwner.Id + repo.OwnerID = newOwner.ID repo.Owner = newOwner // Update repository. @@ -1110,10 +1110,10 @@ func TransferOwnership(u *User, newOwnerName string, repo *Repository) error { // Dummy object. collaboration := &Collaboration{RepoID: repo.ID} for _, c := range collaborators { - collaboration.UserID = c.Id - if c.Id == newOwner.Id || newOwner.IsOrgMember(c.Id) { + collaboration.UserID = c.ID + if c.ID == newOwner.ID || newOwner.IsOrgMember(c.ID) { 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. - 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) - } 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) } - 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) } else if err = transferRepoAction(sess, u, owner, newOwner, repo); err != nil { return fmt.Errorf("transferRepoAction: %v", err) @@ -1200,7 +1200,7 @@ func ChangeRepositoryName(u *User, oldRepoName, newRepoName string) (err error) return ErrRepoAlreadyExist{u.Name, newRepoName} } - repo, err := GetRepositoryByName(u.Id, oldRepoName) + repo, err := GetRepositoryByName(u.ID, oldRepoName) if err != nil { return fmt.Errorf("GetRepositoryByName: %v", err) } @@ -1414,7 +1414,7 @@ func GetRepositoryByRef(ref string) (*Repository, error) { return nil, err } - return GetRepositoryByName(user.Id, repoName) + return GetRepositoryByName(user.ID, repoName) } // 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) { - return x.Count(&Repository{OwnerID: u.Id}) + return x.Count(&Repository{OwnerID: u.ID}) } // 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) { repo := &Repository{ - OwnerID: u.Id, + OwnerID: u.ID, Owner: u, Name: name, LowerName: strings.ToLower(name), diff --git a/models/repo_collaboration.go b/models/repo_collaboration.go index 3da5cf5a0..2a530f875 100644 --- a/models/repo_collaboration.go +++ b/models/repo_collaboration.go @@ -33,7 +33,7 @@ func (c *Collaboration) ModeI18nKey() string { func (repo *Repository) AddCollaborator(u *User) error { collaboration := &Collaboration{ RepoID: repo.ID, - UserID: u.Id, + UserID: u.ID, } has, err := x.Get(collaboration) diff --git a/models/ssh_key.go b/models/ssh_key.go index a279b4871..92f38b570 100644 --- a/models/ssh_key.go +++ b/models/ssh_key.go @@ -562,8 +562,8 @@ func DeletePublicKey(doer *User, id int64) (err error) { } // Check if user has access to delete this key. - if !doer.IsAdmin && doer.Id != key.OwnerID { - return ErrKeyAccessDenied{doer.Id, key.ID, "public"} + if !doer.IsAdmin && doer.ID != key.OwnerID { + return ErrKeyAccessDenied{doer.ID, key.ID, "public"} } sess := x.NewSession() @@ -797,7 +797,7 @@ func DeleteDeployKey(doer *User, id int64) error { if err != nil { return fmt.Errorf("HasAccess: %v", err) } else if !yes { - return ErrKeyAccessDenied{doer.Id, key.ID, "deploy"} + return ErrKeyAccessDenied{doer.ID, key.ID, "deploy"} } } diff --git a/models/update.go b/models/update.go index 66775ea9f..14e5b28cf 100644 --- a/models/update.go +++ b/models/update.go @@ -108,7 +108,7 @@ func PushUpdate(opts PushUpdateOptions) (err error) { return fmt.Errorf("GetUserByName: %v", err) } - repo, err := GetRepositoryByName(repoUser.Id, opts.RepoName) + repo, err := GetRepositoryByName(repoUser.ID, opts.RepoName) if err != nil { return fmt.Errorf("GetRepositoryByName: %v", err) } @@ -133,7 +133,7 @@ func PushUpdate(opts PushUpdateOptions) (err error) { } 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 { 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), opts.OldCommitID, opts.NewCommitID); err != nil { return fmt.Errorf("CommitRepoAction (branch): %v", err) diff --git a/models/user.go b/models/user.go index 44dedccad..5b1fd4ae5 100644 --- a/models/user.go +++ b/models/user.go @@ -52,7 +52,7 @@ var ( // User represents the object of individual and member of organization. type User struct { - Id int64 + ID int64 `xorm:"pk autoincr"` LowerName string `xorm:"UNIQUE NOT NULL"` Name string `xorm:"UNIQUE NOT NULL"` FullName string @@ -137,7 +137,7 @@ func (u *User) IsLocal() bool { // HasForkedRepo checks if user has already forked a repository with given ID. func (u *User) HasForkedRepo(repoID int64) bool { - _, has := HasForkedRepo(u.Id, repoID) + _, has := HasForkedRepo(u.ID, repoID) return has } @@ -184,7 +184,7 @@ func (u *User) HomeLink() string { // GenerateEmailActivateCode generates an activate code based on user information and given e-mail. func (u *User) GenerateEmailActivateCode(email string) string { 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) // Add tail hex username @@ -199,7 +199,7 @@ func (u *User) GenerateActivateCode() string { // CustomAvatarPath returns user custom avatar file path. 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. @@ -226,13 +226,13 @@ func (u *User) GenerateRandomAvatar() error { 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 } func (u *User) RelAvatarLink() string { defaultImgUrl := "/img/avatar_default.png" - if u.Id == -1 { + if u.ID == -1 { return defaultImgUrl } @@ -241,7 +241,7 @@ func (u *User) RelAvatarLink() string { if !com.IsExist(u.CustomAvatarPath()) { return defaultImgUrl } - return "/avatars/" + com.ToStr(u.Id) + return "/avatars/" + com.ToStr(u.ID) case setting.DisableGravatar, setting.OfflineMode: if !com.IsExist(u.CustomAvatarPath()) { 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 } @@ -266,7 +266,7 @@ func (u *User) AvatarLink() string { // User.GetFollwoers returns range of user's followers. func (u *User) GetFollowers(page int) ([]*User, error) { 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 { sess = sess.Join("LEFT", "follow", `"user".id=follow.user_id`) } else { @@ -276,13 +276,13 @@ func (u *User) GetFollowers(page int) ([]*User, error) { } func (u *User) IsFollowing(followID int64) bool { - return IsFollowing(u.Id, followID) + return IsFollowing(u.ID, followID) } // GetFollowing returns range of user's following. func (u *User) GetFollowing(page int) ([]*User, error) { 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 { sess = sess.Join("LEFT", "follow", `"user".id=follow.follow_id`) } else { @@ -350,7 +350,7 @@ func (u *User) UploadAvatar(data []byte) error { // DeleteAvatar deletes the user's custom avatar. 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()) 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. 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. 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) { - 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. @@ -404,19 +404,19 @@ func (u *User) GetOrganizationCount() (int64, error) { // GetRepositories returns all repositories that user owns, including private repositories. func (u *User) GetRepositories() (err error) { - u.Repos, err = GetRepositories(u.Id, true) + u.Repos, err = GetRepositories(u.ID, true) return err } // GetOwnedOrganizations returns all organizations that user owns. func (u *User) GetOwnedOrganizations() (err error) { - u.OwnedOrgs, err = GetOwnedOrgsByUserID(u.Id) + u.OwnedOrgs, err = GetOwnedOrgsByUserID(u.ID) return err } // GetOrganizations returns all organizations that user belongs to. func (u *User) GetOrganizations(all bool) error { - ous, err := GetOrgUsersByUserID(u.Id, all) + ous, err := GetOrgUsersByUserID(u.ID, all) if err != nil { return err } @@ -463,7 +463,7 @@ func GetUserSalt() string { // NewFakeUser creates and returns a fake user for someone has deleted his/her account. func NewFakeUser() *User { return &User{ - Id: -1, + ID: -1, Name: "Someone", LowerName: "someone", } @@ -588,7 +588,7 @@ func VerifyUserActiveCode(code string) (user *User) { if user = getVerifyUser(code); user != nil { // time limit code 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) { return user @@ -604,7 +604,7 @@ func VerifyActiveEmailCode(code, email string) *EmailAddress { if user := getVerifyUser(code); user != nil { // time limit code 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) { 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. - 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) RemoveAllWithNotice("Delete repository wiki local copy", repo.LocalWikiPath()) return nil @@ -649,7 +649,7 @@ func updateUser(e Engine, u *User) error { // Organization does not need email if !u.IsOrganization() { 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 { return err } else if has { @@ -668,7 +668,7 @@ func updateUser(e Engine, u *User) error { u.Description = base.TruncateString(u.Description, 255) 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 } @@ -697,7 +697,7 @@ func deleteUser(e *xorm.Session, u *User) error { if err != nil { return fmt.Errorf("GetRepositoryCount: %v", err) } else if count > 0 { - return ErrUserOwnRepos{UID: u.Id} + return ErrUserOwnRepos{UID: u.ID} } // Check membership of organization. @@ -705,12 +705,12 @@ func deleteUser(e *xorm.Session, u *User) error { if err != nil { return fmt.Errorf("GetOrganizationCount: %v", err) } else if count > 0 { - return ErrUserHasOrgs{UID: u.Id} + return ErrUserHasOrgs{UID: u.ID} } // ***** START: Watch ***** 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) } for i := range watches { @@ -722,7 +722,7 @@ func deleteUser(e *xorm.Session, u *User) error { // ***** START: Star ***** 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) } for i := range stars { @@ -734,7 +734,7 @@ func deleteUser(e *xorm.Session, u *User) error { // ***** START: Follow ***** 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) } for i := range followers { @@ -745,22 +745,22 @@ func deleteUser(e *xorm.Session, u *User) error { // ***** END: Follow ***** if err = deleteBeans(e, - &AccessToken{UID: u.Id}, - &Collaboration{UserID: u.Id}, - &Access{UserID: u.Id}, - &Watch{UserID: u.Id}, - &Star{UID: u.Id}, - &Follow{FollowID: u.Id}, - &Action{UserID: u.Id}, - &IssueUser{UID: u.Id}, - &EmailAddress{UID: u.Id}, + &AccessToken{UID: u.ID}, + &Collaboration{UserID: u.ID}, + &Access{UserID: u.ID}, + &Watch{UserID: u.ID}, + &Star{UID: u.ID}, + &Follow{FollowID: u.ID}, + &Action{UserID: u.ID}, + &IssueUser{UID: u.ID}, + &EmailAddress{UID: u.ID}, ); err != nil { return fmt.Errorf("deleteBeans: %v", err) } // ***** START: PublicKey ***** 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) } for _, key := range keys { @@ -771,11 +771,11 @@ func deleteUser(e *xorm.Session, u *User) error { // ***** END: PublicKey ***** // 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) } - 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) } @@ -861,7 +861,7 @@ func GetUserByID(id int64) (*User, error) { // GetAssigneeByID returns the user with write access of repository by given ID. 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 { return nil, err } else if !has { @@ -906,7 +906,7 @@ func GetUserIDsByNames(names []string) []int64 { if err != nil { continue } - ids = append(ids, u.Id) + ids = append(ids, u.ID) } return ids } diff --git a/models/user_mail.go b/models/user_mail.go index bb5f29d87..9a1804c91 100644 --- a/models/user_mail.go +++ b/models/user_mail.go @@ -160,7 +160,7 @@ func MakeEmailPrimary(email *EmailAddress) error { return ErrEmailNotActivated } - user := &User{Id: email.UID} + user := &User{ID: email.UID} has, err = x.Get(user) if err != nil { return err @@ -182,7 +182,7 @@ func MakeEmailPrimary(email *EmailAddress) error { } if !has { - formerPrimaryEmail.UID = user.Id + formerPrimaryEmail.UID = user.ID formerPrimaryEmail.IsActivated = user.IsActive if _, err = sess.Insert(formerPrimaryEmail); err != nil { return err @@ -190,7 +190,7 @@ func MakeEmailPrimary(email *EmailAddress) error { } 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 } diff --git a/modules/context/context.go b/modules/context/context.go index 348de3257..6ca7e574f 100644 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -156,7 +156,7 @@ func Contexter() macaron.Handler { ctx.IsSigned = true ctx.Data["IsSigned"] = ctx.IsSigned 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["IsAdmin"] = ctx.User.IsAdmin } else { diff --git a/modules/context/org.go b/modules/context/org.go index 4cacdf4a1..f8fbf0c79 100644 --- a/modules/context/org.go +++ b/modules/context/org.go @@ -72,13 +72,13 @@ func HandleOrgAssignment(ctx *Context, args ...bool) { ctx.Org.IsTeamMember = true ctx.Org.IsTeamAdmin = true } else if ctx.IsSigned { - ctx.Org.IsOwner = org.IsOwnedBy(ctx.User.Id) + ctx.Org.IsOwner = org.IsOwnedBy(ctx.User.ID) if ctx.Org.IsOwner { ctx.Org.IsMember = true ctx.Org.IsTeamMember = true ctx.Org.IsTeamAdmin = true } else { - if org.IsOrgMember(ctx.User.Id) { + if org.IsOrgMember(ctx.User.ID) { ctx.Org.IsMember = true } } @@ -105,7 +105,7 @@ func HandleOrgAssignment(ctx *Context, args ...bool) { return } } else { - if err := org.GetUserTeams(ctx.User.Id); err != nil { + if err := org.GetUserTeams(ctx.User.ID); err != nil { ctx.Handle(500, "GetUserTeams", err) return } diff --git a/modules/context/repo.go b/modules/context/repo.go index f68576ff5..949913273 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -122,7 +122,7 @@ func RepoAssignment(args ...bool) macaron.Handler { ctx.Repo.Owner = owner // Get repository. - repo, err := models.GetRepositoryByName(owner.Id, repoName) + repo, err := models.GetRepositoryByName(owner.ID, repoName) if err != nil { if models.IsErrRepoNotExist(err) { ctx.Handle(404, "GetRepositoryByName", err) @@ -198,8 +198,8 @@ func RepoAssignment(args ...bool) macaron.Handler { ctx.Data["WikiCloneLink"] = repo.WikiCloneLink() if ctx.IsSigned { - ctx.Data["IsWatchingRepo"] = models.IsWatching(ctx.User.Id, repo.ID) - ctx.Data["IsStaringRepo"] = models.IsStaring(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) } // repo is bare and display enable diff --git a/routers/admin/repos.go b/routers/admin/repos.go index dc259c634..5eacb5ed3 100644 --- a/routers/admin/repos.go +++ b/routers/admin/repos.go @@ -39,7 +39,7 @@ func DeleteRepo(ctx *context.Context) { 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) return } diff --git a/routers/admin/users.go b/routers/admin/users.go index b7056957e..eb91ea2fd 100644 --- a/routers/admin/users.go +++ b/routers/admin/users.go @@ -120,7 +120,7 @@ func NewUserPost(ctx *context.Context, form auth.AdminCrateUserForm) { } 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 { diff --git a/routers/api/v1/admin/org_team.go b/routers/api/v1/admin/org_team.go index 9b5411b12..c0f3487e1 100644 --- a/routers/api/v1/admin/org_team.go +++ b/routers/api/v1/admin/org_team.go @@ -15,7 +15,7 @@ import ( func CreateTeam(ctx *context.APIContext, form api.CreateTeamOption) { team := &models.Team{ - OrgID: ctx.Org.Organization.Id, + OrgID: ctx.Org.Organization.ID, Name: form.Name, Description: form.Description, Authorize: models.ParseAccessMode(form.Permission), @@ -37,7 +37,7 @@ func AddTeamMember(ctx *context.APIContext) { if ctx.Written() { 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) return } @@ -51,7 +51,7 @@ func RemoveTeamMember(ctx *context.APIContext) { 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) return } diff --git a/routers/api/v1/admin/user.go b/routers/api/v1/admin/user.go index 4bb24998b..b282ce322 100644 --- a/routers/api/v1/admin/user.go +++ b/routers/api/v1/admin/user.go @@ -147,5 +147,5 @@ func CreatePublicKey(ctx *context.APIContext, form api.CreateKeyOption) { if ctx.Written() { return } - user.CreateUserPublicKey(ctx, form, u.Id) + user.CreateUserPublicKey(ctx, form, u.ID) } diff --git a/routers/api/v1/api.go b/routers/api/v1/api.go index a13a1e688..a0af20074 100644 --- a/routers/api/v1/api.go +++ b/routers/api/v1/api.go @@ -49,7 +49,7 @@ func RepoAssignment() macaron.Handler { ctx.Repo.Owner = owner // Get repository. - repo, err := models.GetRepositoryByName(owner.Id, repoName) + repo, err := models.GetRepositoryByName(owner.ID, repoName) if err != nil { if models.IsErrRepoNotExist(err) { ctx.Status(404) diff --git a/routers/api/v1/convert/convert.go b/routers/api/v1/convert/convert.go index 52f28e7dd..596b450f2 100644 --- a/routers/api/v1/convert/convert.go +++ b/routers/api/v1/convert/convert.go @@ -23,7 +23,7 @@ func ToUser(u *models.User) *api.User { } return &api.User{ - ID: u.Id, + ID: u.ID, UserName: u.Name, FullName: u.FullName, Email: u.Email, @@ -194,7 +194,7 @@ func ToIssue(issue *models.Issue) *api.Issue { func ToOrganization(org *models.User) *api.Organization { return &api.Organization{ - ID: org.Id, + ID: org.ID, AvatarUrl: org.AvatarLink(), UserName: org.Name, FullName: org.FullName, diff --git a/routers/api/v1/org/org.go b/routers/api/v1/org/org.go index 5b1ea007e..7b2cfcd1d 100644 --- a/routers/api/v1/org/org.go +++ b/routers/api/v1/org/org.go @@ -48,7 +48,7 @@ func Get(ctx *context.APIContext) { // https://github.com/gogits/go-gogs-client/wiki/Organizations#edit-an-organization func Edit(ctx *context.APIContext, form api.EditOrgOption) { org := ctx.Org.Organization - if !org.IsOwnedBy(ctx.User.Id) { + if !org.IsOwnedBy(ctx.User.ID) { ctx.Status(403) return } diff --git a/routers/api/v1/repo/issue.go b/routers/api/v1/repo/issue.go index a3f69d3f8..b105b6816 100644 --- a/routers/api/v1/repo/issue.go +++ b/routers/api/v1/repo/issue.go @@ -53,7 +53,7 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) { issue := &models.Issue{ RepoID: ctx.Repo.Repository.ID, Name: form.Title, - PosterID: ctx.User.Id, + PosterID: ctx.User.ID, Poster: ctx.User, Content: form.Body, } @@ -69,7 +69,7 @@ func CreateIssue(ctx *context.APIContext, form api.CreateIssueOption) { } return } - issue.AssigneeID = assignee.Id + issue.AssigneeID = assignee.ID } issue.MilestoneID = form.Milestone } else { @@ -109,7 +109,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) { return } - if !issue.IsPoster(ctx.User.Id) && !ctx.Repo.IsWriter() { + if !issue.IsPoster(ctx.User.ID) && !ctx.Repo.IsWriter() { ctx.Status(403) return } @@ -135,7 +135,7 @@ func EditIssue(ctx *context.APIContext, form api.EditIssueOption) { } return } - issue.AssigneeID = assignee.Id + issue.AssigneeID = assignee.ID } if err = models.UpdateIssueUserByAssignee(issue); err != nil { diff --git a/routers/api/v1/repo/repo.go b/routers/api/v1/repo/repo.go index 222098ac6..679ebb09d 100644 --- a/routers/api/v1/repo/repo.go +++ b/routers/api/v1/repo/repo.go @@ -27,7 +27,7 @@ func Search(ctx *context.APIContext) { // Check visibility. if ctx.IsSigned && opts.OwnerID > 0 { - if ctx.User.Id == opts.OwnerID { + if ctx.User.ID == opts.OwnerID { opts.Private = true } else { u, err := models.GetUserByID(opts.OwnerID) @@ -38,7 +38,7 @@ func Search(ctx *context.APIContext) { }) return } - if u.IsOrganization() && u.IsOwnedBy(ctx.User.Id) { + if u.IsOrganization() && u.IsOwnedBy(ctx.User.ID) { opts.Private = true } // 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 func ListMyRepos(ctx *context.APIContext) { - ownRepos, err := models.GetRepositories(ctx.User.Id, true) + ownRepos, err := models.GetRepositories(ctx.User.ID, true) if err != nil { ctx.Error(500, "GetRepositories", err) return @@ -126,7 +126,7 @@ func CreateUserRepo(ctx *context.APIContext, owner *models.User, opt api.CreateR ctx.Error(422, "", err) } else { 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) } } @@ -159,7 +159,7 @@ func CreateOrgRepo(ctx *context.APIContext, opt api.CreateRepoOption) { return } - if !org.IsOwnedBy(ctx.User.Id) { + if !org.IsOwnedBy(ctx.User.ID) { ctx.Error(403, "", "Given user is not owner of organization.") return } @@ -171,7 +171,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { ctxUser := ctx.User // Not equal means context user is an organization, // 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) if err != nil { if models.IsErrUserNotExist(err) { @@ -191,7 +191,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { if ctxUser.IsOrganization() && !ctx.User.IsAdmin { // 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.") return } @@ -226,7 +226,7 @@ func Migrate(ctx *context.APIContext, form auth.MigrateRepoForm) { }) if err != 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) } } @@ -249,7 +249,7 @@ func parseOwnerAndRepo(ctx *context.APIContext) (*models.User, *models.Repositor 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 models.IsErrRepoNotExist(err) { ctx.Status(404) @@ -279,12 +279,12 @@ func Delete(ctx *context.APIContext) { 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.") 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) return } diff --git a/routers/api/v1/user/app.go b/routers/api/v1/user/app.go index da030e983..165f6eb8e 100644 --- a/routers/api/v1/user/app.go +++ b/routers/api/v1/user/app.go @@ -13,7 +13,7 @@ import ( // https://github.com/gogits/go-gogs-client/wiki/Users#list-access-tokens-for-a-user func ListAccessTokens(ctx *context.APIContext) { - tokens, err := models.ListAccessTokens(ctx.User.Id) + tokens, err := models.ListAccessTokens(ctx.User.ID) if err != nil { ctx.Error(500, "ListAccessTokens", err) return @@ -29,7 +29,7 @@ func ListAccessTokens(ctx *context.APIContext) { // https://github.com/gogits/go-gogs-client/wiki/Users#create-a-access-token func CreateAccessToken(ctx *context.APIContext, form api.CreateAccessTokenOption) { t := &models.AccessToken{ - UID: ctx.User.Id, + UID: ctx.User.ID, Name: form.Name, } if err := models.NewAccessToken(t); err != nil { diff --git a/routers/api/v1/user/email.go b/routers/api/v1/user/email.go index 6a3d525cc..1f615cdff 100644 --- a/routers/api/v1/user/email.go +++ b/routers/api/v1/user/email.go @@ -15,7 +15,7 @@ import ( // https://github.com/gogits/go-gogs-client/wiki/Users-Emails#list-email-addresses-for-a-user func ListEmails(ctx *context.APIContext) { - emails, err := models.GetEmailAddresses(ctx.User.Id) + emails, err := models.GetEmailAddresses(ctx.User.ID) if err != nil { ctx.Error(500, "GetEmailAddresses", err) return @@ -37,7 +37,7 @@ func AddEmail(ctx *context.APIContext, form api.CreateEmailOption) { emails := make([]*models.EmailAddress, len(form.Emails)) for i := range form.Emails { emails[i] = &models.EmailAddress{ - UID: ctx.User.Id, + UID: ctx.User.ID, Email: form.Emails[i], IsActivated: !setting.Service.RegisterEmailConfirm, } diff --git a/routers/api/v1/user/follower.go b/routers/api/v1/user/follower.go index 00d1952d5..8d103c9e1 100644 --- a/routers/api/v1/user/follower.go +++ b/routers/api/v1/user/follower.go @@ -78,7 +78,7 @@ func CheckMyFollowing(ctx *context.APIContext) { if ctx.Written() { 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 @@ -91,7 +91,7 @@ func CheckFollowing(ctx *context.APIContext) { if ctx.Written() { return } - checkUserFollowing(ctx, u, target.Id) + checkUserFollowing(ctx, u, target.ID) } // 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() { 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) return } @@ -113,7 +113,7 @@ func Unfollow(ctx *context.APIContext) { if ctx.Written() { 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) return } diff --git a/routers/api/v1/user/key.go b/routers/api/v1/user/key.go index 7337112ec..3e407feff 100644 --- a/routers/api/v1/user/key.go +++ b/routers/api/v1/user/key.go @@ -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 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 @@ -63,7 +63,7 @@ func ListPublicKeys(ctx *context.APIContext) { if ctx.Written() { 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 @@ -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 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 diff --git a/routers/api/v1/user/user.go b/routers/api/v1/user/user.go index b460d942b..98571ae69 100644 --- a/routers/api/v1/user/user.go +++ b/routers/api/v1/user/user.go @@ -36,7 +36,7 @@ func Search(ctx *context.APIContext) { results := make([]*api.User, len(users)) for i := range users { results[i] = &api.User{ - ID: users[i].Id, + ID: users[i].ID, UserName: users[i].Name, AvatarUrl: users[i].AvatarLink(), FullName: users[i].FullName, @@ -68,5 +68,5 @@ func GetInfo(ctx *context.APIContext) { if !ctx.IsSigned { 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()}) } diff --git a/routers/install.go b/routers/install.go index 99380e1b9..23fb01735 100644 --- a/routers/install.go +++ b/routers/install.go @@ -374,7 +374,7 @@ func InstallPost(ctx *context.Context, form auth.InstallForm) { } // Auto-login for admin - ctx.Session.Set("uid", u.Id) + ctx.Session.Set("uid", u.ID) ctx.Session.Set("uname", u.Name) } diff --git a/routers/org/members.go b/routers/org/members.go index 1d720ce61..15998aa27 100644 --- a/routers/org/members.go +++ b/routers/org/members.go @@ -44,17 +44,17 @@ func MembersAction(ctx *context.Context) { var err error switch ctx.Params(":action") { case "private": - if ctx.User.Id != uid && !ctx.Org.IsOwner { + if ctx.User.ID != uid && !ctx.Org.IsOwner { ctx.Error(404) return } - err = models.ChangeOrgUserStatus(org.Id, uid, false) + err = models.ChangeOrgUserStatus(org.ID, uid, false) case "public": - if ctx.User.Id != uid && !ctx.Org.IsOwner { + if ctx.User.ID != uid && !ctx.Org.IsOwner { ctx.Error(404) return } - err = models.ChangeOrgUserStatus(org.Id, uid, true) + err = models.ChangeOrgUserStatus(org.ID, uid, true) case "remove": if !ctx.Org.IsOwner { ctx.Error(404) @@ -67,7 +67,7 @@ func MembersAction(ctx *context.Context) { return } case "leave": - err = org.RemoveMember(ctx.User.Id) + err = org.RemoveMember(ctx.User.ID) if models.IsErrLastOrgOwner(err) { ctx.Flash.Error(ctx.Tr("form.last_org_owner")) ctx.Redirect(ctx.Org.OrgLink + "/members") @@ -109,7 +109,7 @@ func Invitation(ctx *context.Context) { return } - if err = org.AddMember(u.Id); err != nil { + if err = org.AddMember(u.ID); err != nil { ctx.Handle(500, " AddMember", err) return } diff --git a/routers/org/setting.go b/routers/org/setting.go index 7900613b7..128fba36a 100644 --- a/routers/org/setting.go +++ b/routers/org/setting.go @@ -41,7 +41,7 @@ func SettingsPost(ctx *context.Context, form auth.UpdateOrgSettingForm) { // Check if organization name has been changed. 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 { ctx.Handle(500, "IsUserExist", err) return @@ -140,7 +140,7 @@ func Webhooks(ctx *context.Context) { ctx.Data["BaseLink"] = ctx.Org.OrgLink 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 { ctx.Handle(500, "GetWebhooksByOrgId", err) return @@ -151,7 +151,7 @@ func Webhooks(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()) } else { ctx.Flash.Success(ctx.Tr("repo.settings.webhook_deletion_success")) diff --git a/routers/org/teams.go b/routers/org/teams.go index 430f08ec2..3d0456423 100644 --- a/routers/org/teams.go +++ b/routers/org/teams.go @@ -54,9 +54,9 @@ func TeamsAction(ctx *context.Context) { ctx.Error(404) return } - err = ctx.Org.Team.AddMember(ctx.User.Id) + err = ctx.Org.Team.AddMember(ctx.User.ID) case "leave": - err = ctx.Org.Team.RemoveMember(ctx.User.Id) + err = ctx.Org.Team.RemoveMember(ctx.User.ID) case "remove": if !ctx.Org.IsOwner { ctx.Error(404) @@ -82,7 +82,7 @@ func TeamsAction(ctx *context.Context) { return } - err = ctx.Org.Team.AddMember(u.Id) + err = ctx.Org.Team.AddMember(u.ID) page = "team" } @@ -118,7 +118,7 @@ func TeamsRepoAction(ctx *context.Context) { case "add": repoName := path.Base(ctx.Query("repo_name")) 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 models.IsErrRepoNotExist(err) { 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 t := &models.Team{ - OrgID: ctx.Org.Organization.Id, + OrgID: ctx.Org.Organization.ID, Name: form.TeamName, Description: form.Description, Authorize: models.ParseAccessMode(form.Permission), diff --git a/routers/repo/http.go b/routers/repo/http.go index fba06133c..d6abc7745 100644 --- a/routers/repo/http.go +++ b/routers/repo/http.go @@ -59,7 +59,7 @@ func HTTP(ctx *context.Context) { return } - repo, err := models.GetRepositoryByName(repoUser.Id, reponame) + repo, err := models.GetRepositoryByName(repoUser.ID, reponame) if err != nil { if models.IsErrRepoNotExist(err) { ctx.Handle(http.StatusNotFound, "GetRepositoryByName", nil) @@ -200,7 +200,7 @@ func HTTP(ctx *context.Context) { RefName: refName, OldCommitID: oldCommitId, NewCommitID: newCommitId, - PusherID: authUser.Id, + PusherID: authUser.ID, PusherName: authUser.Name, RepoUserName: username, RepoName: reponame, diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 1562845ba..269066eb6 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -125,17 +125,17 @@ func Issues(ctx *context.Context) { switch viewType { case "assigned": filterMode = models.FM_ASSIGN - assigneeID = ctx.User.Id + assigneeID = ctx.User.ID case "created_by": filterMode = models.FM_CREATE - posterID = ctx.User.Id + posterID = ctx.User.ID case "mentioned": filterMode = models.FM_MENTION } var uid int64 = -1 if ctx.IsSigned { - uid = ctx.User.Id + uid = ctx.User.ID } repo := ctx.Repo.Repository @@ -200,7 +200,7 @@ func Issues(ctx *context.Context) { } // 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 { issues[i].IsRead = pairs[idx].IsRead } else { @@ -425,7 +425,7 @@ func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) { issue := &models.Issue{ RepoID: repo.ID, Name: form.Title, - PosterID: ctx.User.Id, + PosterID: ctx.User.ID, Poster: ctx.User, MilestoneID: milestoneID, AssigneeID: assigneeID, @@ -581,7 +581,7 @@ func ViewIssue(ctx *context.Context) { if ctx.IsSigned { // 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) return } @@ -627,7 +627,7 @@ func ViewIssue(ctx *context.Context) { break } } - if !isAdded && !issue.IsPoster(comment.Poster.Id) { + if !isAdded && !issue.IsPoster(comment.Poster.ID) { participants = append(participants, comment.Poster) } } @@ -636,7 +636,7 @@ func ViewIssue(ctx *context.Context) { ctx.Data["Participants"] = participants ctx.Data["NumParticipants"] = len(participants) 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["RequireHighlightJS"] = true @@ -663,7 +663,7 @@ func UpdateIssueTitle(ctx *context.Context) { 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) return } @@ -690,7 +690,7 @@ func UpdateIssueContent(ctx *context.Context) { 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) return } @@ -831,7 +831,7 @@ func NewComment(ctx *context.Context, form auth.CreateCommentForm) { var comment *models.Comment defer func() { // 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") && !(issue.IsPull && issue.HasMerged) { @@ -907,7 +907,7 @@ func UpdateCommentContent(ctx *context.Context) { 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) return } else if comment.Type != models.COMMENT_TYPE_COMMENT { diff --git a/routers/repo/pull.go b/routers/repo/pull.go index 01a5102f7..8fb7ae183 100644 --- a/routers/repo/pull.go +++ b/routers/repo/pull.go @@ -104,7 +104,7 @@ func ForkPost(ctx *context.Context, form auth.CreateRepoForm) { return } - repo, has := models.HasForkedRepo(ctxUser.Id, forkRepo.ID) + repo, has := models.HasForkedRepo(ctxUser.ID, forkRepo.ID) if has { ctx.Redirect(setting.AppSubUrl + "/" + ctxUser.Name + "/" + repo.Name) return @@ -112,7 +112,7 @@ func ForkPost(ctx *context.Context, form auth.CreateRepoForm) { // Check ownership of organization. if ctxUser.IsOrganization() { - if !ctxUser.IsOwnedBy(ctx.User.Id) { + if !ctxUser.IsOwnedBy(ctx.User.ID) { ctx.Error(403) return } @@ -166,7 +166,7 @@ func checkPullInfo(ctx *context.Context) *models.Issue { if ctx.IsSigned { // 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) 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. - headRepo, has := models.HasForkedRepo(headUser.Id, baseRepo.ID) + headRepo, has := models.HasForkedRepo(headUser.ID, baseRepo.ID) if !has && !isSameRepo { log.Trace("ParseCompareInfo[%d]: does not have fork or in same repository", baseRepo.ID) ctx.Handle(404, "ParseCompareInfo", nil) @@ -666,7 +666,7 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm) RepoID: repo.ID, Index: repo.NextIssueIndex(), Name: form.Title, - PosterID: ctx.User.Id, + PosterID: ctx.User.ID, Poster: ctx.User, MilestoneID: milestoneID, AssigneeID: assigneeID, diff --git a/routers/repo/release.go b/routers/repo/release.go index 4aeec2b8d..0df4a1f1d 100644 --- a/routers/repo/release.go +++ b/routers/repo/release.go @@ -176,7 +176,7 @@ func NewReleasePost(ctx *context.Context, form auth.NewReleaseForm) { rel := &models.Release{ RepoID: ctx.Repo.Repository.ID, - PublisherID: ctx.User.Id, + PublisherID: ctx.User.ID, Title: form.Title, TagName: form.TagName, Target: form.Target, diff --git a/routers/repo/repo.go b/routers/repo/repo.go index f9835bd2f..3c1775dce 100644 --- a/routers/repo/repo.go +++ b/routers/repo/repo.go @@ -34,7 +34,7 @@ func MustBeNotBare(ctx *context.Context) { } 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 { ctx.Handle(500, "GetOwnedOrgsByUserIDDesc", err) return nil @@ -42,7 +42,7 @@ func checkContextUser(ctx *context.Context, uid int64) *models.User { ctx.Data["Orgs"] = orgs // 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 } @@ -57,7 +57,7 @@ func checkContextUser(ctx *context.Context, uid int64) *models.User { } // 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) return nil } @@ -136,7 +136,7 @@ func CreatePost(ctx *context.Context, form auth.CreateRepoForm) { } 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) } } @@ -208,7 +208,7 @@ func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) { } 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) } } @@ -231,13 +231,13 @@ func Action(ctx *context.Context) { var err error switch ctx.Params(":action") { 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": - err = models.WatchRepo(ctx.User.Id, ctx.Repo.Repository.ID, false) + err = models.WatchRepo(ctx.User.ID, ctx.Repo.Repository.ID, false) 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": - 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 if !ctx.Repo.IsOwner() { ctx.Error(404) diff --git a/routers/repo/setting.go b/routers/repo/setting.go index c5772dca5..08f06dcb3 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -162,7 +162,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { } if ctx.Repo.Owner.IsOrganization() { - if !ctx.Repo.Owner.IsOwnedBy(ctx.User.Id) { + if !ctx.Repo.Owner.IsOwnedBy(ctx.User.ID) { ctx.Error(404) return } @@ -196,7 +196,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { } if ctx.Repo.Owner.IsOrganization() { - if !ctx.Repo.Owner.IsOwnedBy(ctx.User.Id) { + if !ctx.Repo.Owner.IsOwnedBy(ctx.User.ID) { ctx.Error(404) return } @@ -235,13 +235,13 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { } if ctx.Repo.Owner.IsOrganization() { - if !ctx.Repo.Owner.IsOwnedBy(ctx.User.Id) { + if !ctx.Repo.Owner.IsOwnedBy(ctx.User.ID) { ctx.Error(404) 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) return } @@ -261,7 +261,7 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { } if ctx.Repo.Owner.IsOrganization() { - if !ctx.Repo.Owner.IsOwnedBy(ctx.User.Id) { + if !ctx.Repo.Owner.IsOwnedBy(ctx.User.ID) { ctx.Error(404) return } @@ -321,7 +321,7 @@ func CollaborationPost(ctx *context.Context) { } // 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.Redirect(ctx.Repo.RepoLink + "/settings/collaboration") return @@ -371,7 +371,7 @@ func parseOwnerAndRepo(ctx *context.Context) (*models.User, *models.Repository) 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 models.IsErrRepoNotExist(err) { ctx.Handle(404, "GetRepositoryByName", err) diff --git a/routers/repo/webhook.go b/routers/repo/webhook.go index 22d5cfd2c..715c6a4c7 100644 --- a/routers/repo/webhook.go +++ b/routers/repo/webhook.go @@ -63,7 +63,7 @@ func getOrgRepoCtx(ctx *context.Context) (*OrgRepoCtx, error) { if len(ctx.Org.OrgLink) > 0 { return &OrgRepoCtx{ - OrgID: ctx.Org.Organization.Id, + OrgID: ctx.Org.Organization.ID, Link: ctx.Org.OrgLink, NewTemplate: ORG_HOOK_NEW, }, nil @@ -224,7 +224,7 @@ func checkWebhook(ctx *context.Context) (*OrgRepoCtx, *models.Webhook) { if orCtx.RepoID > 0 { w, err = models.GetWebhookByRepoID(ctx.Repo.Repository.ID, ctx.ParamsInt64(":id")) } 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 models.IsErrWebhookNotExist(err) { @@ -369,7 +369,7 @@ func TestWebhook(ctx *context.Context) { }, Sender: &api.PayloadUser{ UserName: ctx.User.Name, - ID: ctx.User.Id, + ID: ctx.User.ID, AvatarUrl: ctx.User.AvatarLink(), }, } diff --git a/routers/user/auth.go b/routers/user/auth.go index df79ecbe4..40687fca6 100644 --- a/routers/user/auth.go +++ b/routers/user/auth.go @@ -60,7 +60,7 @@ func AutoSignIn(ctx *context.Context) (bool, error) { } isSucceed = true - ctx.Session.Set("uid", u.Id) + ctx.Session.Set("uid", u.ID) ctx.Session.Set("uname", u.Name) ctx.SetCookie(setting.CSRFCookieName, "", -1, setting.AppSubUrl) return true, nil @@ -114,7 +114,7 @@ func SignInPost(ctx *context.Context, form auth.SignInForm) { 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) // 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. - if setting.Service.RegisterEmailConfirm && u.Id > 1 { + if setting.Service.RegisterEmailConfirm && u.ID > 1 { models.SendActivateAccountMail(ctx.Context, u) ctx.Data["IsSendRegisterMail"] = true ctx.Data["Email"] = u.Email @@ -278,7 +278,7 @@ func Activate(ctx *context.Context) { 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.Redirect(setting.AppSubUrl + "/") return diff --git a/routers/user/home.go b/routers/user/home.go index aaf660d48..5316830b6 100644 --- a/routers/user/home.go +++ b/routers/user/home.go @@ -24,6 +24,7 @@ const ( ORG_HOME base.TplName = "org/home" ) +// getDashboardContextUser finds out dashboard is viewing as which context user. func getDashboardContextUser(ctx *context.Context) *models.User { ctxUser := ctx.User orgName := ctx.Params(":org") @@ -51,6 +52,9 @@ func getDashboardContextUser(ctx *context.Context) *models.User { 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) { actions, err := models.GetFeeds(ctxUserID, userID, offset, isProfile) if err != nil { @@ -84,14 +88,15 @@ func retrieveFeeds(ctx *context.Context, ctxUserID, userID, offset int64, isProf func Dashboard(ctx *context.Context) { ctxUser := getDashboardContextUser(ctx) - ctx.Data["Title"] = ctxUser.DisplayName() + " - " + ctx.Tr("dashboard") - ctx.Data["PageIsDashboard"] = true - ctx.Data["PageIsNews"] = true - if ctx.Written() { 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() { collaborateRepos, err := ctx.User.GetAccessibleRepositories() if err != nil { @@ -111,14 +116,14 @@ func Dashboard(ctx *context.Context) { var repos []*models.Repository 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) return } repos = ctxUser.Repos } else { var err error - repos, err = models.GetRepositories(ctxUser.Id, true) + repos, err = models.GetRepositories(ctxUser.ID, true) if err != nil { ctx.Handle(500, "GetRepositories", err) return @@ -140,7 +145,7 @@ func Dashboard(ctx *context.Context) { ctx.Data["MirrorCount"] = len(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() { return } @@ -182,10 +187,10 @@ func Issues(ctx *context.Context) { switch viewType { case "assigned": filterMode = models.FM_ASSIGN - assigneeID = ctxUser.Id + assigneeID = ctxUser.ID case "created_by": filterMode = models.FM_CREATE - posterID = ctxUser.Id + posterID = ctxUser.ID } } @@ -194,7 +199,7 @@ func Issues(ctx *context.Context) { // Get repositories. 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) return } @@ -227,7 +232,7 @@ func Issues(ctx *context.Context) { if filterMode != models.FM_ALL { // 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) } @@ -239,7 +244,7 @@ func Issues(ctx *context.Context) { } 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) page := ctx.QueryInt("page") @@ -257,7 +262,7 @@ func Issues(ctx *context.Context) { // Get issues. issues, err := models.Issues(&models.IssuesOptions{ - UserID: ctxUser.Id, + UserID: ctxUser.ID, AssigneeID: assigneeID, RepoID: repoID, PosterID: posterID, @@ -328,21 +333,21 @@ func showOrgProfile(ctx *context.Context) { if ctx.IsSigned { if ctx.User.IsAdmin { - repos, err := models.GetRepositories(org.Id, true) + repos, err := models.GetRepositories(org.ID, true) if err != nil { ctx.Handle(500, "GetRepositoriesAsAdmin", err) return } ctx.Data["Repos"] = repos } else { - if err := org.GetUserRepositories(ctx.User.Id); err != nil { + if err := org.GetUserRepositories(ctx.User.ID); err != nil { ctx.Handle(500, "GetUserRepositories", err) return } ctx.Data["Repos"] = org.Repos } } else { - repos, err := models.GetRepositories(org.Id, false) + repos, err := models.GetRepositories(org.ID, false) if err != nil { ctx.Handle(500, "GetRepositories", err) return diff --git a/routers/user/profile.go b/routers/user/profile.go index 847cffdd4..0e436eac4 100644 --- a/routers/user/profile.go +++ b/routers/user/profile.go @@ -62,7 +62,7 @@ func Profile(ctx *context.Context) { // Show SSH keys. if isShowKeys { - ShowSSHKeys(ctx, u.Id) + ShowSSHKeys(ctx, u.ID) return } @@ -75,7 +75,7 @@ func Profile(ctx *context.Context) { ctx.Data["PageIsUserProfile"] = true 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 { ctx.Handle(500, "GetOrgsByUserIDDesc", err) return @@ -87,13 +87,13 @@ func Profile(ctx *context.Context) { ctx.Data["TabName"] = tab switch tab { case "activity": - retrieveFeeds(ctx, u.Id, -1, 0, true) + retrieveFeeds(ctx, u.ID, -1, 0, true) if ctx.Written() { return } default: 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 { ctx.Handle(500, "GetRepositories", err) return @@ -140,9 +140,9 @@ func Action(ctx *context.Context) { var err error switch ctx.Params(":action") { case "follow": - err = models.FollowUser(ctx.User.Id, u.Id) + err = models.FollowUser(ctx.User.ID, u.ID) case "unfollow": - err = models.UnfollowUser(ctx.User.Id, u.Id) + err = models.UnfollowUser(ctx.User.ID, u.ID) } if err != nil { diff --git a/routers/user/setting.go b/routers/user/setting.go index c910cd4e1..7412ce34d 100644 --- a/routers/user/setting.go +++ b/routers/user/setting.go @@ -131,7 +131,7 @@ func UpdateAvatarSetting(ctx *context.Context, form auth.UploadAvatarForm, ctxUs // generate a random one when needed. if form.Enable && !com.IsFile(ctxUser.CustomAvatarPath()) { 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["PageIsSettingsEmails"] = true - emails, err := models.GetEmailAddresses(ctx.User.Id) + emails, err := models.GetEmailAddresses(ctx.User.ID) if err != nil { ctx.Handle(500, "GetEmailAddresses", err) return @@ -226,7 +226,7 @@ func SettingsEmailPost(ctx *context.Context, form auth.AddEmailForm) { } // Add Email address. - emails, err := models.GetEmailAddresses(ctx.User.Id) + emails, err := models.GetEmailAddresses(ctx.User.ID) if err != nil { ctx.Handle(500, "GetEmailAddresses", err) return @@ -239,7 +239,7 @@ func SettingsEmailPost(ctx *context.Context, form auth.AddEmailForm) { } email := &models.EmailAddress{ - UID: ctx.User.Id, + UID: ctx.User.ID, Email: form.Email, IsActivated: !setting.Service.RegisterEmailConfirm, } @@ -285,7 +285,7 @@ func SettingsSSHKeys(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsSSHKeys"] = true - keys, err := models.ListPublicKeys(ctx.User.Id) + keys, err := models.ListPublicKeys(ctx.User.ID) if err != nil { ctx.Handle(500, "ListPublicKeys", err) return @@ -299,7 +299,7 @@ func SettingsSSHKeysPost(ctx *context.Context, form auth.AddSSHKeyForm) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsSSHKeys"] = true - keys, err := models.ListPublicKeys(ctx.User.Id) + keys, err := models.ListPublicKeys(ctx.User.ID) if err != nil { ctx.Handle(500, "ListPublicKeys", err) 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 switch { case models.IsErrKeyAlreadyExist(err): @@ -357,7 +357,7 @@ func SettingsApplications(ctx *context.Context) { ctx.Data["Title"] = ctx.Tr("settings") ctx.Data["PageIsSettingsApplications"] = true - tokens, err := models.ListAccessTokens(ctx.User.Id) + tokens, err := models.ListAccessTokens(ctx.User.ID) if err != nil { ctx.Handle(500, "ListAccessTokens", err) return @@ -372,7 +372,7 @@ func SettingsApplicationsPost(ctx *context.Context, form auth.NewAccessTokenForm ctx.Data["PageIsSettingsApplications"] = true if ctx.HasError() { - tokens, err := models.ListAccessTokens(ctx.User.Id) + tokens, err := models.ListAccessTokens(ctx.User.ID) if err != nil { ctx.Handle(500, "ListAccessTokens", err) return @@ -383,7 +383,7 @@ func SettingsApplicationsPost(ctx *context.Context, form auth.NewAccessTokenForm } t := &models.AccessToken{ - UID: ctx.User.Id, + UID: ctx.User.ID, Name: form.Name, } if err := models.NewAccessToken(t); err != nil { diff --git a/templates/.VERSION b/templates/.VERSION index 82c3ae6af..a02c7ea3d 100644 --- a/templates/.VERSION +++ b/templates/.VERSION @@ -1 +1 @@ -0.9.52.0723 \ No newline at end of file +0.9.53.0724 \ No newline at end of file diff --git a/templates/admin/base/page.tmpl b/templates/admin/base/page.tmpl index b689ed081..564d7dec3 100644 --- a/templates/admin/base/page.tmpl +++ b/templates/admin/base/page.tmpl @@ -20,4 +20,4 @@ {{end}} - {{end}} \ No newline at end of file + {{end}} diff --git a/templates/admin/base/search.tmpl b/templates/admin/base/search.tmpl index 29026a11a..22634354b 100644 --- a/templates/admin/base/search.tmpl +++ b/templates/admin/base/search.tmpl @@ -3,4 +3,4 @@ - \ No newline at end of file + diff --git a/templates/admin/org/list.tmpl b/templates/admin/org/list.tmpl index 8560d0219..6b9423d03 100644 --- a/templates/admin/org/list.tmpl +++ b/templates/admin/org/list.tmpl @@ -27,7 +27,7 @@ {{range .Users}} - {{.Id}} + {{.ID}} {{.Name}} {{.NumTeams}} {{.NumMembers}} diff --git a/templates/admin/user/edit.tmpl b/templates/admin/user/edit.tmpl index 78088d1a7..bed3097a5 100644 --- a/templates/admin/user/edit.tmpl +++ b/templates/admin/user/edit.tmpl @@ -102,7 +102,7 @@
-
{{.i18n.Tr "admin.users.delete_account"}}
+
{{.i18n.Tr "admin.users.delete_account"}}
diff --git a/templates/admin/user/list.tmpl b/templates/admin/user/list.tmpl index 5b5048f84..8c7a0c9a9 100644 --- a/templates/admin/user/list.tmpl +++ b/templates/admin/user/list.tmpl @@ -31,14 +31,14 @@ {{range .Users}} - {{.Id}} + {{.ID}} {{.Name}} {{.Email}} {{.NumRepos}} {{DateFmtShort .Created }} - + {{end}} diff --git a/templates/explore/page.tmpl b/templates/explore/page.tmpl index bb07f2611..fd3e7a7a8 100644 --- a/templates/explore/page.tmpl +++ b/templates/explore/page.tmpl @@ -18,4 +18,4 @@ {{end}} -{{end}} \ No newline at end of file +{{end}} diff --git a/templates/explore/search.tmpl b/templates/explore/search.tmpl index f18648865..8d91f3150 100644 --- a/templates/explore/search.tmpl +++ b/templates/explore/search.tmpl @@ -4,4 +4,4 @@ -
\ No newline at end of file +
diff --git a/templates/mail/issue/mention.tmpl b/templates/mail/issue/mention.tmpl index 53ff367e2..e88b9abf0 100644 --- a/templates/mail/issue/mention.tmpl +++ b/templates/mail/issue/mention.tmpl @@ -14,4 +14,4 @@ View it on Gogs.

- \ No newline at end of file + diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index 474c8795a..921e3667c 100644 --- a/templates/org/home.tmpl +++ b/templates/org/home.tmpl @@ -27,7 +27,7 @@
{{if .IsOrganizationOwner}}
- {{.i18n.Tr "new_repo"}} + {{.i18n.Tr "new_repo"}}
{{end}} @@ -46,7 +46,7 @@
{{$isMember := .IsOrganizationMember}} {{range .Members}} - {{if or $isMember (.IsPublicMember $.Org.Id)}} + {{if or $isMember (.IsPublicMember $.Org.ID)}} {{end}} {{end}} diff --git a/templates/org/member/members.tmpl b/templates/org/member/members.tmpl index ddd341af2..85f7cc904 100644 --- a/templates/org/member/members.tmpl +++ b/templates/org/member/members.tmpl @@ -25,13 +25,13 @@ {{$.i18n.Tr "org.members.membership_visibility"}}
- {{ $isPublic := .IsPublicMember $.Org.Id}} + {{ $isPublic := .IsPublicMember $.Org.ID}} {{if $isPublic}} {{$.i18n.Tr "org.members.public"}} - {{if or (eq $.SignedUser.Id .Id) $.IsOrganizationOwner}}({{$.i18n.Tr "org.members.public_helper"}}){{end}} + {{if or (eq $.SignedUser.ID .ID) $.IsOrganizationOwner}}({{$.i18n.Tr "org.members.public_helper"}}){{end}} {{else}} {{$.i18n.Tr "org.members.private"}} - {{if or (eq $.SignedUser.Id .Id) $.IsOrganizationOwner}}({{$.i18n.Tr "org.members.private_helper"}}){{end}} + {{if or (eq $.SignedUser.ID .ID) $.IsOrganizationOwner}}({{$.i18n.Tr "org.members.private_helper"}}){{end}} {{end}}
@@ -40,15 +40,15 @@ {{$.i18n.Tr "org.members.member_role"}}
- {{if .IsUserOrgOwner $.Org.Id}} {{$.i18n.Tr "org.members.owner"}}{{else}}{{$.i18n.Tr "org.members.member"}}{{end}} + {{if .IsUserOrgOwner $.Org.ID}} {{$.i18n.Tr "org.members.owner"}}{{else}}{{$.i18n.Tr "org.members.member"}}{{end}}
- {{if eq $.SignedUser.Id .Id}} - {{$.i18n.Tr "org.members.leave"}} + {{if eq $.SignedUser.ID .ID}} + {{$.i18n.Tr "org.members.leave"}} {{else if $.IsOrganizationOwner}} - {{$.i18n.Tr "org.members.remove"}} + {{$.i18n.Tr "org.members.remove"}} {{end}}
diff --git a/templates/org/team/members.tmpl b/templates/org/team/members.tmpl index 3f070b741..cd50ee4ff 100644 --- a/templates/org/team/members.tmpl +++ b/templates/org/team/members.tmpl @@ -13,7 +13,7 @@ {{range .Team.Members}}
{{if $.IsOrganizationOwner}} - {{$.i18n.Tr "org.members.remove"}} + {{$.i18n.Tr "org.members.remove"}} {{end}} @@ -26,7 +26,7 @@
{{.CsrfTokenHtml}} - +
diff --git a/templates/org/team/repositories.tmpl b/templates/org/team/repositories.tmpl index b8110081a..cc79dd189 100644 --- a/templates/org/team/repositories.tmpl +++ b/templates/org/team/repositories.tmpl @@ -28,7 +28,7 @@ {{.CsrfTokenHtml}}
-
+
diff --git a/templates/org/team/sidebar.tmpl b/templates/org/team/sidebar.tmpl index d17261593..02cb8d7d2 100644 --- a/templates/org/team/sidebar.tmpl +++ b/templates/org/team/sidebar.tmpl @@ -2,10 +2,10 @@

{{.Team.Name}}

diff --git a/templates/org/team/teams.tmpl b/templates/org/team/teams.tmpl index a5ad5d48c..62acc2f2b 100644 --- a/templates/org/team/teams.tmpl +++ b/templates/org/team/teams.tmpl @@ -16,10 +16,10 @@
{{.Name}}
- {{if .IsMember $.SignedUser.Id}} - {{$.i18n.Tr "org.teams.leave"}} + {{if .IsMember $.SignedUser.ID}} + {{$.i18n.Tr "org.teams.leave"}} {{else if $.IsOrganizationOwner}} - {{$.i18n.Tr "org.teams.join"}} + {{$.i18n.Tr "org.teams.join"}} {{end}}
diff --git a/templates/repo/create.tmpl b/templates/repo/create.tmpl index 8cd466f3d..c203f9508 100644 --- a/templates/repo/create.tmpl +++ b/templates/repo/create.tmpl @@ -12,19 +12,19 @@