diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index c8518e8a3..a77346d89 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -70,31 +70,16 @@ class BoardsController < ApplicationController def show # 讨论区消息状态更新(已读和未读) if @project - query_forge_messages = @board.messages - query_forge_messages.each do |query_forge_message| - query = query_forge_message.forge_messages - query.each do |forge_message| - if User.current.id == forge_message.user_id - forge_message.update_attributes(:viewed => true) - end - end - end + ForgeMessage.where("user_id =? and project_id =? and viewed =?", User.current.id, @project.id, 0).update_all(:viewed => true) # 更新@消息为已读 - @project.boards.each do |board| - board.messages.each do |m| - User.current.at_messages.unviewed('Message', m.id).each {|x| x.viewed!} - end - end + # 注释掉这句是因为和上面的方法代码重复,一个类型的消息,已经更新就不需要再更新 + # @project.boards.each do |board| + # board.messages.each do |m| + # User.current.at_messages.unviewed('Message', m.id).each {|x| x.viewed!} + # end + # end elsif @course - query_course_messages = @board.messages - query_course_messages.each do |query_course_message| - query = query_course_message.course_messages - query.each do |course_message| - if User.current.id == course_message.user_id - course_message.update_attributes(:viewed => true) - end - end - end + CourseMessage.where("user_id =? and course_id =? and viewed =?", User.current.id, @course.id, 0).update_all(:viewed => true) end sort_init 'updated_on', 'desc' diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index b2a828768..113e37af3 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -308,7 +308,7 @@ class ProjectsController < ApplicationController if User.current.member_of?(@project) || User.current.admin? case params[:type] when nil - @events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'Message','News', 'ProjectCreateInfo', 'Attachment')", @project).includes(:forge_act).order("updated_at desc").limit(10).offset(@page * 10) + @events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'Message','News', 'Project', 'Attachment')", @project).includes(:forge_act).order("updated_at desc").limit(10).offset(@page * 10) when 'issue' @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Issue'", @project).includes(:forge_act).order("updated_at desc").limit(10).offset(@page * 10) when 'news' diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb index a698823e5..71b23fdcf 100644 --- a/app/controllers/student_work_controller.rb +++ b/app/controllers/student_work_controller.rb @@ -230,12 +230,12 @@ class StudentWorkController < ApplicationController render_403 return end - @student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").order("#{@order} #{@b_sort}"),@name).count end @score = @b_sort == "desc" ? "asc" : "desc" - + # 消息传过来的ID + @message_student_work_id = params[:student_work_id] respond_to do |format| format.js format.html diff --git a/app/models/project.rb b/app/models/project.rb index 32677143d..184b3c7af 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -108,7 +108,8 @@ class Project < ActiveRecord::Base has_many :tags, :through => :project_tags, :class_name => 'Tag' has_many :project_tags, :class_name => 'ProjectTags' # 动态级联删除 - has_many :forge_activities, :class_name => 'ForgeActivity', :dependent => :destroy + has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy + #has_many :forge_activities, :class_name => 'ForgeActivity', :as =>:forge_act, :dependent => :destroy # 关联虚拟表 has_many :forge_messages, :class_name =>'ForgeMessage', :as => :forge_message, :dependent => :destroy @@ -1212,9 +1213,7 @@ class Project < ActiveRecord::Base # Author lizanle # Description 新建项目要在ForgeActivities中加一条数据。 def acts_as_forge_activities - fa = ForgeActivity.new(:user_id => User.current.id,:project_id => self.id, - :forge_act_id => self.id,:forge_act_type => "ProjectCreateInfo") - fa.save! + self.forge_acts << ForgeActivity.new(:user_id => User.current.id, :project_id => self.id) end diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 5ad25d5bd..3af8f9212 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -44,8 +44,6 @@
- - <%#= render :partial => 'layouts/new_header'%>
@@ -104,20 +102,6 @@