mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Refactor User.Id to User.ID
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
@@ -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 {
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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)
|
||||
}
|
||||
|
@@ -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)
|
||||
|
@@ -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,
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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 {
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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 {
|
||||
|
@@ -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,
|
||||
}
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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()})
|
||||
}
|
||||
|
@@ -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)
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
}
|
||||
|
@@ -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"))
|
||||
|
@@ -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),
|
||||
|
@@ -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,
|
||||
|
@@ -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 {
|
||||
|
@@ -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,
|
||||
|
@@ -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,
|
||||
|
@@ -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)
|
||||
|
@@ -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)
|
||||
|
@@ -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(),
|
||||
},
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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 {
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user