From 0b3ea428477b9da33f40252e79aafe85b09526f3 Mon Sep 17 00:00:00 2001 From: David Schneiderbauer Date: Thu, 21 Jun 2018 18:00:13 +0200 Subject: hide issues from org private repos w/o team assignment (#4034) --- models/org.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'models/org.go') diff --git a/models/org.go b/models/org.go index ed0d583067..23f6c58bf6 100644 --- a/models/org.go +++ b/models/org.go @@ -154,12 +154,26 @@ func CreateOrganization(org, owner *User) (err error) { Name: ownerTeamName, Authorize: AccessModeOwner, NumMembers: 1, - UnitTypes: allRepUnitTypes, } if _, err = sess.Insert(t); err != nil { return fmt.Errorf("insert owner team: %v", err) } + // insert units for team + var units = make([]TeamUnit, 0, len(allRepUnitTypes)) + for _, tp := range allRepUnitTypes { + units = append(units, TeamUnit{ + OrgID: org.ID, + TeamID: t.ID, + Type: tp, + }) + } + + if _, err = sess.Insert(&units); err != nil { + sess.Rollback() + return err + } + if _, err = sess.Insert(&TeamUser{ UID: owner.ID, OrgID: org.ID, @@ -238,6 +252,7 @@ func deleteOrg(e *xorm.Session, u *User) error { &Team{OrgID: u.ID}, &OrgUser{OrgID: u.ID}, &TeamUser{OrgID: u.ID}, + &TeamUnit{OrgID: u.ID}, ); err != nil { return fmt.Errorf("deleteBeans: %v", err) } -- cgit v1.2.3