小铃铛的数字标识和事情情况有冲突
This commit is contained in:
parent
b83299772c
commit
42ab249651
|
@ -57,6 +57,9 @@ class MessagesController < ApplicationController
|
|||
@replies = @replies[@page * @limit..@page * @limit + 9]
|
||||
@reply = Message.new(:subject => "RE: #{@message.subject}")
|
||||
if @course
|
||||
#帖子消息状态更新
|
||||
course_messages = CourseMessage.where("user_id =? and course_message_type =? and course_id =? and viewed =?", User.current.id, 'Message', @course.id, 0)
|
||||
course_messages.update_all(:viewed => true)
|
||||
#@replies = @topic.children.
|
||||
#includes(:author, :attachments, :praise_tread_cache, {:board => :project}).
|
||||
#reorder("#{Message.table_name}.created_on DESC").
|
||||
|
|
|
@ -69,7 +69,7 @@ class News < ActiveRecord::Base
|
|||
:author_key => :author_id
|
||||
acts_as_watchable
|
||||
|
||||
after_create :act_as_course_activity, :add_author_as_watcher, :add_news_count, :act_as_student_score,:delay_news_wechat_send, :delay_news_send, :act_as_contest_message
|
||||
after_create :act_as_course_activity, :add_author_as_watcher, :add_news_count, :act_as_student_score,:delay_news_wechat_send, :delay_news_send
|
||||
after_update :update_activity
|
||||
after_destroy :delete_kindeditor_assets, :decrease_news_count, :delete_org_activities, :down_course_score
|
||||
|
||||
|
@ -230,13 +230,13 @@ class News < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def act_as_contest_message
|
||||
if self.contest_id
|
||||
self.contest.contest_members.each do | m|
|
||||
if m.user_id != self.author_id
|
||||
self.contest_messages << ContestMessage.new(:user_id => m.user_id, :contest_id => self.contest_id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
# if self.contest_id
|
||||
# self.contest.contest_members.each do | m|
|
||||
# if m.user_id != self.author_id
|
||||
# self.contest_messages << ContestMessage.new(:user_id => m.user_id, :contest_id => self.contest_id, :viewed => false)
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
def delay_news_send
|
||||
|
@ -265,7 +265,7 @@ class News < ActiveRecord::Base
|
|||
vs = []
|
||||
self.contest.contest_members.each do | m|
|
||||
if m.user_id != self.author_id
|
||||
vs << {contest_message_type:'Contest',contest_message_id:self.id, :user_id => m.user_id,
|
||||
vs << {contest_message_type:'News',contest_message_id:self.id, :user_id => m.user_id,
|
||||
:contest_id => self.contest_id, :viewed => false}
|
||||
|
||||
if vs.size >= 30
|
||||
|
|
|
@ -402,7 +402,8 @@ class User < Principal
|
|||
end
|
||||
user = User.current
|
||||
onclick_time = user.onclick_time.onclick_time
|
||||
course_count = CourseMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count
|
||||
delete_courses = Course.where(:is_delete => 1).blank? ? "(-1)" : "(" + Course.where(:is_delete => 1).map(&:id).join(",") + ")"
|
||||
course_count = CourseMessage.where("user_id =? and viewed =? and created_at >? and course_id not in #{delete_courses}", user.id, 0, onclick_time).count
|
||||
contest_count = ContestMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count
|
||||
forge_count = ForgeMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count
|
||||
user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
<% if ma.course_message.jour_type == 'Course' %>
|
||||
<li><a href="<%= course_feedback_path(ma.course_id) %>" target="_blank" title="<%=ma.course_message.user.show_name %> 在班级中留言了:<%= message_content(ma.course_message.notes)%>"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %> </span>在班级中留言了:<%= message_content(ma.course_message.notes)%></a></li>
|
||||
<% elsif ma.course_message.jour_type == 'HomeworkCommon' %>
|
||||
<li><a href="<%= homework_common_index_url_in_org(ma.course_id) %>" target="_blank" title="<%=ma.course_message.user.show_name %> <%=ma.course_message.m_parent_id.nil? ? '回复了您的作业:' : '在作业中回复了您:' %><%= message_content(ma.course_message.notes)%>"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %> </span><%=ma.course_message.m_parent_id.nil? ? '回复了您的作业:' : '在作业中回复了您:' %><%= message_content(ma.course_message.notes)%></a></li>
|
||||
<li><a href="<%= student_work_index_path(:homework => ma.course_message.jour.id) %>" target="_blank" title="<%=ma.course_message.user.show_name %> <%=ma.course_message.m_parent_id.nil? ? '回复了您的作业:' : '在作业中回复了您:' %><%= message_content(ma.course_message.notes)%>"><span class="shadowbox_news_user"><%=ma.course_message.user.show_name %> </span><%=ma.course_message.m_parent_id.nil? ? '回复了您的作业:' : '在作业中回复了您:' %><%= message_content(ma.course_message.notes)%></a></li>
|
||||
<% else %>
|
||||
<% show_name = ma.course_message.jour.reviewer_role != 3 || ma.course_message.user.allowed_to?(:as_teacher, ma.course) %>
|
||||
<li><a href="<%= student_work_index_path(:homework => ma.course_message.jour.student_work.homework_common_id,:show_work_id => ma.course_message.jour.student_work_id) %>" target="_blank" title="<%=show_name ? ma.course_message.user.show_name + "#{ma.course_message.user.allowed_to?(:as_teacher, ma.course)?"老师":"同学"}" : "匿名用户" %> 回复了作品评论:<%= message_content(ma.course_message.notes)%>"><span class="shadowbox_news_user"><%=show_name ? ma.course_message.user.show_name + "#{ma.course_message.user.allowed_to?(:as_teacher, ma.course)?"老师":"同学"}" : "匿名用户" %> </span>回复了作品评论:<%= message_content(ma.course_message.notes)%></a></li>
|
||||
|
@ -106,6 +106,8 @@
|
|||
<li><a href="<%= contestant_works_path(:work => ma.contest_message.id) %>" target="_blank" title="<%=ma.contest_message.user.show_name %> 发布的竞赛题:<%= ma.contest_message.name%>的截止日期快到了"><span class="shadowbox_news_user"><%=ma.contest_message.user.show_name %> </span>发布的竞赛题:<%= ma.contest_message.name%>的截止时间快到啦</a></li>
|
||||
<% elsif ma.contest_message_type == "Work" && ma.status == 2 %>
|
||||
<li><a href="<%= contestant_works_path(:work => ma.contest_message.id) %>" target="_blank" title="<%=ma.contest_message.user.show_name %> 启动了在线评审:<%= ma.contest_message.name%>"><span class="shadowbox_news_user"><%=ma.contest_message.user.show_name %> </span>启动了在线评审:<%= ma.contest_message.name%></a></li>
|
||||
<% elsif ma.contest_message_type == "Work" && ma.status == 3 %>
|
||||
<li><a href="<%= contestant_works_path(:work => ma.contest_message.id) %>" target="_blank" title="<%=ma.contest_message.user.show_name %> 关闭了在线评审:<%= ma.contest_message.name%>"><span class="shadowbox_news_user"><%=ma.contest_message.user.show_name %> </span>关闭了在线评审:<%= ma.contest_message.name%></a></li>
|
||||
<% elsif ma.contest_message_type == "Work" && ma.status == 4 %>
|
||||
<li><a href="<%= contestant_works_path(:work => ma.contest_message.id) %>" target="_blank" title="<%=ma.contest_message.user.show_name %> 在线评审启动失败(评委数为0或作品数为0):<%= ma.contest_message.name%>"><span class="shadowbox_news_user"><%=ma.contest_message.user.show_name %> </span>在线评审启动失败(评委数为0或作品数为0):<%= ma.contest_message.name%></a></li>
|
||||
<% elsif ma.contest_message_type == "Work" && ma.status == 5 %>
|
||||
|
|
|
@ -176,6 +176,24 @@
|
|||
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
|
||||
<!--关闭在线评审-->
|
||||
<% elsif ma.contest_message_type == "Work" && ma.status == 3 && ma.contest_message %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<div class="longMessageWidth">
|
||||
<li class="homepageNewsPortrait fl">
|
||||
<%= link_to image_tag(url_to_avatar(ma.contest_message.user), :width => "30", :height => "30"), user_path(ma.contest_message.user), :target => '_blank' %>
|
||||
</li>
|
||||
<li class="homepageNewsPubType fl">
|
||||
<%= link_to ma.contest_message.user.show_name, user_path(ma.contest_message.user), :class => "newsBlue homepageNewsPublisher", :target => '_blank' %>
|
||||
<span class="homepageNewsType fl">关闭了在线评审:</span>
|
||||
</li>
|
||||
<li class="messageInformationContents">
|
||||
<%= link_to ma.contest_message.name, contestant_works_path(:work => ma.contest_message.id), :class => "#{!ma.viewed ? "newsBlack" : "newsGrey"}", :target => "_blank"%>
|
||||
</li>
|
||||
</div>
|
||||
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
||||
|
||||
<!--在线评审启动失败-->
|
||||
<% elsif ma.contest_message_type == "Work" && ma.status == 4 && ma.contest_message %>
|
||||
<ul class="homepageNewsList fl">
|
||||
|
@ -188,7 +206,7 @@
|
|||
<span class="homepageNewsType fl">在线评审启动失败<font class="c_red">(评委数为0或作品数为0):</font></span>
|
||||
</li>
|
||||
<li class="messageInformationContents">
|
||||
<%= link_to ma.contest_message.name, contestant_works_path(:work => ma.contest_message.id), :class => "#{!ma.viewed ? "newsBlack" : "newsGrey"}"%>
|
||||
<%= link_to ma.contest_message.name, contestant_works_path(:work => ma.contest_message.id), :class => "#{!ma.viewed ? "newsBlack" : "newsGrey"}", :target => "_blank" %>
|
||||
</li>
|
||||
</div>
|
||||
<li class="homepageNewsTime fr"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
|
|
|
@ -490,7 +490,7 @@
|
|||
</span>
|
||||
</li>
|
||||
<li class="messageInformationContents">
|
||||
<%= link_to message_content(ma.course_message.notes), homework_common_index_url_in_org( ma.course_id),
|
||||
<%= link_to message_content(ma.course_message.notes), student_work_index_path(:homework => ma.course_message.jour.id),
|
||||
:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :target => '_blank' %>
|
||||
<!--:onmouseover => "message_titile_show($(this),event)",-->
|
||||
<!--:onmouseout => "message_titile_hide($(this))" %>-->
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
class DeleteContestMessages < ActiveRecord::Migration
|
||||
def up
|
||||
ContestMessage.where("contest_message_type = 'Contest'").delete_all
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
19
db/schema.rb
19
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20170307082304) do
|
||||
ActiveRecord::Schema.define(:version => 20170309024921) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -1456,6 +1456,23 @@ ActiveRecord::Schema.define(:version => 20170307082304) do
|
|||
|
||||
add_index "memos", ["root_id"], :name => "index_memos_on_root_id"
|
||||
|
||||
create_table "mess", :id => false, :force => true do |t|
|
||||
t.string "课程名"
|
||||
t.integer "课程ID", :default => 0, :null => false
|
||||
t.string "教师姓", :default => "", :null => false
|
||||
t.string "教师名", :limit => 30, :default => "", :null => false
|
||||
t.string "主贴名", :default => "", :null => false
|
||||
t.integer "主贴或回帖ID", :default => 0, :null => false
|
||||
t.integer "回帖对应主贴ID"
|
||||
t.integer "帖子点赞数"
|
||||
t.integer "主贴回复数", :default => 0, :null => false
|
||||
t.text "主贴或回帖内容"
|
||||
t.datetime "发帖时间", :null => false
|
||||
t.integer "发帖或回帖用户ID", :default => 0, :null => false
|
||||
t.string "发帖或回帖用户姓", :default => "", :null => false
|
||||
t.string "发帖或回帖用户名", :limit => 30, :default => "", :null => false
|
||||
end
|
||||
|
||||
create_table "message_alls", :force => true do |t|
|
||||
t.integer "user_id"
|
||||
t.integer "message_id"
|
||||
|
|
Loading…
Reference in New Issue