diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index c98116806..82c827b48 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -616,9 +616,14 @@ class AdminController < ApplicationController
# 未审批tab页
# status: 0 未审批; 1 已批阅; 2已更改; 3拒绝;
def applied_schools
+ # 更新消息状态
+ if params[:flag]
+ applied_message = AppliedMessage.where(:id => params[:applied_message_id]).first
+ applied_message.update_attribute(:viewed, true)
+ end
+
@name = params[:name] || ""
condition = "#{@name.strip}".gsub(" ","")
-
@apply_status = ApplyAddSchools.where("status = 0 and name like '%#{condition}%'").order('created_at desc')
@apply_count = @apply_status.count
@apply_pages = Paginator.new @apply_count, 30, params['page'] || 1
@@ -655,7 +660,7 @@ class AdminController < ApplicationController
applied_school.update_column('status', 1) unless applied_school.nil?
school = applied_school.school
school.update_attribute("province", applied_school.province)
- AppliedMessage.create(:user_id => applied_school.user_id, :status => 1, :viewed => true, :applied_id => applied_school.id, :applied_type => "ApplyAddSchools", :name => applied_school.name )
+ AppliedMessage.create(:user_id => applied_school.user_id, :status => 1, :viewed => 0, :applied_id => applied_school.id, :applied_type => "ApplyAddSchools", :name => applied_school.name )
# School.create(:user_id => applied_school.user_id, :status => 1, :viewed => true, :applied_id => applied_school.id, :applied_type => "ApplyAddSchools", :name => applied_school.name )
respond_to do |format|
format.html{ redirect_to unapplied_schools_url }
@@ -663,8 +668,8 @@ class AdminController < ApplicationController
end
# 单位审核:更改
- # REDO: 修改该字段
- # REDO: 同步修改使用了改名称的用户单位
+ # 修改该字段
+ # 同步修改使用了改名称的用户单位
def edit_applied_schools
aas = ApplyAddSchools.find(params[:applied_id])
# aas.update_attribute(:name, params[:name])
@@ -672,11 +677,9 @@ class AdminController < ApplicationController
school = School.find params[:school_id]
begin
aas.update_attribute(:status, 2)
- AppliedMessage.create(:user_id => aas.user_id, :status => 2, :viewed => true, :applied_id => aas.id, :applied_type => "ApplyAddSchools", :name => school[0].name )
+ AppliedMessage.create(:user_id => aas.user_id, :status => 2, :viewed => 0, :applied_id => aas.id, :applied_type => "ApplyAddSchools", :name => school[0].name )
users = UserExtensions.where("school_id = #{aas.school_id}")
- users.each do |user|
- user.update_column("school_id", school[0].id)
- end
+ users.update_all(:school_id => school[0].id)
if aas.school_id != school[0].id.to_i
aas.school.destroy
end
@@ -709,28 +712,19 @@ class AdminController < ApplicationController
end
# 单位审核:删除
- # REDO: destroy关联删除
- # REDO: 删除确认提示,是否删除
- # REDO: 给申请人发送消息
def delete_applied_schools
applied_school = ApplyAddSchools.find(params[:id])
applied_school.update_attribute(:status, 3)
# 未审批删除
if params[:tip] == "unapplied"
- AppliedMessage.create(:user_id => applied_school.user_id, :status => 3, :viewed => true, :applied_id => applied_school.id, :applied_type => "ApplyAddSchools", :name => applied_school.name )
- # 删除学校的用户
- users = UserExtensions.where("school_id = #{applied_school.school_id}")
- users.each do |user|
- user.update_column("school_id", nil)
- end
+ AppliedMessage.create(:user_id => applied_school.user_id, :status => 3, :viewed => 0, :applied_id => applied_school.id, :applied_type => "ApplyAddSchools", :name => applied_school.name )
+ # 删除学校的用户
+ users = UserExtensions.where("school_id = #{applied_school.school_id}")
+ users.update_all(:school_id => nil)
applied_school.school.destroy
redirect_to unapplied_schools_url
# 已审批删除
elsif params[:tip] == "applied"
- users = UserExtensions.where("school_id = #{applied_school.school_id}")
- users.each do |user|
- user.update_column("school_id", nil)
- end
applied_school.destroy
redirect_to applied_schools_url
end
diff --git a/app/controllers/my_controller.rb b/app/controllers/my_controller.rb
index 32c605516..05b93d302 100644
--- a/app/controllers/my_controller.rb
+++ b/app/controllers/my_controller.rb
@@ -108,6 +108,12 @@ class MyController < ApplicationController
# Edit user's account
def account
+ # 更新消息状态
+ if params[:flag]
+ applied_message = AppliedMessage.where(:id => params[:applied_message_id]).first
+ applied_message.update_attribute(:viewed, true)
+ end
+
@user = User.current
lg=@user.login
diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb
index 98d814137..b6e34a185 100644
--- a/app/controllers/school_controller.rb
+++ b/app/controllers/school_controller.rb
@@ -188,11 +188,12 @@ class SchoolController < ApplicationController
user_extention.school_id = school.id
user_extention.save!
- # status=4 向管理员发送信息
+ # 向管理员发送信息
users = User.where(:admin => 1)
users.each do |user|
- AppliedMessage.create(:user_id => user.id, :status => 0, :applied_user_id => User.current.id, :viewed => true, :applied_id => school.id, :applied_type => "ApplyAddSchools", :name => school.name )
+ AppliedMessage.create(:user_id => user.id, :status => 0, :applied_user_id => User.current.id, :viewed => 0, :applied_id => school.id, :applied_type => "ApplyAddSchools", :name => school.name )
end
+
else
data[:result] = 3
end
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index a07070989..398fb8510 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -105,6 +105,22 @@ module UsersHelper
end
end
+ # 单位申请消息:通过用户的状态判断
+ # status(0:申请消息;1,2,3:系统消息)
+ def applied_school_users applied_message
+ user = User.find(applied_message.applied_user_id)
+ end
+
+ # 单位申请消息通过状态判断tip描述
+ def applied_school_tip applied_message
+ case applied_message.status
+ when 1,2,3
+ "您添加新的单位:"
+ when 0
+ "申请了单位:"
+ end
+ end
+
def applied_project_tip_header applied_message
case applied_message.status
when 4
@@ -117,6 +133,7 @@ module UsersHelper
end
+
def get_resource_origin attach
type = attach.container_type
content = attach.container
diff --git a/app/views/admin/_update_school_form.html.erb b/app/views/admin/_update_school_form.html.erb
index f006dcdc0..8bcdbe97d 100644
--- a/app/views/admin/_update_school_form.html.erb
+++ b/app/views/admin/_update_school_form.html.erb
@@ -2,7 +2,7 @@
<%#= hidden_field_tag(:send_id, edit_id) %>
- <% if !schools.empty? %>
+ <% if !schools.empty? && !@search.nil? %>
<% schools.each do |school| %>
-
diff --git a/app/views/admin/all_schools.js.erb b/app/views/admin/all_schools.js.erb
index 7a53a25dc..cbaf14ab9 100644
--- a/app/views/admin/all_schools.js.erb
+++ b/app/views/admin/all_schools.js.erb
@@ -1,11 +1,11 @@
<% if params[:search].nil? %>
-$("#ajax-modal").html('<%= escape_javascript( render :partial => 'admin/all_schools', :locals => {:schools => @schools, :edit_id => @edit_id}) %>');
-showModal('ajax-modal', '452px');
-$('#ajax-modal').siblings().remove();
-$('#ajax-modal').before("");
-$('#ajax-modal').parent().css("top","50%").css("left","50%");
-$('#ajax-modal').parent().addClass("popbox").addClass("resourceUploadPopup");
-$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");
+ $("#ajax-modal").html('<%= escape_javascript( render :partial => 'admin/all_schools', :locals => {:schools => @schools, :edit_id => @edit_id}) %>');
+ showModal('ajax-modal', '452px');
+ $('#ajax-modal').siblings().remove();
+ $('#ajax-modal').before("");
+ $('#ajax-modal').parent().css("top","50%").css("left","50%");
+ $('#ajax-modal').parent().addClass("popbox").addClass("resourceUploadPopup");
+ $('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");
<% else %>
-$("#schools_list").html("<%= escape_javascript(render :partial => 'admin/update_school_form', :locals => {:schools => @schools, :edit_id => @edit_id}) %>");
+ $("#schools_list").html("<%= escape_javascript(render :partial => 'admin/update_school_form', :locals => {:schools => @schools, :edit_id => @edit_id}) %>");
<% end %>
\ No newline at end of file
diff --git a/app/views/admin/applied_schools.html.erb b/app/views/admin/applied_schools.html.erb
index 19700c2c6..a2cc56362 100644
--- a/app/views/admin/applied_schools.html.erb
+++ b/app/views/admin/applied_schools.html.erb
@@ -11,7 +11,7 @@
<%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '输入单位名称进行搜索' %>
<%= submit_tag l(:button_apply ), :class => "small", :name => nil %>
- <%= link_to l(:button_clear), {:controller => 'admin', :action => 'applied_shcools'}, :class => 'icon icon-reload' %>
+ <%= link_to l(:button_clear), {:controller => 'admin', :action => 'applied_schools'}, :class => 'icon icon-reload' %>
<% end %>
@@ -60,7 +60,7 @@
<% user = User.where("id=?", apply.user_id).first %>
<% unless user.nil? %>
- <%=link_to user.show_name, user_path(user),:target => '_blank' %>
+ <%=link_to user.show_name, user_path(user),:target => '_blank', :class => "application-default-link" %>
<% end %>
|
@@ -132,7 +132,7 @@
|
|
-
+ |
<%= apply.remarks %>
|
diff --git a/app/views/admin/has_applied_schools.html.erb b/app/views/admin/has_applied_schools.html.erb
index 535e2fe3f..f544ec8a0 100644
--- a/app/views/admin/has_applied_schools.html.erb
+++ b/app/views/admin/has_applied_schools.html.erb
@@ -11,7 +11,7 @@
<%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '输入单位名称进行搜索' %>
<%= submit_tag l(:button_apply ), :class => "small", :name => nil %>
- <%= link_to l(:button_clear), {:controller => 'admin', :action => 'applied_shcools'}, :class => 'icon icon-reload' %>
+ <%= link_to l(:button_clear), {:controller => 'admin', :action => 'has_applied_schools'}, :class => 'icon icon-reload' %>
<% end %>
@@ -20,7 +20,7 @@
-
+ |
序号
|
diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb
index b7e2989eb..753022d75 100644
--- a/app/views/layouts/_logined_header.html.erb
+++ b/app/views/layouts/_logined_header.html.erb
@@ -73,9 +73,9 @@
- <%= link_to "", user_message_path(User.current), :class => "homepageNewsIcon", :target =>"_Blank", :title => "您的所有消息" %>
- <% if User.current.count_new_message.to_i >0 %>
- <%= link_to User.current.count_new_message , user_message_path(User.current), :class => "newsActive", :target =>"_Blank" %>
+ <%= link_to "", user_message_path(User.current), :class => "homepageNewsIcon", :target => "_Blank", :title => "您的所有消息" %>
+ <% if User.current.count_new_message.to_i > 0 %>
+ <%= link_to User.current.count_new_message , user_message_path(User.current), :class => "newsActive", :target => "_Blank" %>
<% end %>
<%#= link_to User.current.count_new_message, user_message_path(User.current), :class => "homepageNewsIcon" %>
diff --git a/app/views/layouts/_show_messages_list.html.erb b/app/views/layouts/_show_messages_list.html.erb
index c652c7936..671738f52 100644
--- a/app/views/layouts/_show_messages_list.html.erb
+++ b/app/views/layouts/_show_messages_list.html.erb
@@ -142,6 +142,28 @@
<% content = ' '+ma.author.show_name+' 提到了你:'+ma.subject.html_safe %>
- <%=link_to content.html_safe, ma.url, :title => ma.author.show_name+' 提到了你:'+ma.subject.html_safe, :target => '_blank' %>
<% end %>
+ <% elsif ma.class == AppliedMessage %>
+ <% if ma.applied_type == "ApplyAddSchools" && ma.status == 0 %>
+ -
+ <% content = ''+User.where("id=?", ma.applied_user_id).first.show_name+' 提交了申请:添加新的单位:'+"“"+ma.name+"”" %>
+ <%= link_to content.html_safe, unapplied_schools_path(:flag => 1, :applied_message_id => ma.id), :title => "#{User.where("id=?", ma.applied_user_id).first.show_name}提交了申请:添加新的单位“#{ma.name}”", :target => '_blank' %>
+
+ <% elsif ma.applied_type == "ApplyAddSchools" && ma.status == 1 %>
+ -
+ <% content = "系统提示:“#{ma.name}”的申请,已通过审核。谢谢!" %>
+ <%= link_to content.html_safe, { :controller=> "my",:action => "account",:flag => 1, :applied_message_id => ma.id }, :title => "系统提示:“#{ma.name}”的申请,已通过审核。谢谢!", :target => '_blank'%>
+
+ <% elsif ma.applied_type == "ApplyAddSchools" && ma.status == 2 %>
+ -
+ <% content = "系统提示:“#{ma.applied.name}”的申请,因名称不符合规范,系统已将其更改为“#{ma.name}”。谢谢!" %>
+ <%= link_to content.html_safe, { :controller=> "my",:action => "account", :flag => 1, :applied_message_id => ma.id }, :title => "系统提示:“#{ma.applied.name}”的申请,因名称不符合规范,系统已将其更改为“#{ma.name}”。谢谢!", :target => '_blank'%>
+
+ <% elsif ma.applied_type == "ApplyAddSchools" && ma.status == 3 %>
+ -
+ <% content = "系统提示:“#{ma.name}”的申请,经确认为无效的单位信息,已被删除,请重新编辑您的单位资料。谢谢!" %>
+ <%= link_to content.html_safe, { :controller=> "my",:action => "account", :flag => 1, :applied_message_id => ma.id }, :title => "系统提示:“#{ma.name}”的申请,经确认为无效的单位信息,已被删除,请重新编辑您的单位资料。谢谢!", :target => '_blank'%>
+
+ <% end %>
<% end %>
<% end %>
diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb
index 46e8e015a..5c8e13e3f 100644
--- a/app/views/my/account.html.erb
+++ b/app/views/my/account.html.erb
@@ -80,7 +80,7 @@
-
+
平台找到了0个包含"国防"的高校
@@ -88,7 +88,7 @@
-
+
平台找到了0个包含"国防"的高校
@@ -96,7 +96,7 @@
-
+
平台找到了0个包含"国防"的高校
@@ -104,7 +104,7 @@
-
+
平台找到了0个包含"国防"的高校
@@ -466,7 +466,7 @@
}else{
$("#search_school_result_list").html('');
str = e.target.value.length > 4 ? e.target.value.substr(0, 4)+"..." : e.target.value;
- $("#hint").html('您输入的名称尚不存在, 申请添加');
+ $("#hint").html('如果找不到自己的单位,您可以 添加单位');
$("#hint").show();
$("#errortip").show();
}
diff --git a/app/views/users/_user_message_applied.html.erb b/app/views/users/_user_message_applied.html.erb
index 6d853f01c..414b13cf7 100644
--- a/app/views/users/_user_message_applied.html.erb
+++ b/app/views/users/_user_message_applied.html.erb
@@ -1,51 +1,24 @@
<% if ma.class == AppliedMessage %>
<% if ma.applied_type == "ApplyAddSchools" %>
- <% if ma.status == 1 || ma.status == 2 || ma.status == 3 || ma.status == 0 %>
-
- <% if ma.status == 1 || ma.status == 2 || ma.status == 3 %>
- <%= image_tag("/images/trustie_logo1.png", width: "30px", height: "30px", class: "mt3") %>
- <% elsif ma.status == 0 %>
- <%= link_to image_tag(url_to_avatar(ma.user), :width => "30", :height => "30"), user_path(ma.user), :target => '_blank' %>
+ <% if ma.status == 0 %>
+ <%= link_to image_tag(url_to_avatar(ma.user), :width => "30", :height => "30"), user_path(ma.user), :target => '_blank' %>
+ <% else %>
+ <%= image_tag("/images/trustie_logo1.png", width: "30px", height: "30px", class: "mt3") %>
<% end %>
-
- <% if ma.status == 1 %>
- 系统提示
- ">您添加新的高校(单位):
-
-
- “<%= ma.name %>”的申请,已通过
-
- - <%= time_tag(ma.created_at).html_safe %>
- <% elsif ma.status == 2 %>
- 系统提示
- ">您添加新的高校(单位):
- -
- “<%= ma.applied.name %>”的申请,因名称不合法,系统已将其更改为“<%= ma.name %>”
-
- - <%= time_tag(ma.created_at).html_safe %>
- <% elsif ma.status == 3 %>
- 系统提示
- ">您添加新的高校(单位):
- -
- <%= link_to "“"+ma.name+"”" + "的申请,因名称不合法,已被拒绝,请重新编辑您的基本资料", { :controller=> "my",:action => "account" }, :title => "“#{ma.name}”的申请,因名称不合法,已被拒绝,请重新编辑您的基本资料", :target => '_blank'%>
-
- - <%= time_tag(ma.created_at).html_safe %>
- <% elsif ma.status == 0 %>
- <%=link_to User.where("id=?", ma.applied_user_id).first.show_name, user_path(ma.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
- "> 申请了单位:
- -
-
- <%= link_to User.where("id=?", ma.applied_user_id).first.show_name + "提交了申请:添加新的单位“#{ma.name}”", unapplied_schools_path(), :title => "#{User.where("id=?", ma.applied_user_id).first.show_name}提交了申请:添加新的单位“#{ma.name}”" %>
-
- - <%= time_tag(ma.created_at).html_safe %>
- <% end %>
+ <%= render :partial => "users/user_message_applied_schools", :locals =>{:ma => ma} %>
+ -
+ <%= render :partial => "users/user_message_applied_school_action", :locals =>{:ma => ma} %>
+
+ - <%= time_tag(ma.created_at).html_safe %>
- <% end %>
<% elsif ma && ma.applied_type == "AppliedProject" %>
<%= render :partial => "users/applied_project_content", :locals =>{:ma => ma} %>
diff --git a/app/views/users/_user_message_applied_school_action.html.erb b/app/views/users/_user_message_applied_school_action.html.erb
new file mode 100644
index 000000000..b4b0cdb6d
--- /dev/null
+++ b/app/views/users/_user_message_applied_school_action.html.erb
@@ -0,0 +1,15 @@
+<% if ma.status == 1 %>
+
+ “<%= ma.name %>”的申请,已通过审核。谢谢!
+
+<% elsif ma.status == 2 %>
+
+ “<%= ma.applied.name %>”的申请,因名称不符合规范,系统已将其更改为“<%= ma.name %>”。谢谢!
+
+<% elsif ma.status == 3 %>
+ <%= link_to "“"+ma.name+"”" + "的申请,经确认为无效的单位信息,已被删除,请重新编辑您的单位资料。谢谢!", { :controller=> "my",:action => "account" }, :title => "“#{ma.name}”的申请,经确认为无效的单位信息,已被删除,请重新编辑您的单位资料。谢谢!", :target => '_blank'%>
+<% elsif ma.status == 0 %>
+
+ <%= link_to User.where("id=?", ma.applied_user_id).first.show_name + "提交了申请:添加新的单位“#{ma.name}”", unapplied_schools_path(), :title => "#{User.where("id=?", ma.applied_user_id).first.show_name}提交了申请:添加新的单位“#{ma.name}”" %>
+
+<% end %>
\ No newline at end of file
diff --git a/app/views/users/_user_message_applied_schools.html.erb b/app/views/users/_user_message_applied_schools.html.erb
new file mode 100644
index 000000000..9de70a03a
--- /dev/null
+++ b/app/views/users/_user_message_applied_schools.html.erb
@@ -0,0 +1,7 @@
+
+<% if ma.status != 0 %>
+ 系统提示
+<% else %>
+ <%=link_to User.where("id=?", ma.applied_user_id).first.show_name, user_path(ma.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
+<% end %>
+"><%= applied_school_tip(ma) %>
\ No newline at end of file
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 798c4c480..20040f559 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -1965,6 +1965,7 @@ function edit_school_name(url,id){
url,
{id: id ,name: $("#school_name_edit_"+id).val() },
function (data) {
+ $("#school_name_edit_"+id).val("");
if(data.status == 0){
$("#apply_title_"+data.id).show();
$("#school_name_edit_"+data.id).hide();
@@ -1998,6 +1999,7 @@ function edit_school_address(url,id){
url,
{id: id ,address: $("#school_address_edit_"+id).val() },
function (data) {
+ $("#school_address_edit_"+data.id).val("");
if(data.status == 0){
$("#apply_address_"+data.id).show();
$("#school_address_edit_"+data.id).hide();
|