1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-11-04 08:17:24 -05:00

Refactor User.Id to User.ID

This commit is contained in:
Unknwon 2016-07-24 01:08:22 +08:00
parent 46e96c008c
commit 1f2e173a74
79 changed files with 333 additions and 328 deletions

View File

@ -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 |
|:-------------:|:-------:|:-------:|

View File

@ -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)

View File

@ -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())

View File

@ -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)
}
}

View File

@ -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
}

View File

@ -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 {

View File

@ -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]),

View File

@ -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
}

View File

@ -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}
}

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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
}

View File

@ -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,

View File

@ -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),

View File

@ -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)

View File

@ -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"}
}
}

View File

@ -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)

View File

@ -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
}

View File

@ -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
}

View File

@ -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 {

View File

@ -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
}

View File

@ -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

View File

@ -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
}

View File

@ -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 {

View File

@ -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
}

View File

@ -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)
}

View File

@ -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)

View File

@ -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,

View File

@ -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
}

View File

@ -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 {

View File

@ -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
}

View File

@ -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 {

View File

@ -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,
}

View File

@ -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
}

View File

@ -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

View File

@ -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()})
}

View File

@ -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)
}

View File

@ -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
}

View File

@ -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"))

View File

@ -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),

View File

@ -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,

View File

@ -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 {

View File

@ -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,

View File

@ -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,

View File

@ -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)

View File

@ -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)

View File

@ -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(),
},
}

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -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 {

View File

@ -1 +1 @@
0.9.52.0723
0.9.53.0724

View File

@ -20,4 +20,4 @@
</div>
</div>
{{end}}
{{end}}
{{end}}

View File

@ -3,4 +3,4 @@
<input name="q" value="{{.Keyword}}" placeholder="{{.i18n.Tr "explore.search"}}..." autofocus>
<button class="ui blue button">{{.i18n.Tr "explore.search"}}</button>
</div>
</form>
</form>

View File

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

View File

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

View File

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

View File

@ -18,4 +18,4 @@
</div>
</div>
{{end}}
{{end}}
{{end}}

View File

@ -4,4 +4,4 @@
<button class="ui blue button">{{.i18n.Tr "explore.search"}}</button>
</div>
</form>
<div class="ui divider"></div>
<div class="ui divider"></div>

View File

@ -14,4 +14,4 @@
<a href="{{.Link}}">View it on Gogs</a>.
</p>
</body>
</html>
</html>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -44,4 +44,4 @@
</div>
{{end}}
{{end}}
</div>
</div>

View File

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

View File

@ -3,4 +3,4 @@
{{template "user/meta/header" .}}
{{template "repo/user_cards" .}}
</div>
{{template "base/footer" .}}
{{template "base/footer" .}}

View File

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

View File

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