Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_forum
cxt 6 years ago
commit c746667796

@ -7,9 +7,18 @@ class DiscussesController < ApplicationController
page = params[:page].to_i
offset = page * LIMIT
# 总数,分页使用
if current_user.admin?
@disscuss_count = Discuss.where(:dis_id => @container.id, :dis_type => @container.class.to_s, :root_id => nil).count
@discusses = Discuss.limit(LIMIT).where(:dis_id => @container.id, :dis_type => @container.class.to_s, :root_id => nil).
includes(:user, :praise_tread).offset(offset)
@discusses = Discuss.limit(LIMIT).where(:dis_id => dis_id, :dis_type => dis_type,
:root_id => nil).includes(:user, :praise_tread).offset(offset)
else
disscusses = Discuss.where("dis_id = :dis_id and dis_type = :dis_type and root_id is null and
(hidden = :hidden or user_id = :user_id)",
{dis_id: dis_id, dis_type: dis_type, hidden: false, user_id: current_user.id})
@disscuss_count = disscusses.count
@discusses = disscusses.limit(LIMIT).includes(:user, :praise_tread).offset(offset)
end
@current_user = current_user
end
@ -23,8 +32,10 @@ class DiscussesController < ApplicationController
def create
begin
@discuss = Discuss.create!(:dis_id => params[:container_id], :dis_type => params[:container_type], :content => params[:content].gsub("&nbsp\;", "").strip,
:user_id => current_user.id, :praise_count => 0, :position => params[:position], :challenge_id => params[:challenge_id])
@discuss = Discuss.create!(:dis_id => params[:container_id], :dis_type => params[:container_type],
:content => params[:content].gsub("&nbsp\;", "").strip, :user_id => current_user.id,
:praise_count => 0, :position => params[:position], :challenge_id => params[:challenge_id],
:hidden => current_user.admin?)
rescue Exception => e
uid_logger_error("create discuss failed : #{e.message}")
raise Educoder::TipException.new("评论异常")

@ -36,7 +36,7 @@ class Discuss < ApplicationRecord
def contents(shixun, user)
return content unless hidden?
shixun.has_manager?(user) ? content : '违规评论已被屏蔽!'
shixun.has_manager?(user) ? content : ''
end
private

Loading…
Cancel
Save