- <%= link_to "+添加",all_partners_managements_path,remote:true,class:"color-blue addOperation" %>
+ <%= link_to "+添加", all_partners_managements_path,remote:true,class:"color-blue addOperation" %>
<%= render :partial => "partner_list" %>
@@ -31,7 +31,7 @@
}
- function delPartners(){
- delete_confirm_box_2("","确定删除合作伙伴?");
+ function delPartners(url){
+ delete_confirm_box_2(url,"确定删除合作伙伴?");
}
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 9c70df82..73cbadc6 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -719,6 +719,7 @@ RedmineApp::Application.routes.draw do ## oauth相关
post 'update_level_for_subject'
post :add_customers
delete :delete_customers
+ delete :delete_partner
get :customers_list
get :school_report, controller: 'managements::schools', action: 'statistics'
end
diff --git a/db/migrate/20190425072918_create_partner_customers.rb b/db/migrate/20190425072918_create_partner_customers.rb
new file mode 100644
index 00000000..69d13714
--- /dev/null
+++ b/db/migrate/20190425072918_create_partner_customers.rb
@@ -0,0 +1,9 @@
+class CreatePartnerCustomers < ActiveRecord::Migration
+ def change
+ create_table :partner_customers do |t|
+ t.references :partner
+ t.references :customer
+ t.timestamps
+ end
+ end
+end
diff --git a/db/migrate/20190425073328_modify_partner_and_customer.rb b/db/migrate/20190425073328_modify_partner_and_customer.rb
new file mode 100644
index 00000000..c4f7b97a
--- /dev/null
+++ b/db/migrate/20190425073328_modify_partner_and_customer.rb
@@ -0,0 +1,29 @@
+class ModifyPartnerAndCustomer < ActiveRecord::Migration
+ def up
+ add_column :customers, :school_id, :integer
+ add_column :partners, :school_id, :integer
+
+ schools = School.where("customer_id is not null or partner_id is not null")
+
+ schools.each do |school|
+ if school.customer_id
+ customer = Customer.find_by_id(school.customer_id)
+ customer.update_column(:school_id, school.id) if customer
+ end
+ if school.partner_id
+ partner = Partner.find_by_id(school.partner_id)
+ partner.update_column(:school_id, school.id) if partner
+ end
+ end
+
+ # 迁移关联关系
+ customers = Customer.where(nil)
+ customers.each do |customer|
+ PartnerCustomer.create(partner_id: customer.partner_id, customer_id: customer.id)
+ end
+
+ end
+
+ def down
+ end
+end
diff --git a/spec/factories/partner_customers.rb b/spec/factories/partner_customers.rb
new file mode 100644
index 00000000..6327b7ca
--- /dev/null
+++ b/spec/factories/partner_customers.rb
@@ -0,0 +1,5 @@
+FactoryGirl.define do
+ factory :partner_customer do
+
+ end
+end
diff --git a/spec/models/partner_customer_spec.rb b/spec/models/partner_customer_spec.rb
new file mode 100644
index 00000000..6dc614cf
--- /dev/null
+++ b/spec/models/partner_customer_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe PartnerCustomer, :type => :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end