This commit is contained in:
sw 2015-09-02 21:30:59 +08:00
commit 359e34471b
10 changed files with 294 additions and 293 deletions

View File

@ -31,7 +31,7 @@
<div>
<% if params[:type].nil? %>
<div class="newsReadSetting">
有&nbsp;<span class="c_red"><%= User.current.count_new_message %></span>&nbsp;未读<a href="javascript:void(0);" class="ml15"><%= link_to "全部设为已读", user_message_path(User.current, :viewed => 'all') %></a>
有&nbsp;<span class="c_red"><%= User.current.count_new_message %></span>&nbsp;未读<a href="javascript:void(0);" class="ml15"><%= link_to "全部设为已读", user_message_path(User.current, :viewed => 'all') %></a>
</div>
<% end %>
<% if @message_alls.count >0 %>
@ -59,7 +59,7 @@
:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:onmouseover =>"message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %></li>
<div style="display: none" >
<div style="display: none" class="message_title">
<%= ma.course_message.comments.html_safe %>
</div>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
@ -100,7 +100,7 @@
:class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
:onmouseover =>"message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %></a></li>
<div style="display: none" >
<div style="display: none" class="message_title" >
<%= ma.course_message.content.html_safe %>
</div>
<% end %>
@ -182,7 +182,7 @@
:topic_id => ma.forge_message.id),:class=>"#{ma.viewed==0?"newsBlack":"newsGrey"}",
:onmouseover =>"message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %></a></li>
<div style="display: none" >
<div style="display: none" class="message_title">
<%= ma.forge_message.content.html_safe %>
</div>
<% end %>
@ -240,7 +240,7 @@
:onmouseover =>"message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %></a>
</li>
<div style="display: none" >
<div style="display: none" class="message_title">
<%= ma.memo.content.html_safe %>
</div>
<% end %>
@ -264,7 +264,7 @@
:onmouseover =>"message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %></a>
</li>
<div style="display: none" >
<div style="display: none" class="message_title" >
<%= ma.journals_for_message.notes.html_safe %>
</div>
<li class="homepageNewsTime fl"><%= time_tag(ma.journals_for_message.created_on).html_safe %> </li>
@ -290,7 +290,7 @@
function message_titile_show(obj,e)
{
obj.parent().next("div").show();
obj.parent().next("div").css("top",e.pageY).css("left",e.pageX).css("position","fixed");
obj.parent().next("div").css("top",e.pageY).css("left",e.pageX).css("position","absolute");
}
function message_titile_hide(obj)
{

View File

@ -1,78 +1,78 @@
# encoding: UTF-8
class ForgeMessages < ActiveRecord::Migration
def up
Project.all.each do |project|
transaction do
project.forge_messages << ForgeMessage.new(:user_id => project.user_id, :project_id => project.id)
# 新闻
project.news.each do |new|
new.project.members.each do |m|
if m.user_id != new.author_id
if m.created_on < new.created_on # 在成员加入项目之后
new.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => new.project_id, :viewed => true)
end
end
end
end
# 新闻回复
project.news.each do |new|
if new.comments
new.comments.each do |comment|
if comment.author_id != comment.commented.author_id
comment.forge_messages << ForgeMessage.new(:user_id => comment.commented.author_id, :project_id => comment.commented.project.id, :viewed => true)
end
end
end
end
# 讨论区
if project.boards.first
project.boards.first.messages.each do |message|
if message.parent_id.nil? # 主贴
message.project.members.each do |m|
if m.user_id != message.author_id
if m.created_on < message.created_on
message.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => message.board.project_id, :viewed => true)
end
end
end
else # 回帖
message.project.members.each do |m|
if m.user_id == Message.find(message.parent_id).author_id && m.user_id != message.author_id # 只针对主贴回复,回复自己的帖子不发消息
if m.created_on < message.created_on
message.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => message.board.project_id, :viewed => true)
end
end
end
end
end
end
# 缺陷
project.issues.each do |issue|
unless issue.author_id == issue.assigned_to_id
issue.forge_messages << ForgeMessage.new(:user_id => issue.assigned_to_id, :project_id => issue.project_id, :viewed => true)
end
end
# 缺陷更新
project.issues.each do |issue|
if issue.journals
issue.journals.each do |journal|
if journal.user_id != journal.issue.author_id
journal.forge_messages << ForgeMessage.new(:user_id => journal.issue.author_id, :project_id => journal.issue.project_id, :viewed => true)
end
if journal.user_id != journal.issue.assigned_to_id && journal.issue.assigned_to_id != journal.issue.author_id # 指派人不是自己的话,则给指派人发送
journal.forge_messages << ForgeMessage.new(:user_id => journal.issue.assigned_to_id, :project_id => journal.issue.project_id, :viewed => true)
end
end
end
end
end
end
# Project.all.each do |project|
# transaction do
# project.forge_messages << ForgeMessage.new(:user_id => project.user_id, :project_id => project.id)
#
# # 新闻
# project.news.each do |new|
# new.project.members.each do |m|
# if m.user_id != new.author_id
# if m.created_on < new.created_on # 在成员加入项目之后
# new.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => new.project_id, :viewed => true)
# end
# end
# end
# end
#
# # 新闻回复
# project.news.each do |new|
# if new.comments
# new.comments.each do |comment|
# if comment.author_id != comment.commented.author_id
# comment.forge_messages << ForgeMessage.new(:user_id => comment.commented.author_id, :project_id => comment.commented.project.id, :viewed => true)
# end
# end
# end
# end
#
# # 讨论区
# if project.boards.first
# project.boards.first.messages.each do |message|
# if message.parent_id.nil? # 主贴
# message.project.members.each do |m|
# if m.user_id != message.author_id
# if m.created_on < message.created_on
# message.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => message.board.project_id, :viewed => true)
# end
# end
# end
# else # 回帖
# message.project.members.each do |m|
# if m.user_id == Message.find(message.parent_id).author_id && m.user_id != message.author_id # 只针对主贴回复,回复自己的帖子不发消息
# if m.created_on < message.created_on
# message.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => message.board.project_id, :viewed => true)
# end
# end
# end
# end
# end
# end
#
# # 缺陷
# project.issues.each do |issue|
# unless issue.author_id == issue.assigned_to_id
# issue.forge_messages << ForgeMessage.new(:user_id => issue.assigned_to_id, :project_id => issue.project_id, :viewed => true)
# end
# end
#
# # 缺陷更新
# project.issues.each do |issue|
# if issue.journals
# issue.journals.each do |journal|
# if journal.user_id != journal.issue.author_id
# journal.forge_messages << ForgeMessage.new(:user_id => journal.issue.author_id, :project_id => journal.issue.project_id, :viewed => true)
# end
# if journal.user_id != journal.issue.assigned_to_id && journal.issue.assigned_to_id != journal.issue.author_id # 指派人不是自己的话,则给指派人发送
# journal.forge_messages << ForgeMessage.new(:user_id => journal.issue.assigned_to_id, :project_id => journal.issue.project_id, :viewed => true)
# end
# end
# end
# end
#
# end
# end
end
def down

