From 7eb2e4c71351398cbcbf5a1f2c9b77c1099a9e1b Mon Sep 17 00:00:00 2001 From: p31729568 Date: Wed, 31 Jul 2019 13:42:05 +0800 Subject: [PATCH 1/3] move user project search api controller --- app/controllers/projects_controller.rb | 8 -------- app/controllers/users/base_controller.rb | 2 +- app/controllers/users/projects_controller.rb | 11 +++++++++++ app/views/{ => users}/projects/search.json.jbuilder | 0 config/routes.rb | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) rename app/views/{ => users}/projects/search.json.jbuilder (100%) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index c9ed6c597..672477790 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -1,10 +1,2 @@ class ProjectsController < ApplicationController - def search - query_params = { keyword: params[:keyword], category: 'manage' } - projects = Users::ProjectService.new(current_user, query_params).call - - params[:limit] = params[:per_page].to_i.zero? ? 20 : params[:per_page].to_i - @count = projects.count - @projects = paginate projects - end end \ No newline at end of file diff --git a/app/controllers/users/base_controller.rb b/app/controllers/users/base_controller.rb index fd138a182..969aca320 100644 --- a/app/controllers/users/base_controller.rb +++ b/app/controllers/users/base_controller.rb @@ -43,7 +43,7 @@ class Users::BaseController < ApplicationController page = page_value per_page = per_page_value - return Kaminari.paginate_array(objs).page(page).per(per_page) unless observed_logged_user? && opts[:special] + return Kaminari.paginate_array(objs).page(page).per(per_page) unless opts[:special] && observed_logged_user? # note: 为实现第一页少一条记录,让前端放置新建入口 if page == 1 diff --git a/app/controllers/users/projects_controller.rb b/app/controllers/users/projects_controller.rb index 863b99b37..07f4d5cac 100644 --- a/app/controllers/users/projects_controller.rb +++ b/app/controllers/users/projects_controller.rb @@ -1,4 +1,6 @@ class Users::ProjectsController < Users::BaseController + skip_before_action :check_observed_user_exists!, only: [:search] + def index projects = Users::ProjectService.new(observed_user, query_params).call @@ -6,6 +8,15 @@ class Users::ProjectsController < Users::BaseController @projects = paginate(projects.includes(:project_score, owner: { user_extension: :school }), special: true) end + def search + query_params = { keyword: params[:keyword], category: 'manage' } + projects = Users::ProjectService.new(current_user, query_params).call + + params[:limit] = params[:per_page].to_i.zero? ? 20 : params[:per_page].to_i + @count = projects.count + @projects = paginate projects + end + private def query_params diff --git a/app/views/projects/search.json.jbuilder b/app/views/users/projects/search.json.jbuilder similarity index 100% rename from app/views/projects/search.json.jbuilder rename to app/views/users/projects/search.json.jbuilder diff --git a/config/routes.rb b/config/routes.rb index 2f9eed61b..581f563b0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -75,7 +75,7 @@ Rails.application.routes.draw do get :system_update resource :trial_apply, only: [:create] - resources :projects, only: [] do + resources :projects, module: :users, only: [] do get :search, on: :collection end From ea5d5dceaea5fe4323ae7bd96c315de4efe908d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 31 Jul 2019 13:58:06 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../courses/exercise/Studentshavecompletedthelist.js | 6 ++++-- .../modules/courses/exercise/Testpapersettinghomepage.js | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/public/react/src/modules/courses/exercise/Studentshavecompletedthelist.js b/public/react/src/modules/courses/exercise/Studentshavecompletedthelist.js index f7a989f79..0556d94e9 100644 --- a/public/react/src/modules/courses/exercise/Studentshavecompletedthelist.js +++ b/public/react/src/modules/courses/exercise/Studentshavecompletedthelist.js @@ -2312,11 +2312,13 @@ class Studentshavecompletedthelist extends Component { }; _getRequestParams() { - const { order, checkedValuesineinfo,searchtext, page ,limit} = this.state + const { order, checkedValuesineinfo,course_groupyslstwo ,searchtext, page ,limit,course_groupyslsthree} = this.state return { page, + review:course_groupyslsthree, + commit_status:course_groupyslstwo, search:searchtext, - group_id:checkedValuesineinfo, + exercise_group_id:checkedValuesineinfo, limit: limit, order, } diff --git a/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js b/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js index 24e960a9d..8e895b852 100644 --- a/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js +++ b/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js @@ -170,7 +170,7 @@ class Testpapersettinghomepage extends Component{ } console.log("170"); console.log(params); - axios.get(url+`?${queryString.stringify(params)}`).then((response) => { + axios.get(url+`?${queryString.stringify(params)}`+ '&export=true').then((response) => { if(response===undefined){ return } @@ -193,7 +193,7 @@ class Testpapersettinghomepage extends Component{ } }else { this.props.showNotification(`正在下载中`); - window.open("/api"+url+`?${queryString.stringify(params)}`, '_blank'); + window.open("/api"+url+`?${queryString.stringify(params)}`+ '&export=true', '_blank'); } }).catch((error) => { console.log(error) @@ -357,7 +357,7 @@ class Testpapersettinghomepage extends Component{ 导出 :""} From 730d83de4dc431e2810f085a276eb3a888b6b904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 31 Jul 2019 14:00:53 +0800 Subject: [PATCH 3/3] Merge branch 'dev_aliyun' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun # Conflicts: # public/react/src/modules/courses/exercise/Testpapersettinghomepage.js --- .../src/modules/courses/exercise/Testpapersettinghomepage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js b/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js index 52dd9c080..8e895b852 100644 --- a/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js +++ b/public/react/src/modules/courses/exercise/Testpapersettinghomepage.js @@ -357,7 +357,7 @@ class Testpapersettinghomepage extends Component{ 导出 :""}