issue详情优化

This commit is contained in:
huang 2016-12-21 16:28:51 +08:00
parent 88f376205d
commit a759fce270
4 changed files with 17 additions and 28 deletions

View File

@ -1818,25 +1818,14 @@ class UsersController < ApplicationController
def show
if is_current_user
# 自己的主页显示消息
# 系统消息为管理员发送,我的消息中包含有系统消息
@message_alls = []
messages = MessageAll.where("(user_id =? and message_type !=?) or message_type =?" ,@user.id, "SystemMessage", "SystemMessage").includes(:message).order("created_at desc")
messages.each do |message_all|
mess = message_all.message
unless (message_all.message_type == 'CourseMessage' && mess && mess.course && mess.course.is_delete == 1)
@message_alls << mess
end
end
# 系统消息为管理员发送,我的消息中包含有系统消息(187ms)
@message_alls = MessageAll.where("(user_id =? and message_type !=?) or message_type =?" ,@user.id, "SystemMessage", "SystemMessage").includes(:message).order("created_at desc")
@message_count = @message_alls.count
@message_alls = paginateHelper @message_alls, 20
# 用户待解决的issue
=begin
@unsolved_issues = Issue.where(:assigned_to_id => @user.id, :status_id => [1, 2, 4, 6]).includes(:author, :project).order("updated_on desc")
@unsolved_issues_count = @unsolved_issues.count
@unsolved_issue_pages = Paginator.new @unsolved_issues_count, 20, params['page'] || 1
@unsolved_issues = paginateHelper @unsolved_issues, 20
=end
@unsolved_issues_count = Issue.where(:assigned_to_id => @user.id, :status_id => [1, 2, 4, 6]).includes(:author, :project).order("updated_on desc").count
# 待解决的issue数(1ms)
@unsolved_issues_count = Issue.find_by_sql("SELECT count(*) FROM `issues`, `projects` where issues.project_id = projects.id and projects.status =1 and assigned_to_id =#{@user.id} and status_id in (1, 2, 4, 6);").count
# 用户待完成的作业
my_course_ids = StudentsForCourse.where(:student_id => @user.id).blank? ? "(-1)" : "(" + StudentsForCourse.where(:student_id => @user.id).map{|sc| sc.course_id}.join(",") + ")"
homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Date.today}'")

View File

@ -1,25 +1,25 @@
<% message_alls.each do |ma| %>
<% @message_alls.each do |ma| %>
<%# 系统消息 %>
<%= render :partial => 'users/user_message_system', :locals => {:ma => ma} %>
<%= render :partial => 'users/user_message_system', :locals => {:ma => ma.message} %>
<%= render :partial => 'users/user_at_message', :locals => {:ma => ma} %>
<%= render :partial => 'users/user_at_message', :locals => {:ma => ma.message} %>
<%# 课程消息 %>
<%= render :partial => 'users/user_message_course', :locals => {:ma => ma} %>
<%= render :partial => 'users/user_message_course', :locals => {:ma => ma.message} %>
<!--项目消息-->
<%= render :partial => 'users/user_message_forge', :locals => {:ma => ma} %>
<%= render :partial => "users/user_message_forge", :locals => {:ma => ma.message} %>
<!--公共贴吧-->
<%= render :partial => 'users/user_message_forum', :locals => {:ma => ma} %>
<%= render :partial => 'users/user_message_forum', :locals => {:ma => ma.message} %>
<!--用户留言-->
<%= render :partial => 'users/user_message_userfeedaback', :locals => {:ma => ma} %>
<%= render :partial => 'users/user_message_userfeedaback', :locals => {:ma => ma.message} %>
<%= render :partial => 'users/user_message_org', :locals => {:ma => ma} %>
<%= render :partial => 'users/user_message_org', :locals => {:ma => ma.message} %>
<%# 申请类消息 %>
<%= render :partial => 'users/user_message_applied', :locals => {:ma => ma} %>
<%= render :partial => 'users/user_message_applied', :locals => {:ma => ma.message} %>
<% end %>
<ul class="pages" style="width: auto;display: table;margin-left: auto;margin-right: auto; padding-top: 10px">

View File

@ -1,4 +1,4 @@
<% if ma.class == CourseMessage %>
<% if ma.class == CourseMessage && ma.course.try(:is_delete) == 0 %>
<% if ma.course_message_type == "News" && ma.course_message %>
<ul class="homepageNewsList fl">
<div class="longMessageWidth">

View File

@ -7,5 +7,5 @@
</span>
</div>
<div class="resources">
<%= render :partial => 'users/new_user_message', :locals => { :message_alls => @message_alls } %>
<%= render :partial => 'users/new_user_message' %>
</div>