注释掉消息迁移文件

修改消息html样式
This commit is contained in:
huang 2015-09-02 21:33:03 +08:00
parent c7f15d3a3e
commit a47c9176b7
9 changed files with 287 additions and 287 deletions

View File

@ -31,7 +31,7 @@
<div> <div>
<% if params[:type].nil? %> <% if params[:type].nil? %>
<div class="newsReadSetting"> <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> </div>
<% end %> <% end %>
<% if @message_alls.count >0 %> <% if @message_alls.count >0 %>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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