From 35fdf9a8a7c8d66e435e7861c569931d566e8da4 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Tue, 6 Dec 2016 09:36:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E9=A6=96=E9=A1=B5=E5=A4=B4?= =?UTF-8?q?=E9=83=A8=E5=8F=8A=E5=85=B6=E5=B7=A6=E4=BE=A7=E5=AF=BC=E8=88=AA?= =?UTF-8?q?(=E6=9C=AA=E5=AE=8C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Gemfile | 4 +- app/controllers/users_controller.rb | 12 +- app/helpers/users_helper.rb | 37 ++++ app/views/layouts/_logined_header.html.erb | 18 +- .../layouts/_user_brief_introduction.html.erb | 14 +- app/views/layouts/_user_watch_btn.html.erb | 4 +- app/views/layouts/new_base_user.html.erb | 178 +++++++++++++----- app/views/users/user_messages.html.erb | 2 +- public/images/user/female.jpg | Bin 3783 -> 14850 bytes public/images/user/home-user-mes.png | Bin 0 -> 107495 bytes public/images/user/male.jpg | Bin 4136 -> 2756 bytes public/images/user/nonews.png | Bin 0 -> 112502 bytes public/images/user/user_navmore_icons.png | Bin 1085 -> 19619 bytes public/stylesheets/css/common.css | 17 +- public/stylesheets/css/project.css | 18 +- public/stylesheets/css/user.css | 170 +++++++++++++++++ 16 files changed, 389 insertions(+), 85 deletions(-) create mode 100644 public/images/user/home-user-mes.png create mode 100644 public/images/user/nonews.png create mode 100644 public/stylesheets/css/user.css diff --git a/Gemfile b/Gemfile index 58ccbc011..b8b49cf95 100644 --- a/Gemfile +++ b/Gemfile @@ -50,10 +50,10 @@ gem 'elasticsearch-model' gem 'elasticsearch-rails' #rails 3.2.22.2 bug - gem "test-unit", "~>3.0" +# gem "test-unit", "~>3.0" ### profile - gem 'oneapm_rpm' +# gem 'oneapm_rpm' group :development do gem 'grape-swagger' diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index da7cfd849..1ffc4f0d7 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -433,7 +433,7 @@ class UsersController < ApplicationController render_404 return end - @message_alls = paginateHelper @message_alls,25 + @message_alls = paginateHelper @message_alls, 25 respond_to do |format| format.html{render :layout=>'new_base_user'} end @@ -1822,6 +1822,16 @@ class UsersController < ApplicationController principal_types = "JournalsForMessage" container_type = '' act_type = '' + + # 用户项目数 + @my_project_count = user_project_count + # 用户的课程数 + @my_course_count = user_course_count + # 用户发布的issue数 + @issues_author_is_self_count = issues_author_is_self_count + # 用户收到的issue数 + @issues_assigned_is_self_count = issues_assigned_is_self_count + if params[:type].present? case params[:type] when "course_homework" diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 98024954d..e5dcfc2df 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -53,6 +53,43 @@ module UsersHelper end + + # 用户项目总数 + def user_project_count + @my_projects = @user.projects.where("projects.user_id = #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC") + @my_projects_count = @my_projects.count + @my_joined_projects = @user.projects.where("projects.user_id != #{@user.id}").select("projects.*,(SELECT MAX(updated_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS updatetime").order("updatetime DESC") + @my_joined_projects_count = @my_joined_projects.count + + @my_project_total = @my_projects_count + @my_joined_projects_count + end + + # 用户的课程总数 + def user_course_count + @my_course_count = @user.syllabuses.count + + sy_courses = @user.courses.visible.not_deleted + syllabus_ids = sy_courses.empty? ? '(-1)' : "(" + sy_courses.map{|course| !course.syllabus_id.nil? && course.syllabus_id}.join(",") + ")" + syllabus_members = SyllabusMember.where("user_id = #{@user.id}") + syllabus_member_ids = syllabus_members.empty? ? "(-1)" : "(" + syllabus_members.map{|syl_mem| syl_mem.syllabus_id}.join(',') + ")" + @join_syllabuses = Syllabus.where("(id in #{syllabus_ids} or id in #{syllabus_member_ids}) and user_id != #{@user.id}") + @my_joined_course_count = @join_syllabuses.count + + @user_course_total = @my_joined_course_count + @my_course_count + end + + # 用户发布的issue数 + def issues_author_is_self_count + @issues = Issue.where( :author_id => @user.id ) + @issues_author_is_self_count = @issues.count + end + + # 用户收到的issue数 + def issues_assigned_is_self_count + @issues = Issue.where( :assigned_to_id => @user.id ) + @issues_assigned_is_self_count = @issues.count + end + def get_resource_type type case type when 'Course' diff --git a/app/views/layouts/_logined_header.html.erb b/app/views/layouts/_logined_header.html.erb index db1e4f1cc..971414835 100644 --- a/app/views/layouts/_logined_header.html.erb +++ b/app/views/layouts/_logined_header.html.erb @@ -7,13 +7,19 @@