diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 22d8deb0c..919093556 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -550,9 +550,27 @@ class UsersController < ApplicationController def show @page = (params[:page] || -1).to_i + 1 + @type = params[:type] user_project_ids = "(" + @user.projects.visible.map{|project| project.id}.join(",") + ")" user_course_ids = "(" + @user.courses.visible.map{|course| course.id}.join(",") + ")" - @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids}) or (container_type = 'Course' and container_id in #{user_course_ids})").order('created_at desc').limit(10).offset(@page * 10) + if @type + case @type + when "course_homework" + @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'HomeworkCommon'").order('created_at desc').limit(10).offset(@page * 10) + when "course_news" + @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'News'").order('created_at desc').limit(10).offset(@page * 10) + when "course_message" + @user_activities = UserActivity.where("container_type = 'Course' and container_id in #{user_course_ids} and act_type = 'Message'").order('created_at desc').limit(10).offset(@page * 10) + when "project_issue" + @user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Issue'").order('created_at desc').limit(10).offset(@page * 10) + when "project_message" + @user_activities = UserActivity.where("container_type = 'Project' and container_id in #{user_project_ids} and act_type = 'Message'").order('created_at desc').limit(10).offset(@page * 10) + end + else + course_types = "('Message','News','HomeworkCommon')" + project_types = "('Message','Issue')" + @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids}) and act_type in #{course_types}").order('created_at desc').limit(10).offset(@page * 10) + end # @user_activities = paginateHelper @user_activities,500 render :layout=>'new_base_user' end diff --git a/app/views/users/_course_attachment.html.erb b/app/views/users/_course_attachment.html.erb new file mode 100644 index 000000000..d58ef5655 --- /dev/null +++ b/app/views/users/_course_attachment.html.erb @@ -0,0 +1,39 @@ +