daiao 6 years ago
parent 49cf70f38f
commit a71e82ae78

@ -125,9 +125,21 @@ class ShixunsService
praise_count = d.praise_tread.where(:praise_or_tread => 1).count
user_praise= d.praise_tread.select{|pt| pt.user_id == current_user.id}.length > 0 ? true : false
# 实训TPM的管理员可以看到隐藏的评论
parents = {:id => d.id, :content => d.content, :time => time_from_now(d.created_at), :position => d.position, :user_id => d.user.try(:id), :reward => d.reward,
:image_url => url_to_avatar(d.user), :username => d.username, :user_login => d.user.try(:login), :shixun_id => dis.id, :hidden => d.hidden,
:manager => current_user.manager_of_shixun?(dis, current_user), :praise_count => praise_count, :user_praise => user_praise, :admin => current_user.admin?}
manager = current_user.manager_of_shixun?(dis, current_user)
game_url =
if manager
challenge_id = dis.challenges.where(position: d.position).pluck(:id).first
game_identifier = Game.where(user_id: current_user,
challenge_id: challenge_id).pluck(:identifier).first
"/tasks/#{game_identifier}"
else
""
end
parents = {:id => d.id, :content => d.content, :time => time_from_now(d.created_at), :position => d.position,
:user_id => d.user.try(:id), :reward => d.reward, :image_url => url_to_avatar(d.user),
:username => d.username, :user_login => d.user.try(:login), :shixun_id => dis.id, :hidden => d.hidden,
:manager => manager, :praise_count => praise_count, game_url: game_url,
:user_praise => user_praise, :admin => current_user.admin?}
# 现在没有二级回复所以查询的时候直接从root_id取
children = Discuss.where(:root_id => d.id).includes(:user).reorder("created_at asc")

Loading…
Cancel
Save