View File

@ -1,80 +1,80 @@
# encoding: UTF-8
class CourseMessages < ActiveRecord::Migration
def up
Course.all.each do |course|
transaction do
put course.id
course.course_messages << CourseMessage.new(:user_id => course.tea_id,:course_id => course.id)
# 作业
course.homework_commons.each do |homework_common|
homework_common.course.members.each do |m|
if m.user_id != homework_common.user_id
if m.created_on < homework_common.created_at
homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true)
end
end
end
end
# 通知
course.news.each do |new|
new.course.members.each do |m|
if m.user_id != new.author_id
if m.created_on < new.created_on # 在成员加入课程之后
new.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true)
end
end
end
end
# 通知的回复
course.news.each do |new|
if new.comments
new.comments.each do |comment|
if comment.author_id != comment.commented.author_id
comment.course_messages << CourseMessage.new(:user_id => comment.commented.author_id, :course_id => course.id, :viewed => true)
end
end
end
end
# 讨论区
if course.boards.first
course.boards.first.messages.each do |message|
if message.parent_id.nil? # 主贴
message.course.members.each do |m|
if message.author.allowed_to?(:as_teacher, message.course) && m.user_id != message.author_id # 老师 自己的帖子不给自己发送消息
if m.created_on < message.created_on
message.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true)
end
end
end
else # 回帖
message.course.members.each do |m|
if m.user_id == Message.find(message.parent_id).author_id && m.user_id != message.author_id # 只针对主贴回复,回复自己的帖子不发消息
if m.created_on < message.created_on
message.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true)
end
end
end
end
end
end
# 问卷
Poll.where("polls_type = 'Course' and polls_group_id = #{course.id}").each do |poll|
if poll.polls_status == 2 #问卷是发布状态
Course.find(poll.polls_group_id).members.each do |m|
if m.user_id != poll.user_id
if m.created_on < poll.created_at
poll.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true)
end
end
end
elsif poll.polls_status == 1 #问卷是新建状态
poll.course_messages.destroy_all
end
end
# Course.all.each do |course|
# transaction do
# put course.id
# course.course_messages << CourseMessage.new(:user_id => course.tea_id,:course_id => course.id)
# # 作业
# course.homework_commons.each do |homework_common|
# homework_common.course.members.each do |m|
# if m.user_id != homework_common.user_id
# if m.created_on < homework_common.created_at
# homework_common.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true)
# end
# end
# end
# end
#
# # 通知
# course.news.each do |new|
# new.course.members.each do |m|
# if m.user_id != new.author_id
# if m.created_on < new.created_on # 在成员加入课程之后
# new.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true)
# end
# end
# end
# end
#
# # 通知的回复
# course.news.each do |new|
# if new.comments
# new.comments.each do |comment|
# if comment.author_id != comment.commented.author_id
# comment.course_messages << CourseMessage.new(:user_id => comment.commented.author_id, :course_id => course.id, :viewed => true)
# end
# end
# end
# end
#
# # 讨论区
# if course.boards.first
# course.boards.first.messages.each do |message|
# if message.parent_id.nil? # 主贴
# message.course.members.each do |m|
# if message.author.allowed_to?(:as_teacher, message.course) && m.user_id != message.author_id # 老师 自己的帖子不给自己发送消息
# if m.created_on < message.created_on
# message.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true)
# end
# end
# end
# else # 回帖
# message.course.members.each do |m|
# if m.user_id == Message.find(message.parent_id).author_id && m.user_id != message.author_id # 只针对主贴回复,回复自己的帖子不发消息
# if m.created_on < message.created_on
# message.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true)
# end
# end
# end
# end
# end
# end
#
# # 问卷
# Poll.where("polls_type = 'Course' and polls_group_id = #{course.id}").each do |poll|
# if poll.polls_status == 2 #问卷是发布状态
# Course.find(poll.polls_group_id).members.each do |m|
# if m.user_id != poll.user_id
# if m.created_on < poll.created_at
# poll.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => course.id, :viewed => true)
# end
# end
# end
# elsif poll.polls_status == 1 #问卷是新建状态
# poll.course_messages.destroy_all
# end
# end
# 作品评阅
# course.homework_commons.each do |homework_common|
@ -107,8 +107,8 @@ class CourseMessages < ActiveRecord::Migration
# end
# 作品讨论
end
end
# end
# end
end
def down

