diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 1c0fa35a4..87d68f3c4 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -21,7 +21,7 @@ class BoardsController < ApplicationController before_filter :find_project_by_project_id, :find_board_if_available, :except => [:join_to_org_subfields] before_filter :authorize, :except => [:new, :show, :create, :index, :join_to_org_subfields, :update_position, :update_name, :update_boards_position, :update_boards_name] accept_rss_auth :index, :show - + helper :sort include SortHelper @@ -146,7 +146,7 @@ class BoardsController < ApplicationController if (@board) @topic_count = @board.topics.count(); @topic_pages = 0 #(params[:page] ? params[:page].to_i + 1 : 0) *10 - @topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on) #{sort_type}").offset(@topic_pages).includes(:last_reply).preload(:author, {:last_reply => :author}).all(); + @topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, COALESCE(last_replies_messages.created_on, #{Message.table_name}.updated_on) #{sort_type}").offset(@topic_pages).includes(:last_reply).preload(:author, {:last_reply => :author}).all(); else @board = @contest.boards.build @board.name = " #{l(:label_board_contest) }"#self.name @@ -156,7 +156,7 @@ class BoardsController < ApplicationController if @board.save @topic_count = @board.topics.count(); @topic_pages = 0 #(params[:page] ? params[:page].to_i + 1 : 0) *10 - @topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, COALESCE(last_replies_messages.created_on, #{Message.table_name}.created_on) #{sort_type}").offset(@topic_pages).includes(:last_reply).preload(:author, {:last_reply => :author}).all(); + @topics = @board.topics.reorder("#{Message.table_name}.sticky DESC, COALESCE(last_replies_messages.created_on, #{Message.table_name}.updated_on) #{sort_type}").offset(@topic_pages).includes(:last_reply).preload(:author, {:last_reply => :author}).all(); else @topics = [] end @@ -183,7 +183,7 @@ class BoardsController < ApplicationController end #分页 - @limit = 1 + @limit = 10 @is_remote = true @atta_count = @topics.count @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 @@ -370,16 +370,16 @@ class BoardsController < ApplicationController end def update_boards_name - @board.update_attribute("name", params[:name]) - @board.update_attribute("description", params[:name]) + @board.update_attribute("name", params[:name]) + @board.update_attribute("description", params[:name]) - @course_board = @course.boards.where("parent_id is NULL").first - @board = @course_board.children.order("position asc") - @board_count = @board.count + @course_board = @course.boards.where("parent_id is NULL").first + @board = @course_board.children.order("position asc") + @board_count = @board.count - respond_to do |format| - format.js - end + respond_to do |format| + format.js + end end def join_to_org_subfields @@ -392,7 +392,7 @@ class BoardsController < ApplicationController end end -private + private def redirect_to_settings_in_projects redirect_to settings_project_url(@project, :tab => 'boards') end diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index c9f826c57..aab0f243b 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -61,16 +61,16 @@ class MessagesController < ApplicationController course_messages = CourseMessage.where("user_id =? and course_message_type =? and course_message_id =? and course_id =? and viewed =?", User.current.id, 'Message', @topic.id, @course.id, 0) course_messages.update_all(:viewed => true) #@replies = @topic.children. - #includes(:author, :attachments, :praise_tread_cache, {:board => :project}). - #reorder("#{Message.table_name}.created_on DESC"). - #limit(@reply_pages.per_page). - #offset(@reply_pages.offset). - #all + #includes(:author, :attachments, :praise_tread_cache, {:board => :project}). + #reorder("#{Message.table_name}.created_on DESC"). + #limit(@reply_pages.per_page). + #offset(@reply_pages.offset). + #all #@replies = paginateHelper messages_replies,10 # 班级帖子回复消息设为已读 @replies.each do |comment| - course_message = CourseMessage.where(:course_message_type => 'Message', :course_message_id => comment.id, :user_id => User.current.id, :viewed => 0) - course_message.update_all(:viewed => 1) + course_message = CourseMessage.where(:course_message_type => 'Message', :course_message_id => comment.id, :user_id => User.current.id, :viewed => 0) + course_message.update_all(:viewed => 1) end @left_nav_type = 2 respond_to do |format| @@ -133,6 +133,10 @@ class MessagesController < ApplicationController # Create a new topic def new + + end + + def create if User.current.logged? @message = Message.new @message.author = User.current @@ -437,8 +441,8 @@ class MessagesController < ApplicationController :created_on => Time.now, :updated_on => Time.now, :locked => @message.locked, :sticky => @message.sticky) @message.attachments.each do |attach| mes.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, - :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, - :is_public => attach.is_public, :quotes => 0) + :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, + :is_public => attach.is_public, :quotes => 0) end # OrgSubfieldMessage.create(:org_subfield_id => field_id.to_i, :message_id => mes.id, :message_type => type) # org_acts = OrgActivity.where("container_type='OrgSubfield' and container_id=? and org_act_type='Message' and org_act_id=?", field_id.to_i, @message.id) diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 4ca7f618c..6ddcfcede 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -1,60 +1,58 @@ - - - - <% if false %> - + <% if @is_new%> + $(function(){ + $("#message_subject").focus(); + }); + <%end%> + -
- <%= link_to "时间", {:controller => 'boards', :action => 'index', :board_id =>@board.id, :type => @type, :sort => @b_sort, :order => 1 }, :class => "link-color-grey fr mr15", :remote => true %> - <% if @type.to_i == 1 %> - <%= link_to "", {:controller => 'boards', :action => 'index', :board_id =>@board.id, :type => @type, :sort => @b_sort, :order => 1 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %> - <% end %> - | - <%= link_to "人气", {:controller => 'boards', :action => 'index', :board_id =>@board.id, :type => @type, :sort => @b_sort, :order => 2 }, :class => "link-color-grey fr", :remote => true %> - <% if @type.to_i == 2 %> - <%= link_to "", {:controller => 'boards', :action => 'index', :board_id =>@board.id, :type => @type, :sort => @b_sort, :order => 2 }, :class => "#{@b_sort.to_i == 1 ? 'sortupbtn' : 'sortdownbtn'} ", :remote => true %> - <% end %> +
+ <%= link_to "热度排序", {:controller => 'boards', :action => 'index', :board_id =>@board.id, :type => @type, :sort => @b_sort, :order => 2}, :class => "#{@order.to_i == 2 ? 'link-color-green' : 'link-color-grey'} fr mr15", :remote => true %> + | + <%= link_to "时间排序", {:controller => 'boards', :action => 'index', :board_id =>@board.id, :type => @type, :sort => @b_sort, :order => 1}, :class => "#{@order.to_i == 1 ? 'link-color-green' : 'link-color-grey'} fr", :remote => true %> @@ -28,16 +22,17 @@ <%= link_to activity.parent.subject.to_s.html_safe, User.current.logged? ? board_message_path(activity.board_id, activity) : signin_url_without_domain, :class => "panel-list-title hide fl" %> <% end %> - - <% if activity.sticky == 1 %> - 顶 - <% end %> - + + <% if activity.sticky == 1 %> + 顶 + <% end %> +
-+
+ <%= %> - 发表于<%= time_from_now activity.created_on %> - 更新于<%= time_from_now activity.updated_on %> + 发表于<%= time_from_now activity.created_on %> + 更新于<%= time_from_now activity.updated_on %> <%= link_to activity.author.show_real_name, user_path(activity.author), :class => "panel-name-small hide fl mr15 ml10" %> <% count = Message.where("root_id = #{activity.id}").count %> <% if count >0 %> @@ -62,24 +57,17 @@