From 0a0f5d98dbe413900f5006d137565404c6832353 Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Fri, 3 Jul 2015 15:03:53 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81=20?= =?UTF-8?q?=E5=8A=A0=E5=85=A5=20=E4=B8=8E=E6=88=91=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../activity_notifys_controller.rb | 1 + app/controllers/comments_controller.rb | 14 +++++++++++++ app/controllers/news_controller.rb | 15 +++++++++++++ app/models/comment.rb | 21 +++++++++++++++++++ app/models/news.rb | 15 +++++++++++++ 5 files changed, 66 insertions(+) diff --git a/app/controllers/activity_notifys_controller.rb b/app/controllers/activity_notifys_controller.rb index 01e4260ea..ad9818fcc 100644 --- a/app/controllers/activity_notifys_controller.rb +++ b/app/controllers/activity_notifys_controller.rb @@ -6,6 +6,7 @@ class ActivityNotifysController < ApplicationController # accept_rss_auth :index, :show helper :activities + helper :attachments def index query = nil if @course diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index d226000c0..c10f8bc84 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -34,6 +34,20 @@ class CommentsController < ApplicationController ids = params[:asset_id].split(',') update_kindeditor_assets_owner ids,@comment.id,OwnerTypeHelper::COMMENT end + # 与我相关动态的记录add start + if( @comment.id && @news.course ) + if(@news.author_id != User.current.id) + notify = ActivityNotify.new() + notify.activity_container_id = @news.course.id + notify.activity_container_type = 'Course' + notify.activity_id = @comment.id + notify.activity_type = 'Comment' + notify.notify_to = @news.author_id + notify.is_read = 0 + notify.save() + end + end + # 与我相关动态的记录add end flash[:notice] = l(:label_comment_added) end diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index f71a77ca7..56b4a30fc 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -141,6 +141,21 @@ class NewsController < ApplicationController ids = params[:asset_id].split(',') update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS end + # 与我相关动态的记录add start + teachers = searchTeacherAndAssistant(@course) + for teacher in teachers + if(teacher.user_id != User.current.id) + notify = ActivityNotify.new() + notify.activity_container_id = @course.id + notify.activity_container_type = 'Course' + notify.activity_id = @news.id + notify.activity_type = 'News' + notify.notify_to = teacher.user_id + notify.is_read = 0 + notify.save() + end + end + # 与我相关动态的记录add end render_attachment_warning_if_needed(@news) flash[:notice] = l(:notice_successful_create) redirect_to course_news_index_url(@course) diff --git a/app/models/comment.rb b/app/models/comment.rb index bdb642d3c..a4842a23f 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -19,6 +19,14 @@ class Comment < ActiveRecord::Base include Redmine::SafeAttributes include ApplicationHelper has_many_kindeditor_assets :assets, :dependent => :destroy + + has_many :ActivityNotifies,:as => :activity, :dependent => :destroy + acts_as_event :datetime => :updated_on, + :description => :comments, + :type => 'news', + :title=>Proc.new {|o| "RE: #{o.commented.title}" }, + :url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.commented.id} } + belongs_to :commented, :polymorphic => true, :counter_cache => true belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' validates_presence_of :commented, :author, :comments @@ -38,4 +46,17 @@ class Comment < ActiveRecord::Base def delete_kindeditor_assets delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::COMMENT end + + def set_notify_id(notify_id) + @notify_id= notify_id + end + def get_notify_id() + return @notify_id + end + def set_notify_is_read(notify_is_read) + @notify_is_read = notify_is_read + end + def get_notify_is_read() + return @notify_is_read + end end diff --git a/app/models/news.rb b/app/models/news.rb index 7e809cbfd..7d33d760e 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -30,6 +30,8 @@ class News < ActiveRecord::Base has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy # end + has_many :ActivityNotifies,:as => :activity, :dependent => :destroy + validates_presence_of :title, :description validates_length_of :title, :maximum => 60 validates_length_of :summary, :maximum => 255 @@ -85,6 +87,19 @@ class News < ActiveRecord::Base #description end + def set_notify_id(notify_id) + @notify_id= notify_id + end + def get_notify_id() + return @notify_id + end + def set_notify_is_read(notify_is_read) + @notify_is_read = notify_is_read + end + def get_notify_is_read() + return @notify_is_read + end + private def add_author_as_watcher From d882a3c5eea306a54e220eb232a7fd15d29614df Mon Sep 17 00:00:00 2001 From: yutao <283765470@qq.com> Date: Fri, 3 Jul 2015 15:20:53 +0800 Subject: [PATCH 2/2] =?UTF-8?q?bug#2948:=E5=9C=A8=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=92=8C=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=EF=BC=8C=E8=A2=AB=E7=95=99=E8=A8=80=E7=9A=84=E4=BA=BA=E5=BA=94?= =?UTF-8?q?=E8=AF=A5=E8=83=BD=E7=9C=8B=E5=88=B0=E7=95=99=E8=A8=80=E4=BA=BA?= =?UTF-8?q?=E7=9A=84=E6=98=B5=E7=A7=B0=E5=92=8C=E7=9C=9F=E5=AE=9E=E5=A7=93?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/_history.html.erb | 2 +- app/views/users/_history.html.erb | 2 +- app/views/words/_journal_reply_items.html.erb | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/courses/_history.html.erb b/app/views/courses/_history.html.erb index e9639f4f0..043bac947 100644 --- a/app/views/courses/_history.html.erb +++ b/app/views/courses/_history.html.erb @@ -9,7 +9,7 @@
- <%= link_to journal.user.show_name, user_path(journal.user),:class => 'c_blue fb fl mb10', :target => "_blank"%> + <%= link_to "#{journal.user.show_name}(#{journal.user.login})", user_path(journal.user),:class => 'c_blue fb fl mb10', :target => "_blank"%> <%= format_time(journal.created_on) %> diff --git a/app/views/users/_history.html.erb b/app/views/users/_history.html.erb index d69b6b25b..a87c2d8e4 100644 --- a/app/views/users/_history.html.erb +++ b/app/views/users/_history.html.erb @@ -9,7 +9,7 @@
- <%= link_to journal.user, user_path(journal.user),:style => " font-weight:bold; color:#15bccf; margin-right:30px; background:none;", :target => "_blank"%><%= format_time(journal.created_on) %> + <%= link_to "#{journal.user.show_name}(#{journal.user.login})", user_path(journal.user),:style => " font-weight:bold; color:#15bccf; margin-right:30px; background:none;", :target => "_blank"%><%= format_time(journal.created_on) %>

<%=journal.notes.html_safe%>

diff --git a/app/views/words/_journal_reply_items.html.erb b/app/views/words/_journal_reply_items.html.erb index f93254218..5e9d6ef46 100644 --- a/app/views/words/_journal_reply_items.html.erb +++ b/app/views/words/_journal_reply_items.html.erb @@ -13,10 +13,10 @@
<% id = 'project_respond_form_'+ reply.id.to_s %> - <%= link_to reply.user.show_name, user_path(reply.user) %> + <%= link_to "#{reply.user.show_name}(#{reply.user.login})", user_path(reply.user) %> <%= l(:label_reply_to)%> <% if show_name %> - <%= link_to parent_jour.user.show_name, user_path(parent_jour.user) %> + <%= link_to "#{parent_jour.user.show_name}(#{parent_jour.user.login})", user_path(parent_jour.user) %> <% else %> <%= l(:label_anonymous) %> <% end %>