View File

@ -1,25 +1,25 @@
class UpdateMessageTime < ActiveRecord::Migration
def up
course_count = CourseMessage.all.count / 30 + 1
transaction do
for i in 1 ... course_count do i
CourseMessage.page(i).per(30).each do |cmessage|
if cmessage.course_message
if cmessage.course_message.respond_to?("created_at")
cmessage.created_at = cmessage.course_message.created_at
elsif cmessage.course_message.respond_to?("created_on")
cmessage.created_at = cmessage.course_message.created_on
end
cmessage.save
puts cmessage.id
course_all_message = MessageAll.where("message_type = '#{cmessage.class.to_s}' and message_id = '#{cmessage.id}'").first
course_all_message.created_at = cmessage.created_at
course_all_message.save
end
end
end
end
# course_count = CourseMessage.all.count / 30 + 1
# transaction do
# for i in 1 ... course_count do i
# CourseMessage.page(i).per(30).each do |cmessage|
# if cmessage.course_message
# if cmessage.course_message.respond_to?("created_at")
# cmessage.created_at = cmessage.course_message.created_at
# elsif cmessage.course_message.respond_to?("created_on")
# cmessage.created_at = cmessage.course_message.created_on
# end
# cmessage.save
# puts cmessage.id
#
# course_all_message = MessageAll.where("message_type = '#{cmessage.class.to_s}' and message_id = '#{cmessage.id}'").first
# course_all_message.created_at = cmessage.created_at
# course_all_message.save
# end
# end
# end
# end
end
def down

View File

