From c91ef44570f7941f759a82bfbdb3d87dab1f67ac Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 23 Feb 2016 12:52:04 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=AD=90=E5=9F=9F=E5=90=8D?= =?UTF-8?q?=EF=BC=9A=E6=89=80=E6=9C=89=E5=AD=90=E5=9F=9F=E5=90=8D=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E5=88=B0secdomains=E8=A1=A8=EF=BC=8C=E5=B0=86?= =?UTF-8?q?=E7=BB=84=E7=BB=87=E8=A1=A8=E4=B8=AD=E7=9A=84=E5=AD=90=E5=9F=9F?= =?UTF-8?q?=E5=90=8D=E8=BF=81=E7=A7=BB=E5=88=B0secdomains=E8=A1=A8?= =?UTF-8?q?=E4=B8=AD=EF=BC=8C=E5=B9=B6=E4=BF=AE=E6=94=B9=E7=9B=B8=E5=BA=94?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/org_subfields_controller.rb | 3 ++- app/controllers/organizations_controller.rb | 9 +++++++-- app/views/organizations/_subfield_list.html.erb | 2 +- app/views/organizations/setting.html.erb | 11 ++++++----- app/views/users/user_organizations.html.erb | 5 ----- .../20160223021012_add_index_to_secdomain.rb | 5 +++++ .../20160223021227_move_domain_to_secdomain.rb | 14 ++++++++++++++ ...60223031843_remove_domain_from_organizations.rb | 8 ++++++++ db/schema.rb | 9 +++++++-- 9 files changed, 50 insertions(+), 16 deletions(-) create mode 100644 db/migrate/20160223021012_add_index_to_secdomain.rb create mode 100644 db/migrate/20160223021227_move_domain_to_secdomain.rb create mode 100644 db/migrate/20160223031843_remove_domain_from_organizations.rb diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index bae0232a5..2a4bcf9c8 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -30,7 +30,8 @@ class OrgSubfieldsController < ApplicationController if params[:id] @organization = Organization.find(params[:id]) else - @organization = Organization.where("domain=?",request.subdomain).first + domain = Secdomain.where("subname=?", request.subdomain).first + @organization = Organization.find(domain.pid) end @org_subfield = OrgSubfield.find_by_sql("select distinct org_subfields.* from org_subfields,"+ "subfield_subdomain_dirs where org_subfields.id = subfield_subdomain_dirs.org_subfield_id and "+ diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 6e2da311f..f225e7f50 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -139,7 +139,7 @@ class OrganizationsController < ApplicationController end def check_uniq_domain - @is_exist = (Organization.where("domain=?", params[:org_domain]).count > 0) + @is_exist = (Secdomain.where("subname=?",params[:org_domain]).count > 0) end def find_organization @@ -322,7 +322,12 @@ class OrganizationsController < ApplicationController def agree_apply_subdomain @organization = Organization.find(params[:organization_id]) OrgMessage.find(params[:act_id]).update_attribute(:viewed, 1) - @organization.update_attribute(:domain, params[:org_domain]) + if Secdomain.where("pid=? and sub_type=2",@organization.id).count > 0 + domain = Secdomain.where("pid=? and sub_type=2",params[:organization_id]).first + Secdomain.update(domain.id, :subname => params[:org_domain]) + else + Secdomain.create(:sub_type => 2, :pid => params[:organization_id], :subname => params[:org_domain]) + end if OrgMessage.where("message_type='AgreeApplySubdomain' and organization_id=#{@organization.id} and content=?",params[:org_domain]).count == 0 OrgMessage.create(:user_id => params[:user_id], :organization_id => @organization.id, :message_type => 'AgreeApplySubdomain', :message_id => @organization.id, :sender_id => User.current.id, :viewed => 0, :content => params[:org_domain]) end diff --git a/app/views/organizations/_subfield_list.html.erb b/app/views/organizations/_subfield_list.html.erb index b49436d4e..eed0dabf6 100644 --- a/app/views/organizations/_subfield_list.html.erb +++ b/app/views/organizations/_subfield_list.html.erb @@ -28,7 +28,7 @@
  • 新增
  • <%= field.field_type == "Post" ? "帖子" : "资源" %>