Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop

This commit is contained in:
daiao 2016-12-20 11:04:39 +08:00
commit c2924e06e6
7 changed files with 56 additions and 25 deletions

View File

@ -33,12 +33,18 @@ class HomeworkCommonController < ApplicationController
@homeworks = paginateHelper @homework_commons,10
#设置at已读
@homeworks.each do |homework|
# homework.journals_for_messages.each do |j|
# User.current.at_messages.unviewed('JournalsForMessage', j.id).each {|x| x.viewed!}
# end
homework.delay.set_jour_viewed
ids = @homeworks.inject([]) do |ids, homework|
jids = homework.journals_for_messages.map(&:id)
jids ? ids + jids : ids
# homework.delay.set_jour_viewed
end
unless ids.empty?
User.current.at_messages.where(viewed: false,
at_message_type: 'JournalsForMessage',
at_message_id: ids).update_all(viewed: true)
end
@left_nav_type = 3
respond_to do |format|
format.js

View File

@ -328,17 +328,28 @@ class Message < ActiveRecord::Base
def delay_message_send
if self.course
if self.parent_id.nil? # 发帖
self.delay.contain_messages_message
dm = []
self.course.members.includes(:user).each do |m|
if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息
dm << {course_message_type:'Message',course_message_id:self.id, :user_id => m.user_id,
:course_id => self.board.course_id, :viewed => false}
if dm.size >= 30
self.delay.contain_messages_message(dm)
dm.clear
end
end
end
unless dm.empty?
self.delay.contain_messages_message(dm)
end
end
end
end
def contain_messages_message
self.course.members.includes(:user).each do |m|
if self.author.allowed_to?(:as_teacher, self.course) && m.user_id != self.author_id # 老师 自己的帖子不给自己发送消息
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false)
end
end
def contain_messages_message vs
CourseMessage.create(vs)
end
#更新用户分数 -by zjc

View File

@ -208,16 +208,29 @@ class News < ActiveRecord::Base
def delay_news_send
if self.course
self.delay.contain_news_message
vs = []
self.course.members.each do | m|
if m.user_id != self.author_id
vs << {course_message_type:'News',course_message_id:self.id, :user_id => m.user_id,
:course_id => self.course_id, :viewed => false}
if vs.size >= 30
self.delay.contain_news_message(vs)
vs.clear
end
end
end
unless vs.empty?
self.delay.contain_news_message(vs)
end
end
end
def contain_news_message
self.course.members.each do |m|
if m.user_id != self.author_id
self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false)
end
end
def contain_news_message(vs)
CourseMessage.create(vs)
end
# Time 2015-03-31 13:50:54

View File

@ -167,7 +167,7 @@
<ul>
<li class="home-user-leftnav-li icons-class clear">
<%= link_to user_course_count > 0 ? "课程<span class='issues_nav_tag mr10 fr' style='line-height:18px;margin-top: 9px;'>#{user_course_count}</span>".html_safe : "课程",
{:controller => "users", :action => "user_courselist", :id => @user}, :id => "user_course_list", :target => "_blank" %>
user_course_community_path(User.current), :id => "user_course_list", :target => "_blank" %>
<!-- <div class="user_navmore_box" >
<ul>
<li class="user_navmore_icons">
@ -208,7 +208,7 @@
<ul>
<li class="home-user-leftnav-li icons-project clear">
<%= link_to user_project_count > 0 ? "项目<span class='issues_nav_tag mr10 fr' style='line-height:18px;margin-top: 9px;'>#{user_project_count}</span>".html_safe : "项目",
{:controller => "users", :action => "user_projectlist", :id => @user}, :id => 'user_project_list', :target => "_blank" %>
user_project_community_path(User.current), :id => 'user_project_list', :target => "_blank" %>
<!-- <div class="user_navmore_box" >
<ul>
<li class="user_navmore_icons">
@ -246,11 +246,11 @@
<ul>
<li class="home-user-leftnav-li icons-class clear">
<%= link_to user_course_count > 0 ? "课程<span class='issues_nav_tag ml140'>#{user_course_count}</span>".html_safe : "课程",
{:controller => "users", :action => "user_courselist", :id => @user}, :id => "user_course_list", :class => "fl", :target => "_blank" %>
user_course_community_path(@user), :id => "user_course_list", :class => "fl", :target => "_blank" %>
</li>
<li class="home-user-leftnav-li icons-project clear">
<%= link_to user_project_count > 0 ? "项目<span class='issues_nav_tag ml140'>#{user_project_count}</span>".html_safe : "项目",
{:controller => "users", :action => "user_projectlist", :id => @user}, :id => 'user_project_list', :class => "fl", :target => "_blank" %>
user_project_community_path(@user), :id => 'user_project_list', :class => "fl", :target => "_blank" %>
</li>
</ul>
</div>

View File

@ -1,5 +1,6 @@
hideModal();
<% if params[:status].to_i == 3 %>
var num = $("#work_num_<%= @work.id%>").html();
<% score_open = @is_teacher || @homework.score_open == 1 || @work.user == User.current %>
<% if @is_teacher %>
<% if @homework.homework_type == 3 %>

View File

@ -50,7 +50,7 @@
</li>
<li class="c_grey">
<% if !activity.assigned_to_id.nil? && activity.assigned_to_id != 0 %>
<% if activity.try(:assigned_to).try(:realname).empty? %>
<% if activity.try(:assigned_to).try(:realname).blank? %>
<%= link_to activity.assigned_to, user_path(activity.assigned_to_id)%>
<% else %>
<%= link_to activity.try(:assigned_to).try(:realname), user_path(activity.assigned_to_id)%>

View File

@ -213,7 +213,7 @@
</ul>
<% end %>
<% if ma.forge_message_type == "PullRequest" %>
<% if ma.forge_message_type == "PullRequest" && PullRequest.where(:pull_request_id => ma.forge_message_id).count != 0 %>
<ul class="homepageNewsList fl">
<div class="longMessageWidth">
<li class="homepageNewsPortrait fl">