From 341308658da0423cac9e28400af07974c384ba7e Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 22 Mar 2016 10:48:37 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=9B=B4=E6=96=B0=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 2ced977be..f74350672 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -560,18 +560,9 @@ class ProjectsController < ApplicationController end def update_message_status(user, project) - project_invite_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type =?", user, project, "ProjectInvite") - project_invite_messages.each do |project_invite_message| - project_invite_message.update_attribute(:viewed, true) - end - #更新被加入项目消息的viewed字段 - join_project_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type=?", user, project, "JoinProject") - join_project_messages.each do |join_project| - join_project.update_attribute(:viewed, true) - end - #更新被移出项目消息的viewed字段 - remove_project_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type=?", user, project, "RemoveFromProject") - remove_project_messages.update_all(:viewed => true) + # 更新加入项目消息 + project__messages = ForgeMessage.where("forge_message_type in ('ProjectInvite', 'JoinProject', 'RemoveFromProject') and user_id =? and project_id =? ", user, project) + project__messages.update_all(:viewed => true) unless project__messages.blank? end def message_invite(message_id, key) From 478311128d52613d4f78df7ab6a736818877ee83 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 22 Mar 2016 12:42:53 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BC=98=E5=8C=96project=5Fcontroller=20sh?= =?UTF-8?q?ow=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 2 +- app/controllers/projects_controller.rb | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index dfa30915e..515b94392 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -852,7 +852,7 @@ class CoursesController < ApplicationController # return # end # 统计访问量 - @course.update_attribute(:visits, @course.visits.to_i + 1) + @course.update_column(:visits, @course.visits.to_i + 1) #更新创建课程消息状态 create_course_messages = @course.course_messages.where("user_id =? and course_message_type =? and course_id =? and viewed =?", User.current.id, 'Course', @course.id, 0) create_course_messages.update_all(:viewed => true) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index f74350672..fe7d4bbe5 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -295,11 +295,13 @@ class ProjectsController < ApplicationController def show # 更新消息为已读 update_message_status(User.current, @project) + # over if params[:jump] && redirect_to_project_menu_item(@project, params[:jump]) return end # 统计访问量 - @project.update_attribute(:visits, @project.visits.to_i + 1) + @project.update_column(:visits, @project.visits + 1) + # over @author = params[:user_id].blank? ? nil : User.active.find(params[:user_id]) @page = params[:page] ? params[:page].to_i + 1 : 0 # 根据私密性,取出符合条件的所有数据 @@ -321,8 +323,6 @@ class ProjectsController < ApplicationController = ? and forge_act_type != ? ",@project,1, "Document").order("created_at desc") .page(params['page'|| 1]).per(10); end - boards = @project.boards.includes(:last_message => :author).all - @topic_count = @project.boards.count # 根据对应的请求,返回对应的数据 respond_to do |format| format.html From 7967066b05db8bc4568f1a715ea1b0e086ec61a9 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 22 Mar 2016 15:06:54 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E9=99=84=E4=BB=B6=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E5=8F=91=E9=80=81=E6=96=B9=E5=BC=8F=E6=94=B9?= =?UTF-8?q?=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 13 +++++++------ app/models/attachment.rb | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 7ae1b85f8..69b356b5a 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -458,10 +458,16 @@ class FilesController < ApplicationController if params[:in_project_toolbar] @in_project_toolbar = params[:in_project_toolbar] end - # 发送邮件 attachments = Attachment.attach_filesex(@project, params[:attachments], params[:attachment_type]) if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') + # 发送邮件 Mailer.run.attachments_added(attachments[:files]) + # 生成动态 + attachments[:files].each do |file| + ForgeActivity.create(:user_id => User.current.id, :project_id => @project.id, :forge_act_id => file.id, :forge_act_type => "Attachment") + end + # 更新资源总数, 根据上传的附件数累加 + @project.project_score.update_attribute(:attach_num, @project.project_score.attach_num + attachments[:files].count) unless @project.project_score.nil? end # end if params[:project_attachment_type] && params[:project_attachment_type].is_a?(Array) @@ -485,11 +491,6 @@ class FilesController < ApplicationController end end end - # 更新资源总数, 根据上传的附件数累加 - unless @project.project_score.nil? - @project.project_score.update_attribute(:attach_num, @project.project_score.attach_num + attachments[:files].count) - end - # end # TODO: 临时用 nyan sort_init 'created_on', 'desc' sort_update 'created_on' => "#{Attachment.table_name}.created_on", diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 714da9920..881621c3a 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -90,7 +90,7 @@ class Attachment < ActiveRecord::Base @@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails") before_save :files_to_final_location - after_save :act_as_course_activity,:act_as_forge_activity + after_save :act_as_course_activity after_create :office_conver, :be_user_score,:create_attachment_ealasticsearch_index after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index, :decrease_attchments_count, :down_course_score