From a9fb270b542ea430d1808b695db68b4094fdae4d Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 9 Mar 2017 16:42:30 +0800 Subject: [PATCH] =?UTF-8?q?=E9=97=AE=E5=90=A7=E7=9A=84=E5=B8=96=E5=AD=90?= =?UTF-8?q?=EF=BC=8C=E5=90=A7=E4=B8=BB=E5=92=8C=E8=B6=85=E7=BA=A7=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=91=98=E6=9C=89=E7=BD=AE=E9=A1=B6=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/forums_controller.rb | 10 +++++----- app/controllers/memos_controller.rb | 10 ++++++++++ app/views/boards/_course_new.html.erb | 14 +++++++------- app/views/forums/_show_topics.html.erb | 7 +++++-- app/views/memos/_form.html.erb | 11 ++++++++++- app/views/memos/show.html.erb | 5 +++++ config/routes.rb | 3 +++ public/stylesheets/css/public.css | 2 +- 8 files changed, 46 insertions(+), 16 deletions(-) diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index 0f5a55ab9..f15114d20 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -121,7 +121,7 @@ class ForumsController < ApplicationController order = "" @order_str = "" if(params[:reorder_complex]) - order = " last_replies_memos.created_at #{params[:reorder_complex]}, #{Memo.table_name}.created_at #{params[:reorder_complex]}" + order = "last_replies_memos.created_at #{params[:reorder_complex]}, #{Memo.table_name}.created_at #{params[:reorder_complex]}" @order_str = "reorder_complex="+params[:reorder_complex] elsif(params[:reorder_popu]) order = "replies_count #{params[:reorder_popu]}" @@ -166,16 +166,16 @@ class ForumsController < ApplicationController order = "" @order_str = "" if(params[:reorder_complex]) - order = " last_replies_memos.created_at #{params[:reorder_complex]}, #{Memo.table_name}.created_at #{params[:reorder_complex]}" + order = "#{Memo.table_name}.sticky desc, last_replies_memos.created_at #{params[:reorder_complex]}, #{Memo.table_name}.created_at #{params[:reorder_complex]}" @order_str = "reorder_complex="+params[:reorder_complex] elsif(params[:reorder_popu]) - order = "replies_count #{params[:reorder_popu]}" + order = "#{Memo.table_name}.sticky desc, replies_count #{params[:reorder_popu]}" @order_str = "reorder_popu="+params[:reorder_popu] elsif(params[:reorder_time]) - order = "#{Memo.table_name}.updated_at #{params[:reorder_time]}" + order = "#{Memo.table_name}.sticky desc, #{Memo.table_name}.updated_at #{params[:reorder_time]}" @order_str = "reorder_time="+params[:reorder_time] else - order = "#{Memo.table_name}.updated_at desc" + order = "#{Memo.table_name}.sticky desc, #{Memo.table_name}.updated_at desc" @order_str = "reorder_time=desc" end @memo = Memo.new(:forum => @forum) diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 8e84f2659..eb31cf13f 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -50,6 +50,8 @@ class MemosController < ApplicationController @memo = Memo.new(params[:memo]) @memo.forum_id = @forum.id @memo.author_id = User.current.id + # 问吧置顶sticky:1 置顶;0不置顶 + @memo.sticky = params[:memo][:sticky].to_i if params[:memo][:parent_id] @memo.root_id = (Memo.find params[:memo][:parent_id]).root_id.nil? ? params[:memo][:parent_id].to_i : (Memo.find params[:memo][:parent_id]).root_id @@ -189,6 +191,14 @@ class MemosController < ApplicationController end end + #置顶功能 + def change_sticky + @memo.sticky ? @memo.update_attribute(:sticky, false) : @memo.update_attribute(:sticky, true) + respond_to do |format| + format.html { redirect_to forum_memo_path(@memo.forum, @memo) } + end + end + private def find_memo diff --git a/app/views/boards/_course_new.html.erb b/app/views/boards/_course_new.html.erb index 774d1c100..21764a055 100644 --- a/app/views/boards/_course_new.html.erb +++ b/app/views/boards/_course_new.html.erb @@ -122,18 +122,18 @@
- +

-
- <%=topic.subject%> +
+ <%= topic.subject %> + <% if topic.sticky && !params[:id].blank? %> + + <% end %>
diff --git a/app/views/memos/_form.html.erb b/app/views/memos/_form.html.erb index bab98541b..084bc5bc8 100644 --- a/app/views/memos/_form.html.erb +++ b/app/views/memos/_form.html.erb @@ -6,7 +6,16 @@
  • - <%= f.text_field :subject, :no_label => true, :id => "memo_subject", :maxlength => "50", :style => "width:708px", :onblur => "check_memo_name();", :onfocus => "$('#memo_name_error_tips').hide();", :onmouseover => "this.style.borderColor='#d9d9d9'", :class => "wenba-tiwen-input", :placeholder => "请输入标题" %> + <%= f.text_field :subject, + :no_label => true, + :id => "memo_subject", + :maxlength => "50", + :style => "width:708px", + :onblur => "check_memo_name();", + :onfocus => "$('#memo_name_error_tips').hide();", + :onmouseover => "this.style.borderColor='#d9d9d9'", + :class => "wenba-tiwen-input", + :placeholder => "请输入标题" %>