@@ -330,46 +330,40 @@ func DeleteTeam(t *Team) error {
330
330
return err
331
331
}
332
332
333
- // Get organization.
334
- org , err := GetUserByID (t .OrgID )
335
- if err != nil {
336
- return err
337
- }
338
-
339
333
sess := x .NewSession ()
340
334
defer sessionRelease (sess )
341
- if err = sess .Begin (); err != nil {
335
+ if err : = sess .Begin (); err != nil {
342
336
return err
343
337
}
344
338
345
339
// Delete all accesses.
346
340
for _ , repo := range t .Repos {
347
- if err = repo .recalculateTeamAccesses (sess , t .ID ); err != nil {
341
+ if err : = repo .recalculateTeamAccesses (sess , t .ID ); err != nil {
348
342
return err
349
343
}
350
344
}
351
345
352
346
// Delete team-repo
353
- if _ , err = sess .
347
+ if _ , err : = sess .
354
348
Where ("team_id=?" , t .ID ).
355
349
Delete (new (TeamRepo )); err != nil {
356
350
return err
357
351
}
358
352
359
353
// Delete team-user.
360
- if _ , err = sess .
361
- Where ("org_id=?" , org . ID ).
354
+ if _ , err : = sess .
355
+ Where ("org_id=?" , t . OrgID ).
362
356
Where ("team_id=?" , t .ID ).
363
357
Delete (new (TeamUser )); err != nil {
364
358
return err
365
359
}
366
360
367
361
// Delete team.
368
- if _ , err = sess .Id (t .ID ).Delete (new (Team )); err != nil {
362
+ if _ , err : = sess .Id (t .ID ).Delete (new (Team )); err != nil {
369
363
return err
370
364
}
371
365
// Update organization number of teams.
372
- if _ , err = sess .Exec ("UPDATE `user` SET num_teams=num_teams-1 WHERE id=?" , t .OrgID ); err != nil {
366
+ if _ , err : = sess .Exec ("UPDATE `user` SET num_teams=num_teams-1 WHERE id=?" , t .OrgID ); err != nil {
373
367
return err
374
368
}
375
369
@@ -517,12 +511,6 @@ func removeTeamMember(e Engine, team *Team, userID int64) error {
517
511
return err
518
512
}
519
513
520
- // Get organization.
521
- org , err := getUserByID (e , team .OrgID )
522
- if err != nil {
523
- return err
524
- }
525
-
526
514
if _ , err := e .Delete (& TeamUser {
527
515
UID : userID ,
528
516
OrgID : team .OrgID ,
@@ -538,16 +526,16 @@ func removeTeamMember(e Engine, team *Team, userID int64) error {
538
526
539
527
// Delete access to team repositories.
540
528
for _ , repo := range team .Repos {
541
- if err = repo .recalculateTeamAccesses (e , 0 ); err != nil {
529
+ if err : = repo .recalculateTeamAccesses (e , 0 ); err != nil {
542
530
return err
543
531
}
544
532
}
545
533
546
534
// This must exist.
547
535
ou := new (OrgUser )
548
- _ , err = e .
536
+ _ , err : = e .
549
537
Where ("uid = ?" , userID ).
550
- And ("org_id = ?" , org . ID ).
538
+ And ("org_id = ?" , team . OrgID ).
551
539
Get (ou )
552
540
if err != nil {
553
541
return err
0 commit comments