diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index d5fc1770c..cd51d2e58 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -52,7 +52,7 @@ class ForumsController < ApplicationController def index @offset, @limit = api_offset_and_limit({:limit => 10}) - @forums_all = Forum.where('1=1') + @forums_all = Forum.reorder("sticky DESC") @forums_count = @forums_all.count @forums_pages = Paginator.new @forums_count, @limit, params['page'] @@ -208,6 +208,8 @@ class ForumsController < ApplicationController end end + + private diff --git a/app/models/forum.rb b/app/models/forum.rb index 24b5b15e0..e0592723e 100644 --- a/app/models/forum.rb +++ b/app/models/forum.rb @@ -8,7 +8,9 @@ class Forum < ActiveRecord::Base 'topic_count', 'memo_count', 'last_memo_id', - 'creator_id' + 'creator_id', + 'sticky', + 'locked' validates_presence_of :name, :creator_id, :description validates_length_of :name, maximum: 50 #validates_length_of :description, maximum: 255 diff --git a/app/views/forums/_form.html.erb b/app/views/forums/_form.html.erb index 556238732..9b3519b05 100644 --- a/app/views/forums/_form.html.erb +++ b/app/views/forums/_form.html.erb @@ -17,6 +17,18 @@
<%= f.text_field :name, :required => true, :style => 'width: 100%;', :class => 'create-share' %>
+
+ <% if User.current.logged? && User.current.admin? %> + <% if @forum.safe_attribute? 'sticky' %> + <%= f.check_box :sticky %> + <%= label_tag 'message_sticky', l(:label_board_sticky) %> + <% end %> + <% if @forum.safe_attribute? 'locked' %> + <%= f.check_box :locked %> + <%= label_tag 'message_locked', l(:label_board_locked) %> + <% end %> + <% end %> +

diff --git a/app/views/forums/_forum_list.html.erb b/app/views/forums/_forum_list.html.erb index 9d0eba923..874dc355f 100644 --- a/app/views/forums/_forum_list.html.erb +++ b/app/views/forums/_forum_list.html.erb @@ -7,9 +7,14 @@ <%= forum.creator.nil? ? (link_to image_tag(url_to_avatar(forum.creator), :class => "avatar")) : (link_to image_tag(url_to_avatar(forum.creator), :class => "avatar"), user_path(forum.creator)) %>

-

<%= link_to h(forum.name), forum_path(forum) %>

-

<%= textAreailizable forum.description%>

-

<%= authoring forum.created_at, forum.creator %>

+ + + + +
+

<%= link_to h(forum.name), forum_path(forum) %>

<%= textAreailizable forum.description%>

<%= authoring forum.created_at, forum.creator %>

+
<%= link_to (forum.memo_count), forum_path(forum) %><%= link_to (forum.topic_count), forum_path(forum) %>
回答帖子
diff --git a/app/views/forums/index.html.erb b/app/views/forums/index.html.erb index fa6e74ccd..31d00891e 100644 --- a/app/views/forums/index.html.erb +++ b/app/views/forums/index.html.erb @@ -11,7 +11,8 @@ <% if User.current.logged? %> <%= link_to( l(:label_forum_new), new_forum_path, :class => 'icon icon-add') %> - <% end %> + <% end %> +