From ceeec3af120ca3c69607dad1acbf857a881c3b44 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 8 Jan 2016 19:33:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=80=E4=BA=9Bbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 2 +- app/views/layouts/base_org.html.erb | 2 +- .../agree_apply_subdomain.js.erb | 2 +- app/views/organizations/setting.html.erb | 2 +- app/views/users/_user_message_org.html.erb | 27 ++++++------------- 5 files changed, 12 insertions(+), 23 deletions(-) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 18eb25675..9f80503d8 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -312,7 +312,7 @@ class OrganizationsController < ApplicationController def agree_apply_subdomain @organization = Organization.find(params[:organization_id]) @organization.update_attribute(:domain, params[:org_domain]) - if OrgMessage.where("message_type='AgreeApplySubdomain' and organization_id=#{@organization.id} and content=#{params[:org_domain]}").count == 0 + 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 end diff --git a/app/views/layouts/base_org.html.erb b/app/views/layouts/base_org.html.erb index 58dee20b8..2007aec5a 100644 --- a/app/views/layouts/base_org.html.erb +++ b/app/views/layouts/base_org.html.erb @@ -163,7 +163,7 @@
diff --git a/app/views/organizations/agree_apply_subdomain.js.erb b/app/views/organizations/agree_apply_subdomain.js.erb index df25d018c..314d48e15 100644 --- a/app/views/organizations/agree_apply_subdomain.js.erb +++ b/app/views/organizations/agree_apply_subdomain.js.erb @@ -1 +1 @@ -$("#agree_apply_subdomain").text("已同意申请"); \ No newline at end of file +$("#agree_apply_subdomain_<%= params[:act_id] %>").text("已同意申请"); \ No newline at end of file diff --git a/app/views/organizations/setting.html.erb b/app/views/organizations/setting.html.erb index bcc0a0c4b..2e9058c40 100644 --- a/app/views/organizations/setting.html.erb +++ b/app/views/organizations/setting.html.erb @@ -140,7 +140,7 @@ $("#add_subfield_form").submit(); } function apply_subdomain(id, domain){ - var reg = new RegExp("[a-zA-Z0-9_]{1,}"); + var reg = new RegExp("^[a-zA-Z0-9_]{1,}$"); if (reg.exec(domain)){ $.ajax({ url:"<%= apply_subdomain_organization_path %>", diff --git a/app/views/users/_user_message_org.html.erb b/app/views/users/_user_message_org.html.erb index b2801a618..5bf1c8950 100644 --- a/app/views/users/_user_message_org.html.erb +++ b/app/views/users/_user_message_org.html.erb @@ -12,24 +12,13 @@ <%= ma.content %>
  • - <% if ma.status == 0 %> - <%=link_to "同意", agree_apply_subdomain_organizations_path( :organization_id => ma.organization_id, :org_domain => ma.content, :user_id => ma.sender_id, :message_id => ma.id ), - :id => 'agree_apply_subdomain', - :method => 'post', - :remote => true, - :class => "green_btn_cir ml10", - :style => "color:#fff" %> - <%=link_to "拒绝", agree_apply_subdomain_organizations_path( :organization_id => ma.organization_id, :org_domain => ma.content, :user_id => ma.sender_id,:message_id => ma.id ), - :id => 'agree_apply_subdomain', - :method => 'post', - :remote => true, - :class => "green_btn_cir ml10", - :style => "color:#fff" %> - <% elsif ma.status == 1 %> - 已同意 - <% elsif ma.status == 2 %> - 已拒绝 - <% end %> + <%=link_to (ma.organization.domain.nil? || (ma.organization.domain && ma.organization.domain != ma.content)) ? "同意申请":"已同意申请", + agree_apply_subdomain_organizations_path( :organization_id => ma.organization_id, :org_domain => ma.content, :user_id => ma.sender_id, :act_id => ma.id ), + :id => "agree_apply_subdomain_#{ma.id}", + :method => 'post', + :remote => true, + :class => "green_btn_cir ml10", + :style => "color:#fff" %>
  • <%= time_tag(ma.created_at).html_safe %>
  • @@ -40,7 +29,7 @@
  • - '>管理员<%= ma.status == 1 ? '同意':'拒绝' %>了您的子域名申请: + '>管理员同意了您的子域名申请:
  • <%= ma.content %>