@@ -15,7 +15,9 @@ import (
15
15
)
16
16
17
17
var (
18
- ErrOrgNotExist = errors .New ("Organization does not exist" )
18
+ // ErrOrgNotExist organization does not exist
19
+ ErrOrgNotExist = errors .New ("Organization does not exist" )
20
+ // ErrTeamNotExist team does not exist
19
21
ErrTeamNotExist = errors .New ("Team does not exist" )
20
22
)
21
23
@@ -68,7 +70,7 @@ func (org *User) GetMembers() error {
68
70
69
71
var ids = make ([]int64 , len (ous ))
70
72
for i , ou := range ous {
71
- ids [i ] = ou .Uid
73
+ ids [i ] = ou .UID
72
74
}
73
75
org .Members , err = GetUsersByIDs (ids )
74
76
return err
@@ -127,7 +129,7 @@ func CreateOrganization(org, owner *User) (err error) {
127
129
128
130
// Add initial creator to organization and owner team.
129
131
if _ , err = sess .Insert (& OrgUser {
130
- Uid : owner .ID ,
132
+ UID : owner .ID ,
131
133
OrgID : org .ID ,
132
134
IsOwner : true ,
133
135
NumTeams : 1 ,
@@ -235,37 +237,37 @@ func DeleteOrganization(org *User) (err error) {
235
237
// OrgUser represents an organization-user relation.
236
238
type OrgUser struct {
237
239
ID int64 `xorm:"pk autoincr"`
238
- Uid int64 `xorm:"INDEX UNIQUE(s)"`
240
+ UID int64 `xorm:"INDEX UNIQUE(s)"`
239
241
OrgID int64 `xorm:"INDEX UNIQUE(s)"`
240
242
IsPublic bool
241
243
IsOwner bool
242
244
NumTeams int
243
245
}
244
246
245
247
// IsOrganizationOwner returns true if given user is in the owner team.
246
- func IsOrganizationOwner (orgId , uid int64 ) bool {
248
+ func IsOrganizationOwner (orgID , uid int64 ) bool {
247
249
has , _ := x .
248
250
Where ("is_owner=?" , true ).
249
251
And ("uid=?" , uid ).
250
- And ("org_id=?" , orgId ).
252
+ And ("org_id=?" , orgID ).
251
253
Get (new (OrgUser ))
252
254
return has
253
255
}
254
256
255
257
// IsOrganizationMember returns true if given user is member of organization.
256
- func IsOrganizationMember (orgId , uid int64 ) bool {
258
+ func IsOrganizationMember (orgID , uid int64 ) bool {
257
259
has , _ := x .
258
260
Where ("uid=?" , uid ).
259
- And ("org_id=?" , orgId ).
261
+ And ("org_id=?" , orgID ).
260
262
Get (new (OrgUser ))
261
263
return has
262
264
}
263
265
264
266
// IsPublicMembership returns true if given user public his/her membership.
265
- func IsPublicMembership (orgId , uid int64 ) bool {
267
+ func IsPublicMembership (orgID , uid int64 ) bool {
266
268
has , _ := x .
267
269
Where ("uid=?" , uid ).
268
- And ("org_id=?" , orgId ).
270
+ And ("org_id=?" , orgID ).
269
271
And ("is_public=?" , true ).
270
272
Get (new (OrgUser ))
271
273
return has
@@ -311,7 +313,7 @@ func GetOwnedOrgsByUserID(userID int64) ([]*User, error) {
311
313
return getOwnedOrgsByUserID (sess , userID )
312
314
}
313
315
314
- // GetOwnedOrganizationsByUserIDDesc returns a list of organizations are owned by
316
+ // GetOwnedOrgsByUserIDDesc returns a list of organizations are owned by
315
317
// given user ID, ordered descending by the given condition.
316
318
func GetOwnedOrgsByUserIDDesc (userID int64 , desc string ) ([]* User , error ) {
317
319
sess := x .NewSession ()
@@ -374,7 +376,7 @@ func AddOrgUser(orgID, uid int64) error {
374
376
}
375
377
376
378
ou := & OrgUser {
377
- Uid : uid ,
379
+ UID : uid ,
378
380
OrgID : orgID ,
379
381
}
380
382
@@ -512,7 +514,7 @@ func (org *User) GetUserTeamIDs(userID int64) ([]int64, error) {
512
514
return teamIDs , nil
513
515
}
514
516
515
- // GetTeams returns all teams that belong to organization ,
517
+ // GetUserTeams returns all teams that belong to user ,
516
518
// and that the user has joined.
517
519
func (org * User ) GetUserTeams (userID int64 ) ([]* Team , error ) {
518
520
return org .getUserTeams (x , userID )
@@ -560,7 +562,7 @@ func (org *User) GetUserRepositories(userID int64, page, pageSize int) ([]*Repos
560
562
return repos , repoCount , nil
561
563
}
562
564
563
- // GetUserRepositories returns mirror repositories of the organization
565
+ // GetUserMirrorRepositories returns mirror repositories of the user
564
566
// that the user with the given userID has access to.
565
567
func (org * User ) GetUserMirrorRepositories (userID int64 ) ([]* Repository , error ) {
566
568
teamIDs , err := org .GetUserTeamIDs (userID )
0 commit comments