From fc7e41ebf99692748c9bfe519536a5c6a7cbe508 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 18 Nov 2015 10:57:17 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=9C=A8=E9=A1=B9=E7=9B=AE=E5=92=8C=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=9C=A8=E5=85=B3=E8=81=94=E5=92=8C=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=85=B3=E8=81=94=E7=BB=84=E7=BB=87=E5=90=8E=EF=BC=8C=E7=BF=BB?= =?UTF-8?q?=E9=A1=B5=E8=83=BD=E9=93=BE=E6=8E=A5=E5=88=B0=E6=AD=A3=E7=A1=AE?= =?UTF-8?q?=E7=9A=84=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/org_courses_controller.rb | 30 ------------------ app/controllers/org_projects_controller.rb | 31 ------------------- .../courses/settings/_added_orgs.html.erb | 7 +++-- app/views/courses/settings/_join_org.html.erb | 14 ++++++++- app/views/org_courses/create.js.erb | 13 +------- app/views/org_courses/destroy.js.erb | 15 +-------- app/views/org_projects/create.js.erb | 18 ----------- app/views/org_projects/destroy.js.erb | 22 ++----------- .../search_public_orgs_not_in_project.js.erb | 6 ++++ .../projects/settings/_join_org.html.erb | 26 +++++++++++----- public/javascripts/course.js | 14 +++++++++ 11 files changed, 61 insertions(+), 135 deletions(-) diff --git a/app/controllers/org_courses_controller.rb b/app/controllers/org_courses_controller.rb index d7e59382a..3d1d313c5 100644 --- a/app/controllers/org_courses_controller.rb +++ b/app/controllers/org_courses_controller.rb @@ -5,23 +5,6 @@ class OrgCoursesController < ApplicationController org_ids.each do |org_id| OrgCourse.create(:organization_id => org_id.to_i, :course_id => params[:course_id].to_i, :created_at => Time.now) end - - condition = '%%' - if !params[:name].nil? - condition = "%#{params[:name].strip}%".gsub(" ","") - end - course_org_ids = OrgCourse.find_by_sql("select distinct organization_id from org_courses where course_id = #{params[:course_id]}").map(&:organization_id) - if course_org_ids.empty? - @orgs_not_in_course = Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id, condition).page((params[:page].to_i || 1)).per(10) - @org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count - else - course_org_ids = "(" + course_org_ids.join(',') + ")" - @orgs_not_in_course = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page((params[:page].to_i || 1)).per(10) - @org_count = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count - end - # @course_count = Course.course_entities.visible.like(params[:name]).page(params[:page]).count - @orgs_page = Paginator.new @org_count, 10,params[:page] - #render :json => {:orgs => @orgs_not_in_course, :count => @org_count}.to_json respond_to do |format| format.js end @@ -31,18 +14,5 @@ class OrgCoursesController < ApplicationController @course = Course.find(params[:course_id]) @org_course = OrgCourse.find(params[:id]) @org_course.destroy - - condition = '%%' - course_org_ids = OrgCourse.find_by_sql("select distinct organization_id from org_courses where course_id = #{params[:course_id]}").map(&:organization_id) - if course_org_ids.empty? - @orgs_not_in_course = Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id, condition).page( 1).per(10) - @org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count - else - course_org_ids = "(" + course_org_ids.join(',') + ")" - @orgs_not_in_course = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page( 1).per(10) - @org_count = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count - end - # @course_count = Course.course_entities.visible.like(params[:name]).page(params[:page]).count - @orgs_page = Paginator.new @org_count, 10,1 end end diff --git a/app/controllers/org_projects_controller.rb b/app/controllers/org_projects_controller.rb index c944193bd..29e60a62a 100644 --- a/app/controllers/org_projects_controller.rb +++ b/app/controllers/org_projects_controller.rb @@ -5,24 +5,6 @@ class OrgProjectsController < ApplicationController org_ids.each do |org_id| OrgProject.create(:organization_id => org_id.to_i, :project_id => params[:project_id].to_i, :created_at => Time.now) end - - #更新组织列表 - condition = '%%' - if !params[:orgs].nil? - condition = "%#{params[:orgs].strip}%".gsub(" ","") - end - project_org_ids = OrgProject.find_by_sql("select distinct organization_id from org_projects where project_id = #{params[:project_id]}").map(&:organization_id) - if project_org_ids.empty? - @orgs_not_in_project = Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id, condition).page((params[:page].to_i || 1)).per(10) - @org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count - else - project_org_ids = "(" + project_org_ids.join(',') + ")" - @orgs_not_in_project = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page((params[:page].to_i || 1)).per(10) - @org_count = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count - end - # @project_count = Project.project_entities.visible.like(params[:name]).page(params[:page]).count - @orgs_page = Paginator.new @org_count, 10,params[:page] - respond_to do |format| format.js end @@ -31,18 +13,5 @@ class OrgProjectsController < ApplicationController @project = Project.find(params[:project_id]) @org_project = OrgProject.find(params[:id]) @org_project.destroy - - condition = '%%' - project_org_ids = OrgProject.find_by_sql("select distinct organization_id from org_projects where project_id = #{params[:project_id]}").map(&:organization_id) - if project_org_ids.empty? - @orgs_not_in_project = Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id, condition).page( 1).per(10) - @org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count - else - project_org_ids = "(" + project_org_ids.join(',') + ")" - @orgs_not_in_project = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page( 1).per(10) - @org_count = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count - end - # @project_count = Project.project_entities.visible.like(params[:name]).page(params[:page]).count - @orgs_page = Paginator.new @org_count, 10,1 end end diff --git a/app/views/courses/settings/_added_orgs.html.erb b/app/views/courses/settings/_added_orgs.html.erb index f3645bc11..9ac783ca0 100644 --- a/app/views/courses/settings/_added_orgs.html.erb +++ b/app/views/courses/settings/_added_orgs.html.erb @@ -1,8 +1,11 @@