@@ -500,23 +500,22 @@ func RemoveTeamRepository(ctx *context.APIContext) {
500
500
501
501
// SearchTeam api for searching teams
502
502
func SearchTeam (ctx * context.APIContext ) {
503
- // swagger:operation GET /teams/search organization teamSearch
503
+ // swagger:operation GET /orgs/{org}/ teams/search organization teamSearch
504
504
// ---
505
- // summary: Search for teams
505
+ // summary: Search for teams within organization
506
506
// produces:
507
507
// - application/json
508
508
// parameters:
509
+ // - name: org
510
+ // in: path
511
+ // description: name of the organization
512
+ // type: string
513
+ // required: true
509
514
// - name: q
510
515
// in: query
511
516
// description: keywords to search
512
517
// required: true
513
518
// type: string
514
- // - name: org_id
515
- // in: query
516
- // description: search only teams within organization
517
- // type: integer
518
- // format: int64
519
- // required: false
520
519
// - name: inclDesc
521
520
// in: query
522
521
// description: include search within team description (defaults to true)
@@ -541,22 +540,11 @@ func SearchTeam(ctx *context.APIContext) {
541
540
UserID : ctx .Data ["SignedUserID" ].(int64 ),
542
541
UserIsAdmin : ctx .IsUserSiteAdmin (),
543
542
Keyword : strings .Trim (ctx .Query ("q" ), " " ),
544
- OrgID : ctx .QueryInt64 ( "org_id" ) ,
543
+ OrgID : ctx .Org . Organization . ID ,
545
544
IncludeDesc : (ctx .Query ("inclDesc" ) == "" || ctx .QueryBool ("inclDesc" )),
546
545
Limit : ctx .QueryInt ("limit" ),
547
546
}
548
547
549
- // If searching in a specific organization, require organization membership
550
- if opts .OrgID > 0 {
551
- if isMember , err := models .IsOrganizationMember (opts .OrgID , opts .UserID ); err != nil {
552
- ctx .Error (500 , "IsOrganizationMember" , err )
553
- return
554
- } else if ! isMember && ! ctx .IsUserSiteAdmin () {
555
- ctx .Error (403 , "" , "Must be an organization member" )
556
- return
557
- }
558
- }
559
-
560
548
teams , _ , err := models .SearchTeam (opts )
561
549
if err != nil {
562
550
ctx .JSON (500 , map [string ]interface {}{
@@ -567,28 +555,12 @@ func SearchTeam(ctx *context.APIContext) {
567
555
}
568
556
569
557
apiTeams := make ([]* api.Team , len (teams ))
570
- cache := make (map [int64 ]* api.Organization )
571
558
for i := range teams {
572
559
if err := teams [i ].GetUnits (); err != nil {
573
560
ctx .Error (500 , "GetUnits" , err )
574
561
return
575
562
}
576
563
apiTeams [i ] = convert .ToTeam (teams [i ])
577
-
578
- if opts .OrgID <= 0 {
579
- apiOrg , ok := cache [teams [i ].OrgID ]
580
- if ! ok {
581
- org , err := models .GetUserByID (teams [i ].OrgID )
582
- if err != nil {
583
- ctx .Error (500 , "GetUserByID" , err )
584
- return
585
- }
586
- apiOrg = convert .ToOrganization (org )
587
- cache [teams [i ].OrgID ] = apiOrg
588
- }
589
- apiTeams [i ] = convert .ToTeam (teams [i ])
590
- apiTeams [i ].Organization = apiOrg
591
- }
592
564
}
593
565
594
566
ctx .JSON (200 , map [string ]interface {}{
0 commit comments