组织子域名:所有子域名保存到secdomains表,将组织表中的子域名迁移到secdomains表中,并修改相应的代码
This commit is contained in:
parent
c1a84e2ce5
commit
c91ef44570
|
@ -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 "+
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
<li class="orgListStatus">新增</li>
|
||||
<li class="orgListStatus"><%= field.field_type == "Post" ? "帖子" : "资源" %></li>
|
||||
<li class="orgListUser hidden">
|
||||
<% if @organization.domain %>
|
||||
<% if Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 %>
|
||||
<div id="sub_dir_show_<%= field.id %>" ondblclick="edit_dir('#sub_dir_show_<%= field.id %>','#sub_dir_edit_<%= field.id %>');" style="cursor:pointer;background-color:#fffce6;color: #0d90c3;" title="双击可编辑">
|
||||
<%= field.subfield_subdomain_dir.nil? ? '未设置': field.subfield_subdomain_dir.name %>
|
||||
</div>
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
}
|
||||
|
||||
</script>
|
||||
<% domain = Secdomain.where("sub_type=2 and pid=?", @organization.id).first %>
|
||||
<div class="homepageRightBanner">
|
||||
<div class="NewsBannerName">配置</div>
|
||||
</div>
|
||||
|
@ -53,12 +54,12 @@
|
|||
<div class="orgRow mb10"><span class="ml10">组织描述:</span><textarea type="text" name="organization[description]" class="orgDes" id="org_desc" placeholder="最多3000个汉字(或6000个英文字符)"><%= @organization.description%></textarea>
|
||||
<div class="cl"></div>
|
||||
</div>
|
||||
<div style="margin-left: 80px " id="check_desc_hint"></div>
|
||||
<div style="margin-left: 80px " id="check_desc_hint"></div>
|
||||
<div class="orgRow mb10"><span class="ml10">组织URL:</span>
|
||||
<div class="w607 fr">http://
|
||||
<input type="text" name="organization[domain]" id="domain" value="<%= @organization.domain%>" class="orgUrlInput" />
|
||||
<input type="text" name="organization[domain]" id="domain" value="<%= domain.nil? ? '' : domain.subname %>" class="orgUrlInput" />
|
||||
.trustie.net<a href="javascript:void(0);" class="linkBlue ml15" style="text-decoration:underline;" onclick="apply_subdomain(<%= @organization.id %>,$('#domain').val());">申请</a>
|
||||
<% if @organization.domain.present? and OrgMessage.where("organization_id=? and message_type='ApplySubdomain'", @organization.id).order("updated_at desc").first.content == @organization.domain %>
|
||||
<% if domain.present? and OrgMessage.where("organization_id=? and message_type='ApplySubdomain'", @organization.id).order("updated_at desc").first.content == domain.subname %>
|
||||
<span>(已批准)</span>
|
||||
<% elsif OrgMessage.where("organization_id=? and message_type='ApplySubdomain'", @organization.id).count > 0 %>
|
||||
<span>(您申请了子域名<%= OrgMessage.where("organization_id=? and message_type='ApplySubdomain'", @organization.id).order("updated_at desc").first.content %>,还未批准)</span>
|
||||
|
@ -127,8 +128,8 @@
|
|||
<input type="text" id="subfield_name" name="name" placeholder="栏目名称" class="orgAddSearch mb10" />
|
||||
<div class="mb5">
|
||||
<p class="fontGrey3"><span class="fb">域名目录</span>(用户自定义url,可选)</p>
|
||||
<% if @organization.domain %>
|
||||
<span class="fl"><%= @organization.domain %>.trustie.net/</span><input class="fl personalUrl ml3" type="text" name="sub_dir">
|
||||
<% if domain %>
|
||||
<span class="fl"><%= domain.subname %>.trustie.net/</span><input class="fl personalUrl ml3" type="text" name="sub_dir">
|
||||
<% else %>
|
||||
<span class="fl">您还没有子域名,请先在左侧信息栏申请子域名</span>
|
||||
<% end %>
|
||||
|
|
|
@ -22,12 +22,7 @@
|
|||
</div>
|
||||
<div class="orgWrap">
|
||||
<div class="orgTitle">
|
||||
<% if org.domain.nil? %>
|
||||
<%= link_to org.name, organization_path(org), :class => 'f16 linkBlue' %>
|
||||
<% else %>
|
||||
<%= link_to org.name, organization_path(org), :class => 'f16 linkBlue' %>
|
||||
<!--<a href="http://test.<%#= org.domain %>.trustie.net" class = 'f16 linkBlue'><%#= org.name %></a>-->
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="orgIntro"><%= org.description %></div>
|
||||
<div class="postCreater">创建者:<%= link_to User.find(org.creator_id), user_path(org.creator_id), :class => 'linkGrey2', :target => '_blank' %></div>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddIndexToSecdomain < ActiveRecord::Migration
|
||||
def change
|
||||
add_index(:secdomains, :subname, unique: true)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
class MoveDomainToSecdomain < ActiveRecord::Migration
|
||||
def up
|
||||
Secdomain.transaction do
|
||||
#将组织中的子域名迁移至secdomains表
|
||||
Organization.where("domain is not null").each do |org|
|
||||
Secdomain.create(sub_type: 2, subname: org.domain, pid: org.id)
|
||||
end
|
||||
#remove_column :organizations, :domain
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -0,0 +1,8 @@
|
|||
class RemoveDomainFromOrganizations < ActiveRecord::Migration
|
||||
def up
|
||||
remove_column :organizations, :domain
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20160202034530) do
|
||||
ActiveRecord::Schema.define(:version => 20160223031843) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -1265,7 +1265,6 @@ ActiveRecord::Schema.define(:version => 20160202034530) do
|
|||
t.text "description"
|
||||
t.integer "creator_id"
|
||||
t.integer "home_id"
|
||||
t.string "domain"
|
||||
t.boolean "is_public"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
|
@ -1543,6 +1542,8 @@ ActiveRecord::Schema.define(:version => 20160202034530) do
|
|||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
add_index "secdomains", ["subname"], :name => "index_secdomains_on_subname", :unique => true
|
||||
|
||||
create_table "seems_rateable_cached_ratings", :force => true do |t|
|
||||
t.integer "cacheable_id", :limit => 8
|
||||
t.string "cacheable_type"
|
||||
|
@ -1726,6 +1727,10 @@ ActiveRecord::Schema.define(:version => 20160202034530) do
|
|||
t.string "extra"
|
||||
end
|
||||
|
||||
create_table "temp", :id => false, :force => true do |t|
|
||||
t.integer "id", :default => 0, :null => false
|
||||
end
|
||||
|
||||
create_table "time_entries", :force => true do |t|
|
||||
t.integer "project_id", :null => false
|
||||
t.integer "user_id", :null => false
|
||||
|
|
Loading…
Reference in New Issue