添加项目新闻回复 消息通知
This commit is contained in:
parent
2f21b4663d
commit
29b8a9dd9d
|
@ -98,7 +98,7 @@ class UsersController < ApplicationController
|
|||
|
||||
# 用户消息
|
||||
# 说明: homework 发布作业;message:讨论区; news:新闻; poll:问卷;works_reviewers:作品评阅;works_reply:作品回复
|
||||
# issue:问题;journal:缺陷状态更新; forum:公共贴吧: user_feedback: 用户留言
|
||||
# issue:问题;journal:缺陷状态更新; forum:公共贴吧: user_feedback: 用户留言; new_reply:新闻回复(comment)
|
||||
def user_messages
|
||||
unless User.current.logged?
|
||||
render_403
|
||||
|
@ -135,6 +135,12 @@ class UsersController < ApplicationController
|
|||
when 'forge_news'
|
||||
@user_forge_messages = ForgeMessage.where("forge_message_type =? and user_id =?", "News", @user).order("created_at desc")
|
||||
@user_forge_messages_count = @user_forge_messages.count
|
||||
when 'course_news_reply'
|
||||
@user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Comment", @user).order("created_at desc")
|
||||
@user_course_messages_count = @user_course_messages.count
|
||||
when 'forge_news_reply'
|
||||
@user_forge_messages = ForgeMessage.where("course_message_type =? and user_id =?", "Comment", @user).order("created_at desc")
|
||||
@user_forge_messagess_count = @user_forge_messages.count
|
||||
when 'poll'
|
||||
@user_course_messages = CourseMessage.where("course_message_type =? and user_id =?", "Poll", @user).order("created_at desc")
|
||||
@user_course_messages_count = @user_course_messages.count
|
||||
|
|
|
@ -21,6 +21,10 @@ class Comment < ActiveRecord::Base
|
|||
has_many_kindeditor_assets :assets, :dependent => :destroy
|
||||
|
||||
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
|
||||
# 课程/项目 消息
|
||||
has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy
|
||||
has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy
|
||||
#end
|
||||
acts_as_event :datetime => :updated_on,
|
||||
:description => :comments,
|
||||
:type => 'news',
|
||||
|
@ -31,7 +35,19 @@ class Comment < ActiveRecord::Base
|
|||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
validates_presence_of :commented, :author, :comments
|
||||
safe_attributes 'comments'
|
||||
after_create :send_mail
|
||||
after_create :send_mail, :act_as_system_message
|
||||
|
||||
def act_as_system_message
|
||||
if self.commented.course
|
||||
if self.author_id != self.commented.author_id
|
||||
self.course_messages << CourseMessage.new(:user_id => self.commented.author_id, :course_id => self.commented.course.id, :viewed => false)
|
||||
end
|
||||
else # 项目相关
|
||||
if self.author_id != self.commented.author_id
|
||||
self.forge_messages << ForgeMessage.new(:user_id => self.commented.author_id, :project_id => self.commented.project.id, :viewed => false)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def send_mail
|
||||
if self.commented.is_a?(News) && Setting.notified_events.include?('news_comment_added')
|
||||
|
|
|
@ -10,17 +10,20 @@
|
|||
<%# 课程相关消息 %>
|
||||
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "作业消息",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'homework'} %></a></li>
|
||||
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "课程讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_message'} %></a></li>
|
||||
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "发布了课程通知",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_news'} %></a></li>
|
||||
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "问卷调查",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'poll'} %></a></li>
|
||||
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "课程通知",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_news'} %></a></li>
|
||||
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "通知回复",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'course_news_reply'} %></a></li>
|
||||
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "课程问卷",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'poll'} %></a></li>
|
||||
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "作品评阅",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reviewers'} %></a></li>
|
||||
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "作品讨论",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'works_reply'} %></a></li>
|
||||
<%# 项目相关消息 %>
|
||||
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "指派给我",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue'} %></a></li>
|
||||
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "更新了问题",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'issue_update'} %></a></li>
|
||||
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "项目讨论区",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_message'} %></a></li>
|
||||
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "发布了新闻",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_news'} %></a></li>
|
||||
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "项目新闻",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_news'} %></a></li>
|
||||
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "新闻回复",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forge_news_reply'} %></a></li>
|
||||
<%# 项目相关消息 %>
|
||||
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "贴吧帖子",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'forum'} %></a></li>
|
||||
<%# 用户留言 %>
|
||||
<%# 系统贴吧 %>
|
||||
<li><a href="javascript:void(0);" class="resourcesGrey"><%= link_to "用户留言",{:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user, :type => 'user_feedback'} %></a></li>
|
||||
|
||||
</ul>
|
||||
|
@ -43,6 +46,16 @@
|
|||
<li class="homepageNewsTime fl"><%= time_tag(ucm.course_message.created_on).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% if ucm.course_message_type == "Comment" %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%= image_tag(url_to_avatar(ucm.course_message.author), :width => "30", :height => "30") %></a></li>
|
||||
<li class="homepageNewsPublisher fl"><a href="javascript:void(0);" class="newsBlue"><%= ucm.course_message.author %></a></li>
|
||||
<li class="<%= ucm.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">回复了通知</li>
|
||||
<li class="homepageNewsContent fl">
|
||||
<%= link_to "#{ucm.course_message.comments}", {:controller => 'news', :action => 'show', :id => ucm.course_message.commented.id },:class =>"#{ucm.viewed == 0 ? "newsBlack" : "newsGrey"}" %></li>
|
||||
<li class="homepageNewsTime fl"><%= time_tag(ucm.course_message.created_on).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% if ucm.course_message_type == "HomeworkCommon" %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%= image_tag(url_to_avatar(ucm.course_message.user), :width => "30", :height => "30") %></a></li>
|
||||
|
@ -162,13 +175,23 @@
|
|||
<li class="homepageNewsPublisher fl">
|
||||
<a href="javascript:void(0);" class="newsBlue"><%= ufm.forge_message.author %></a>
|
||||
</li>
|
||||
<li class="homepageNewsType fl">发布了项目消息</li>
|
||||
<li class="homepageNewsType fl">发布新闻</li>
|
||||
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
|
||||
<%= link_to ("#{ufm.forge_message.title}"), {:controller => 'news', :action => 'show', :id => ufm.forge_message.id}, :class => "newsGrey" %></a>
|
||||
</li>
|
||||
<li class="homepageNewsTime fl"><%= time_tag(ufm.forge_message.created_on).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% if ufm.forge_message_type == "Comment" %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%= image_tag(url_to_avatar(ufm.forge_message.author), :width => "30", :height => "30") %></a></li>
|
||||
<li class="homepageNewsPublisher fl"><a href="javascript:void(0);" class="newsBlue"><%= ufm.forge_message.author %></a></li>
|
||||
<li class="homepageNewsType fl">回复了新闻</li>
|
||||
<li class="homepageNewsContent fl">
|
||||
<%= link_to "#{ufm.forge_message.comments}", {:controller => 'news', :action => 'show', :id => ufm.forge_message.commented.id },:class =>"#{ufm.viewed == 0 ? "newsBlack" : "newsGrey"}" %></li>
|
||||
<li class="homepageNewsTime fl"><%= time_tag(ufm.forge_message.created_on).html_safe %> </li>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%# 公共贴吧 %>
|
||||
|
|
Loading…
Reference in New Issue