Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop

This commit is contained in:
cxt 2016-02-23 15:22:55 +08:00
commit 070af9ad73
11 changed files with 47 additions and 31 deletions

View File

@ -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 "+

View File

@ -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

View File

@ -46,12 +46,12 @@
<li class="navOrgMenu fr" id="orgUser" style="cursor:pointer;">
<%= link_to image_tag(url_to_avatar(User.current),:width => '23',:height => '23'), request.local? ? user_path(User.current):("https://www.trustie.net/users/" + User.current.id.to_s),:alt => '用户头像', :target => '_blank',:style=>'border-radius:3px; vertical-align:top; margin-top:3px; display:inline-block; margin-right:3px;' %>
<%= link_to User.current, (request.local? || request.subdomain.blank?) ? user_path(User.current):("https://www.trustie.net/users/" + User.current.id.to_s),:id => "orgUserName",:class => 'fontGrey2 f14 mr5',:target => '_blank' %>
<%= link_to "退出",logout_organization_path(@organization), :class =>"menuGrey", :method => 'post', :rel => "nofollow" %>
<%= link_to "退出",(request.local? || request.subdomain.nil?) ? logout_organization_path(@organization):"https://www.trustie.net/logout", :class =>"menuGrey", :method => 'post', :rel => "nofollow" %>
</li>
<!--<li class="navOrgMenu fr"><%#=link_to User.current, user_path(User.current), :class => "linkGrey8 f14" %></li>-->
<% else %>
<li class="navOrgMenu fr"><a href="<%= signin_path(:login=>true) %>" class="linkGrey8 f14">登录</a></li>
<li class="navOrgMenu fr"><a href="<%= signin_path(:login=>false) %>" class="linkGrey8 f14 mr15">注册</a></li>
<li class="navOrgMenu fr"><a href="<%= (request.local? || request.subdomain.nil?) ? signin_path(:login=>true):'https://www.trustie.net/login?login=true' %>" class="linkGrey8 f14">登录</a></li>
<li class="navOrgMenu fr"><a href="<%= (request.local? || request.subdomain.nil?) ? signin_path(:login=>false):'https://www.trustie.net/login?login=false' %>" class="linkGrey8 f14 mr15">注册</a></li>
<% end %>
</ul>
<!--<div class="navHomepageProfile">

View File

@ -1,16 +1,3 @@
<style type="text/css">
/*回复框*/
.ReplyToMessageInputContainer .ke-toolbar{display:none;width:400px;border:none;background:none;padding:0px 0px;}
.ReplyToMessageInputContainer .ke-toolbar-icon{line-height:26px;font-size:14px;padding-left:26px;}
.ReplyToMessageInputContainer .ke-toolbar-icon-url{background-image:url( /images/public_icon.png )}
.ReplyToMessageInputContainer .ke-outline{padding:0px 0px;line-height:26px;font-size:14px;}
.ReplyToMessageInputContainer .ke-icon-emoticons{background-position:0px -671px;width:50px;height:26px;}
.ReplyToMessageInputContainer .ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;}
.ReplyToMessageInputContainer .ke-outline{border:none;}
.ReplyToMessageInputContainer .ke-inline-block{display: none;}
.ReplyToMessageInputContainer .ke-container{float:left;}
</style>
<div class="ReplyToMessageContainer borderBottomNone"id="reply_to_message_<%= reply.id%>">
<div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= reply.id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %></div>
<div class="ReplyToMessageInputContainer mb10">

View File

@ -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>

View File

@ -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 %>

View File

@ -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>

View File

@ -9,7 +9,7 @@ class Subdomain
o = ::Secdomain.where(subname: request.subdomain).first
if(@opt[:sub])
if o && o.sub_type == 2 && request.path_parameters[:sub_dir_name] == 'news'
if o && o.sub_type == 2
request.path_parameters[:id] = o.pid
request.path_parameters[:controller] = 'org_subfields'
request.path_parameters[:action] = 'show'

View File

@ -0,0 +1,5 @@
class AddIndexToSecdomain < ActiveRecord::Migration
def change
add_index(:secdomains, :subname, unique: true)
end
end

View File

@ -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

View File

@ -0,0 +1,8 @@
class RemoveDomainFromOrganizations < ActiveRecord::Migration
def up
remove_column :organizations, :domain
end
def down
end
end