diff options
author | Unknwon <u@gogs.io> | 2016-07-24 01:08:22 +0800 |
---|---|---|
committer | Unknwon <u@gogs.io> | 2016-07-24 01:08:22 +0800 |
commit | 1f2e173a745da8e4b57f96b5561a3c10054d3b76 (patch) | |
tree | 367f0f07e4fe1269ac0772e0561a4bf912b5153c /routers/repo | |
parent | 46e96c008cf966428c9dad71c7871de88186e3fe (diff) | |
download | gitea-1f2e173a745da8e4b57f96b5561a3c10054d3b76.tar.gz gitea-1f2e173a745da8e4b57f96b5561a3c10054d3b76.zip |
Refactor User.Id to User.ID
Diffstat (limited to 'routers/repo')
-rw-r--r-- | routers/repo/http.go | 4 | ||||
-rw-r--r-- | routers/repo/issue.go | 24 | ||||
-rw-r--r-- | routers/repo/pull.go | 10 | ||||
-rw-r--r-- | routers/repo/release.go | 2 | ||||
-rw-r--r-- | routers/repo/repo.go | 18 | ||||
-rw-r--r-- | routers/repo/setting.go | 14 | ||||
-rw-r--r-- | routers/repo/webhook.go | 6 |
7 files changed, 39 insertions, 39 deletions
diff --git a/routers/repo/http.go b/routers/repo/http.go index fba06133c9..d6abc77452 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 1562845bad..269066eb61 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 01a5102f7e..8fb7ae1831 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 4aeec2b8d7..0df4a1f1d9 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 f9835bd2f9..3c1775dce4 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 c5772dca52..08f06dcb30 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 22d5cfd2c6..715c6a4c72 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(), }, } |