From 802a2fbcce500247e49f480c1b8af565cb0a7003 Mon Sep 17 00:00:00 2001 From: Wenkai Yin Date: Wed, 14 Jun 2017 20:23:29 +0800 Subject: [PATCH] update --- docs/swagger.yaml | 10 ---------- src/common/dao/project.go | 1 - src/ui/api/project.go | 33 ++++----------------------------- src/ui/api/project_test.go | 16 +--------------- 4 files changed, 5 insertions(+), 55 deletions(-) diff --git a/docs/swagger.yaml b/docs/swagger.yaml index a90592b92..ad9579df8 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -63,16 +63,6 @@ paths: description: The name of project owner. required: false type: string - - name: member - in: query - description: The name of project member. - required: false - type: string - - name: role - in: query - description: The role of member, only take effect when member is provided. - required: false - type: integer - name: page in: query type: integer diff --git a/src/common/dao/project.go b/src/common/dao/project.go index 5f0e73fad..d3cb4ae34 100644 --- a/src/common/dao/project.go +++ b/src/common/dao/project.go @@ -273,7 +273,6 @@ func projectQueryConditions(owner, name string, public *bool, member string, // 1. all projects // 2. public projects // 3. public projects and projects which the user is a member of - // 4. projects which the user is a member of collection := `project ` if len(base) != 0 && base[0] != nil { if len(base[0].Member) > 0 { diff --git a/src/ui/api/project.go b/src/ui/api/project.go index 4c6ff1965..a06be9e69 100644 --- a/src/ui/api/project.go +++ b/src/ui/api/project.go @@ -278,42 +278,17 @@ func (p *ProjectAPI) List() { query.Public = &pub } - member := p.GetString("member") - if len(member) > 0 { - query.Member = &models.Member{ - Name: member, - } - - role := p.GetString("role") - if len(role) > 0 { - r, err := strconv.Atoi(role) - if err != nil { - if err != nil { - p.HandleBadRequest(fmt.Sprintf("invalid role: %s", role)) - return - } - } - query.Member.Role = r - } - } - // base project collection from which filter is done base := &models.BaseProjectCollection{} if !p.SecurityCtx.IsAuthenticated() { - if query.Member != nil && len(query.Member.Name) > 0 { - // must login if query member - p.HandleUnauthorized() - return - } + // not login, only get public projects base.Public = true } else { if !p.SecurityCtx.IsSysAdmin() { + // login, but not system admin, get public projects and + // projects that the user is member of base.Member = p.SecurityCtx.GetUsername() - if query.Member != nil && len(query.Member.Name) > 0 { - base.Public = false - } else { - base.Public = true - } + base.Public = true } } diff --git a/src/ui/api/project_test.go b/src/ui/api/project_test.go index 8b4d0571f..0bc143d80 100644 --- a/src/ui/api/project_test.go +++ b/src/ui/api/project_test.go @@ -113,24 +113,12 @@ func TestListProjects(t *testing.T) { //find add projectID addPID = int(result[0].ProjectId) - //----------------------------case 2 : Response Code=401----------------------------// - fmt.Println("case 2: respose code:401") - httpStatusCode, result, err = apiTest.ProjectsGet( - &apilib.ProjectQuery{ - Member: admin.Name, - }) - t.Logf("$$$$$$$$$$$$$$$$$$$%v", result) - assert.Nil(err) - assert.Equal(int(401), httpStatusCode) - //-------------------case 3 : check admin project role------------------------// httpStatusCode, result, err = apiTest.ProjectsGet( &apilib.ProjectQuery{ Name: addProject.ProjectName, Owner: admin.Name, Public: true, - Member: admin.Name, - Role: 1, }, *admin) if err != nil { t.Error("Error while search project by proName and isPublic", err.Error()) @@ -155,9 +143,7 @@ func TestListProjects(t *testing.T) { } httpStatusCode, result, err = apiTest.ProjectsGet( &apilib.ProjectQuery{ - Name: addProject.ProjectName, - Member: TestUserName, - Role: 2, + Name: addProject.ProjectName, }, *testUser) if err != nil { t.Error("Error while search project by proName and isPublic", err.Error())