@ -1,25 +1,25 @@
class UpdateForgeMessageTime < ActiveRecord::Migration
def up
forge_count = ForgeMessage.all.count / 30 + 1
transaction do
for i in 1 ... forge_count do i
ForgeMessage.page(i).per(30).each do |fmessage|
if fmessage.forge_message
if fmessage.forge_message.respond_to?("created_at")
fmessage.created_at = fmessage.forge_message.created_at
elsif fmessage.forge_message.respond_to?("created_on")
fmessage.created_at = fmessage.forge_message.created_on
end
fmessage.save
puts fmessage.id
forge_all_message = MessageAll.where("message_type = '#{fmessage.class.to_s}' and message_id = '#{fmessage.id}'").first
forge_all_message.created_at = fmessage.created_at
forge_all_message.save
end
end
end
end
# forge_count = ForgeMessage.all.count / 30 + 1
# transaction do
# for i in 1 ... forge_count do i
# ForgeMessage.page(i).per(30).each do |fmessage|
# if fmessage.forge_message
# if fmessage.forge_message.respond_to?("created_at")
# fmessage.created_at = fmessage.forge_message.created_at
# elsif fmessage.forge_message.respond_to?("created_on")
# fmessage.created_at = fmessage.forge_message.created_on
# end
# fmessage.save
# puts fmessage.id
#
# forge_all_message = MessageAll.where("message_type = '#{fmessage.class.to_s}' and message_id = '#{fmessage.id}'").first
# forge_all_message.created_at = fmessage.created_at
# forge_all_message.save
# end
# end
# end
# end
end
def down

View File

@ -1,34 +1,34 @@
class AboutMemoMessage < ActiveRecord::Migration
def up
Memo.all.each do |memo|
transaction do
# 贴吧帖子
receivers = []
u = User.find(6)
receivers << u
# 主贴
if memo.parent_id.nil?
if memo.author_id != memo.forum.creator_id # 发帖人不是吧主
receivers << memo.forum.creator
end
else # 回帖
# 添加吧主
if memo.author_id != memo.forum.creator_id
receivers << memo.forum.creator
end
# 添加发帖人
unless memo.parent.nil?
if memo.author_id != memo.parent.author_id
receivers << memo.parent.author
puts memo.id
end
end
end
receivers.each do |r|
memo.memo_messages << MemoMessage.new(:user_id => r.id, :forum_id => memo.forum_id, :memo_id => memo.id, :memo_type => "Memo", :viewed => true)
end
end
end
# Memo.all.each do |memo|
# transaction do
# # 贴吧帖子
# receivers = []
# u = User.find(6)
# receivers << u
# # 主贴
# if memo.parent_id.nil?
# if memo.author_id != memo.forum.creator_id # 发帖人不是吧主
# receivers << memo.forum.creator
# end
# else # 回帖
# # 添加吧主
# if memo.author_id != memo.forum.creator_id
# receivers << memo.forum.creator
# end
# # 添加发帖人
# unless memo.parent.nil?
# if memo.author_id != memo.parent.author_id
# receivers << memo.parent.author
# puts memo.id
# end
# end
# end
# receivers.each do |r|
# memo.memo_messages << MemoMessage.new(:user_id => r.id, :forum_id => memo.forum_id, :memo_id => memo.id, :memo_type => "Memo", :viewed => true)
# end
# end
# end
end
def down

View File

@ -1,34 +1,34 @@
class AboutUserFeedbackMessage < ActiveRecord::Migration
def up
JournalsForMessage.all.each do |jour_for_message|
transaction do
# 主留言
if jour_for_message.jour_type == 'Principal'
receivers = []
if jour_for_message.reply_id == 0
if jour_for_message.user_id != jour_for_message.jour_id # 过滤自己给自己的留言消息
receivers << jour_for_message.jour
end
else # 留言回复
reply_to = User.find(jour_for_message.reply_id)
if jour_for_message.user_id != jour_for_message.reply_id # 添加我回复的那个人
receivers << reply_to
end
unless jour_for_message.parent.nil?
if jour_for_message.user_id != jour_for_message.parent.jour_id && jour_for_message.reply_id != jour_for_message.parent.jour_id # 给东家发信息,如果回复的对象是东家则不发
receivers << jour_for_message.parent.jour
end
end
end
unless receivers.blank?
receivers.each do |r|
puts jour_for_message.id
jour_for_message.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => jour_for_message.id, :journals_for_message_type => "Principal", :viewed => true)
end
end
end
end
end
# JournalsForMessage.all.each do |jour_for_message|
# transaction do
# # 主留言
# if jour_for_message.jour_type == 'Principal'
# receivers = []
# if jour_for_message.reply_id == 0
# if jour_for_message.user_id != jour_for_message.jour_id # 过滤自己给自己的留言消息
# receivers << jour_for_message.jour
# end
# else # 留言回复
# reply_to = User.find(jour_for_message.reply_id)
# if jour_for_message.user_id != jour_for_message.reply_id # 添加我回复的那个人
# receivers << reply_to
# end
# unless jour_for_message.parent.nil?
# if jour_for_message.user_id != jour_for_message.parent.jour_id && jour_for_message.reply_id != jour_for_message.parent.jour_id # 给东家发信息,如果回复的对象是东家则不发
# receivers << jour_for_message.parent.jour
# end
# end
# end
# unless receivers.blank?
# receivers.each do |r|
# puts jour_for_message.id
# jour_for_message.user_feedback_messages << UserFeedbackMessage.new(:user_id => r.id, :journals_for_message_id => jour_for_message.id, :journals_for_message_type => "Principal", :viewed => true)
# end
# end
# end
# end
# end
end
def down

