|
|
@ -125,9 +125,21 @@ class ShixunsService
|
|
|
|
praise_count = d.praise_tread.where(:praise_or_tread => 1).count
|
|
|
|
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
|
|
|
|
user_praise= d.praise_tread.select{|pt| pt.user_id == current_user.id}.length > 0 ? true : false
|
|
|
|
# 实训(TPM)的管理员可以看到隐藏的评论
|
|
|
|
# 实训(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,
|
|
|
|
manager = current_user.manager_of_shixun?(dis, current_user)
|
|
|
|
:image_url => url_to_avatar(d.user), :username => d.username, :user_login => d.user.try(:login), :shixun_id => dis.id, :hidden => d.hidden,
|
|
|
|
game_url =
|
|
|
|
:manager => current_user.manager_of_shixun?(dis, current_user), :praise_count => praise_count, :user_praise => user_praise, :admin => current_user.admin?}
|
|
|
|
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取
|
|
|
|
# 现在没有二级回复,所以查询的时候直接从root_id取
|
|
|
|
children = Discuss.where(:root_id => d.id).includes(:user).reorder("created_at asc")
|
|
|
|
children = Discuss.where(:root_id => d.id).includes(:user).reorder("created_at asc")
|
|
|
|