From eece0a31eec63ad2be8761da2b2b7c4c37072175 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Thu, 4 Apr 2019 12:55:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=88=E4=BD=9C=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/managements_controller.rb | 17 +++++++------ app/models/school.rb | 3 ++- app/views/layouts/base_management.html.erb | 4 ++++ .../managements/_partner_addUnit.html.erb | 24 +++++++++---------- .../managements/_partner_search_form.html.erb | 4 ++-- app/views/managements/_partners_list.html.erb | 12 +++++----- app/views/managements/all_partners.js.erb | 9 ++++--- 7 files changed, 37 insertions(+), 36 deletions(-) diff --git a/app/controllers/managements_controller.rb b/app/controllers/managements_controller.rb index 48b2e05a..c92ae34d 100644 --- a/app/controllers/managements_controller.rb +++ b/app/controllers/managements_controller.rb @@ -1196,7 +1196,7 @@ end def all_partners @search = params[:search] @province = params[:province] - @schools = School.where("partner_id IS NULL").all + @schools = School.where("partner_id IS NULL") if params[:search] @schools = @schools.where("name like ?", "%#{@search}%") @@ -1222,18 +1222,17 @@ end def add_partner - school_ids = params[:school] - if school_ids.count > 0 - print school_ids + school_ids = params[:school_ids] + if school_ids.length > 0 school_ids.each do |s| school = School.where("id = ?",s).first - @partner = Partner.new(name: school.name) - @partner.save - school.partner_id = @partner.id - school.save + if school.present? + partner = Partner.new(name: school.name) + partner.save + school.update_attributes(:partner_id => partner.id) + end end render :json => {status: 1, message: "创建成功!"} - redirect_to partners_path end end diff --git a/app/models/school.rb b/app/models/school.rb index dd3332c4..62e27987 100644 --- a/app/models/school.rb +++ b/app/models/school.rb @@ -3,7 +3,8 @@ class School < ActiveRecord::Base attr_accessible :name, :province, :pinyin, :city, :address, :logo_link, :auto_users_trial, :shool_code, :authorization_time, - :identifier, :is_online, :video_desc, :video_name,:course_link, :course_name + :identifier, :is_online, :video_desc, :video_name,:course_link, + :course_name, :partner_id, :customer_id has_many :courses has_many :departments, :dependent => :destroy has_many :shixun_schools, :dependent => :destroy diff --git a/app/views/layouts/base_management.html.erb b/app/views/layouts/base_management.html.erb index 45f570d2..65c444c1 100644 --- a/app/views/layouts/base_management.html.erb +++ b/app/views/layouts/base_management.html.erb @@ -13,6 +13,10 @@ <%= javascript_include_tag "edu/application",'edu/base_edu','edu/account', 'baiduTemplate', 'jquery.datetimepicker.js', "edu/management", 'educoder/edu_application' %> <%= call_hook :view_layouts_base_html_head %> <%= yield :header_tags -%> + +
diff --git a/app/views/managements/_partner_addUnit.html.erb b/app/views/managements/_partner_addUnit.html.erb index 8a877398..820cb75d 100644 --- a/app/views/managements/_partner_addUnit.html.erb +++ b/app/views/managements/_partner_addUnit.html.erb @@ -2,10 +2,10 @@
添加合作伙伴
-
+
<%= render partial: "managements/partner_search_form" %>
- 搜索 + 搜索

@@ -13,7 +13,7 @@ 地区

- + <%= render :partial => "partners_list" %>

@@ -25,12 +25,9 @@