View File

@ -1,25 +1,25 @@
class UpdateMemoMessageTime < ActiveRecord::Migration
def up
memo_count = Memo.all.count / 30 + 1
transaction do
for i in 1 ... memo_count do i
MemoMessage.page(i).per(30).each do |memo_message|
if memo_message.memo
if memo_message.memo.respond_to?("created_at")
memo_message.created_at = memo_message.memo.created_at
elsif memo_message.memo.respond_to?("created_on")
memo_message.created_at = memo_message.memo.created_on
end
memo_message.save
puts memo_message.id
memo_messages = MessageAll.where("message_type = '#{memo_message.class.to_s}' and message_id = '#{memo_message.id}'").first
memo_messages.created_at = memo_message.created_at
memo_messages.save
end
end
end
end
# memo_count = Memo.all.count / 30 + 1
# transaction do
# for i in 1 ... memo_count do i
# MemoMessage.page(i).per(30).each do |memo_message|
# if memo_message.memo
# if memo_message.memo.respond_to?("created_at")
# memo_message.created_at = memo_message.memo.created_at
# elsif memo_message.memo.respond_to?("created_on")
# memo_message.created_at = memo_message.memo.created_on
# end
# memo_message.save
# puts memo_message.id
#
# memo_messages = MessageAll.where("message_type = '#{memo_message.class.to_s}' and message_id = '#{memo_message.id}'").first
# memo_messages.created_at = memo_message.created_at
# memo_messages.save
# end
# end
# end
# end
end
def down

View File

@ -1,25 +1,25 @@
class UpdateUserfeebackMessageTime < ActiveRecord::Migration
def up
user_feedback_count = UserFeedbackMessage.all.count / 30 + 1
transaction do
for i in 1 ... user_feedback_count do i
UserFeedbackMessage.page(i).per(30).each do |ufm|
if ufm.journals_for_message
if ufm.journals_for_message.respond_to?("created_at")
ufm.created_at = ufm.journals_for_message.created_at
elsif ufm.journals_for_message.respond_to?("created_on")
ufm.created_at = ufm.journals_for_message.created_on
end
puts ufm.id
ufm.save
user_feedback_messages = MessageAll.where("message_type = '#{ufm.class.to_s}' and message_id = '#{ufm.id}'").first
user_feedback_messages.created_at = ufm.created_at
user_feedback_messages.save
end
end
end
end
# user_feedback_count = UserFeedbackMessage.all.count / 30 + 1
# transaction do
# for i in 1 ... user_feedback_count do i
# UserFeedbackMessage.page(i).per(30).each do |ufm|
# if ufm.journals_for_message
# if ufm.journals_for_message.respond_to?("created_at")
# ufm.created_at = ufm.journals_for_message.created_at
# elsif ufm.journals_for_message.respond_to?("created_on")
# ufm.created_at = ufm.journals_for_message.created_on
# end
# puts ufm.id
# ufm.save
#
# user_feedback_messages = MessageAll.where("message_type = '#{ufm.class.to_s}' and message_id = '#{ufm.id}'").first
# user_feedback_messages.created_at = ufm.created_at
# user_feedback_messages.save
# end
# end
# end
# end
end
def down

View File

@ -925,6 +925,7 @@ img.ui-datepicker-trigger {
text-overflow: ellipsis;
margin-bottom: 3px;
}
.message_title{border: 1px solid #D4D4D4;padding: 0.6em;margin-left: 1.4em;margin-right: 0.4em;border-radius: 4px;font-family: "Microsoft YaHei";background-size: 100% 100%;margin-bottom: 5px;background-color: #E8E8E8;}
.description{display: none !important;}
.ispublic-label{display: none !important;}
.is_public_checkbox{display: none !important;}