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%> + -
-
-
- <%= @board.parent_id.nil? ? "班级讨论区" : "#{@board.name}" %> +
+
+
+ <%= @board.parent_id.nil? ? "班级讨论区" : "#{@board.name}" %> +
+ + <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@board.course)) %> + <% if is_teacher %> + <%= link_to "添加子栏目", settings_course_path(@board.course.id,'boards'), :class => "link-blue fr mt5" %> + <% end %> +
+
+ <% if User.current.logged? %> + <%= labelled_form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, + :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> + <%= render :partial => 'course_new', :locals => {:f => f, :topic => @message, :edit_mode => false, :course => @board.course} %> + <% end %> + <% end %> +
+ <%= render :partial=> 'course_show_detail',:locals =>{:topics => @topics, :page => 0} %>
- - <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@board.course)) %> - <% if is_teacher %> - <%= link_to "添加子栏目", settings_course_path(@board.course.id,'boards'), :class => "link-blue fr mt5" %> - <% end %> -
-
- <% if User.current.logged? %> - <%= labelled_form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, - :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> - <%= render :partial => 'course_new', :locals => {:f => f, :topic => @message, :edit_mode => false, :course => @board.course} %> - <% end %> - <% end %> -
- <%= render :partial=> 'course_show_detail',:locals =>{:topics => @topics, :page => 0} %> -
<% end %> -
-
-

全部帖子

<%= @topics.count %> - 我要发布 -
-
- <%= render :partial => "course_show_detail", :locals => {:topics => @topics, :page => 0} %> +
+
+
+

全部帖子

<%= @topics.count %> + 我要发布 +
+
+ <%= render :partial => "course_show_detail", :locals => {:topics => @topics, :page => 0} %> +
\ No newline at end of file diff --git a/app/views/boards/_course_show_detail.html.erb b/app/views/boards/_course_show_detail.html.erb index 39df6331e..5930d76df 100644 --- a/app/views/boards/_course_show_detail.html.erb +++ b/app/views/boards/_course_show_detail.html.erb @@ -3,8 +3,8 @@ <%= javascript_include_tag "create_kindeditor" %> <% end %> -<% if @topics %> - <%= render :partial => 'users/course_boardlist', :locals => {:topics => @topics ? @topics: topics , :is_course => 1, :is_board=>1} %> +<% if @topics.count > 0 %> + <%= render :partial => 'users/course_boardlist', :locals => {:topics => @topics, :is_course => 1, :is_board=>1} %> <% else %> <%= render :partial => "welcome/no_data" %> <% end %> \ No newline at end of file diff --git a/app/views/users/_course_boardlist.html.erb b/app/views/users/_course_boardlist.html.erb index 8bc33e545..51287f7df 100644 --- a/app/views/users/_course_boardlist.html.erb +++ b/app/views/users/_course_boardlist.html.erb @@ -1,13 +1,7 @@ -

- <%= 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 %> +

-

+

+ <%= %> <%= activity.author.try(:identity) %> - 发表于<%= 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 @@

- - - - - - - - - - + + + + + + + + + + -
- - - - - - - + \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 63d99e310..713ea07b8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -729,7 +729,7 @@ RedmineApp::Application.routes.draw do match 'users/:id/leave_email_activation_message', :to => 'words#leave_email_activation_message', :via => :post, :as => "leave_email_activation_message" # boards - match 'boards/:board_id/topics/new', :to => 'messages#new', :via => [:get, :post], :as => 'new_board_message' + match 'boards/:board_id/topics/new', :to => 'messages#new', :via => :get, :as => 'new_board_message' match 'boards/:id/join_to_org_subfields', :to => 'boards#join_to_org_subfields' match 'boards/:id/update_position', :to => 'boards#update_position', :via => :post match 'boards/:id/update_boards_position', :to => 'boards#update_boards_position', :via => :post