diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 337f951aa..4cd1b26c7 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -137,17 +137,17 @@ class ForumsController < ApplicationController @order_str = "reorder_time=desc" end =end - @memo = Memo.new(:forum => @forum) + #@memo = Memo.new(:forum => @forum) @memos = Memo.where("parent_id is null") @topic_count = @memos.count - @topic_pages = Paginator.new @topic_count, per_page_option, params['page'] - @memos = @memos.includes(:last_reply). - limit(@topic_pages.per_page). - offset(@topic_pages.offset). - reorder(order). - preload(:author, {:last_reply => :author}). - all - @forums = Forum.find_by_sql("SELECT *,topic_count + memo_count tm FROM `forums` order by tm desc;") + + @limit = 20 + @is_remote = true + @topic_pages = Paginator.new @topic_count, @limit, params['page'] || 1 + @memos = @memos.includes(:last_reply).reorder(order) + @memos = paginateHelper @memos, @limit + + #@forums = Forum.find_by_sql("SELECT *,topic_count + memo_count tm FROM `forums` order by tm desc;") @my_forums_count = Memo.where("author_id =? and parent_id is null", User.current.id).count @my_memos_count = Memo.where("author_id =? and parent_id is not null", User.current.id).count @errors = params[:errors] diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 7e9662563..b96c1774f 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -165,10 +165,9 @@ class MemosController < ApplicationController @flag = false respond_to do |format| - if( #@memo.update_column(:subject, params[:memo][:subject]) && - @memo.update_column(:content, params[:memo][:content]) && - @memo.update_column(:sticky, params[:memo][:sticky]) && - @memo.update_column(:lock, params[:memo][:lock]) && + if( @memo.update_column(:content, params[:memo][:content]) && + @memo.update_column(:sticky, params[:memo][:sticky].to_i) && + @memo.update_column(:lock, params[:memo][:lock].to_i) && @memo.update_column(:subject,params[:memo][:subject]) && @memo.update_column(:updated_at,Time.now)) @memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads])) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 77b25309f..319604f32 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -769,13 +769,13 @@ class ShixunsController < ApplicationController end def shixun_discuss - @discusses = @shixun.discusses.where(:parent_id => nil).reorder("created_at desc") + @discusses = @shixun.discusses.reorder("created_at desc") @discusses_count = @discusses.count - @limit = 15 - @is_remote = true - @discusses_pages = Paginator.new @discusses_count, @limit, params['page'] || 1 - @offset ||= @discusses_pages.offset - @discusses = paginateHelper @discusses, @limit + #@limit = 15 + #@is_remote = true + #@discusses_pages = Paginator.new @discusses_count, @limit, params['page'] || 1 + # @offset ||= @discusses_pages.offset + #@discusses = paginateHelper @discusses, @limit #@game_challenge = params[:challenge_id].blank? ? Challenge.find(@discusses.challenge_id) : Challenge.find(params[:challenge_id]) @game_challenge = Challenge.find(params[:challenge_id].to_i) end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 1f545fd9e..2a73e648e 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -326,6 +326,11 @@ class UsersController < ApplicationController @user_activity_id = params[:user_activity_id] @activity_id = params[:activity_id] @type = 'Memo' + when 'Challenge' + @reply = Discuss.find params[:reply_id] + @user_activity_id = params[:user_activity_id] + @activity_id = params[:activity_id] + @type = 'Challenge' end respond_to do |format| format.js @@ -452,6 +457,20 @@ class UsersController < ApplicationController comment.subject = "#{@root.subject}" comment.root_id = reply.root_id reply.children << comment + when 'Challenge' + @game_challenge = Challenge.where(:id => reply.challenge_id).first + @root = reply.root + comment = Discuss.new + comment.user_id = User.current.id + comment.content = params[:reply_message] + comment.root_id = reply.root_id + comment.challenge_id = reply.challenge_id + comment.dis_type = "Shixun" + comment.dis_id = @game_challenge.shixun.try(:id) + comment.praise_count = 0 + reply.children << comment + @discusses = @game_challenge.shixun.discusses.reorder("created_at desc") + @discusses_count = @discusses.count end update_course_activity(@root.class.to_s,@root.id) update_user_activity(@root.class.to_s,@root.id) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9cfcfd972..78c0920a3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2099,7 +2099,7 @@ module ApplicationHelper elsif @organization title << (@organization.name.nil? ? "创新源于实践" : @organization.name) elsif @forum || params[:controller] == "forums" - title << "问吧" + title << "论坛" elsif @my_syllabuses title << "我的课堂" elsif @user @@ -4550,6 +4550,8 @@ def get_reply_by_type type, reply_id reply = JournalsForMessage.find reply_id when 'Memo' reply = Memo.find reply_id + when 'Challenge' + reply = Discuss.find reply_id end reply end diff --git a/app/models/discuss.rb b/app/models/discuss.rb index effd1cb26..af5f96601 100644 --- a/app/models/discuss.rb +++ b/app/models/discuss.rb @@ -7,4 +7,12 @@ class Discuss < ActiveRecord::Base acts_as_tree :foreign_key => 'parent_id' belongs_to :dis, :polymorphic => true validates_presence_of :dis, :user, :content + + def creator_user + User.find(self.user_id) + end + + def content_detail + self.content + end end diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index 7aa89bdab..a3cbaa03e 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -41,7 +41,7 @@ <% end %>

-

<%= memo.content.html_safe %>

+
<%= memo.content.html_safe %>
<%= User.find(memo.author_id).try(:show_name) %> <%= time_from_now memo.updated_at %> @@ -86,6 +86,12 @@
+ + + + + + <% if false %> <%= content_for(:header_tags) do %> <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> diff --git a/app/views/games/_game_show.html.erb b/app/views/games/_game_show.html.erb index ea31adfe5..e0595ab34 100644 --- a/app/views/games/_game_show.html.erb +++ b/app/views/games/_game_show.html.erb @@ -81,7 +81,7 @@