个人主页的一些优化
This commit is contained in:
parent
4be495a7b0
commit
be531d6abd
|
@ -1994,25 +1994,19 @@ end
|
|||
# 系统消息总显示在最前面,显示周期30天
|
||||
@system_messages = SystemMessage.where("created_at > ?", Time.now - 86400 * 30)
|
||||
# 自己的主页显示消息
|
||||
@message_alls = []
|
||||
messages_all = MessageAll.where(:user_id => @user.id)
|
||||
@message_count = messages_all.count
|
||||
# REDO:已删除的内容应该在页面中显示不点击
|
||||
@message_all_pages = Paginator.new @message_count, per_page_option, params['page']
|
||||
@message_alls = messages_all.includes(:message).
|
||||
limit(@message_all_pages.per_page).
|
||||
offset(@message_all_pages.offset).
|
||||
reorder("#{MessageAll.table_name}.created_at desc")
|
||||
|
||||
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)
|
||||
if (message_all.message_type =="SystemMessage" && !many_days_ago(mess.created_at, 30))
|
||||
next
|
||||
else
|
||||
@message_alls << mess
|
||||
end
|
||||
end
|
||||
end
|
||||
@message_count = @message_alls.count
|
||||
@message_alls = paginateHelper @message_alls, 20
|
||||
@unsolved_issues_count = Issue.where(:assigned_to_id => @user.id, :status_id => [1, 2, 4, 6]).includes(:author, :project).count
|
||||
# 用户待完成的作业
|
||||
my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")"
|
||||
my_course_ids = StudentsForCourse.includes(:course).where("student_id = #{@user.id} and courses.is_delete = 0").blank? ? "(-1)" : "(" + StudentsForCourse.includes(:course).
|
||||
where("student_id = #{@user.id} and courses.is_delete = 0").map{|sc| sc.course_id}.join(",") + ")"
|
||||
homeworks = HomeworkCommon.where("course_id in #{my_course_ids} and publish_time <= '#{Date.today}'")
|
||||
homework_ids = homeworks.blank? ? "(-1)" : "(" + homeworks.map{|homework| homework.id}.join(",") + ")"
|
||||
student_works = StudentWork.where("user_id = #{@user.id} and homework_common_id in #{homework_ids} and work_status != 0")
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<%= render :partial => 'users/user_message_system' %>
|
||||
|
||||
<% message_alls.each do |ma| %>
|
||||
<% ma = ma.try(:message) %>
|
||||
<% if ma.class == AtMessage && ma.at_valid? && ma.at_message %>
|
||||
<%= render :partial => 'users/user_at_message', :locals => {:ma => ma} %>
|
||||
<% end %>
|
||||
|
@ -42,7 +43,7 @@
|
|||
<% end %>
|
||||
|
||||
<ul class="pages" style="width: auto;display: table;margin-left: auto;margin-right: auto; padding-top: 10px">
|
||||
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %>
|
||||
<%= pagination_links_full @message_all_pages, @messages_count, :per_page_links => false, :remote => true, :flag => true, :is_new => true %>
|
||||
</ul>
|
||||
<script>
|
||||
$(function(){
|
||||
|
|
Loading…
Reference in New Issue