more fixes for order of threadreplies
This commit is contained in:
@@ -11,7 +11,7 @@ class ForumsController < ApplicationController
|
|||||||
@threads = @forum.forumthreads.select {|f| f.can_read?(current_user) }.to_a
|
@threads = @forum.forumthreads.select {|f| f.can_read?(current_user) }.to_a
|
||||||
@threads.sort_by! do |t|
|
@threads.sort_by! do |t|
|
||||||
# sticky goes first, then sort by last activity (new replies)
|
# sticky goes first, then sort by last activity (new replies)
|
||||||
[t.sticky ? 0 : 1, -(t.replies.last.try(:created_at) || t.created_at).to_i]
|
[t.sticky ? 0 : 1, -(t.replies.order(:id).last.try(:created_at) || t.created_at).to_i]
|
||||||
end
|
end
|
||||||
@threads = Kaminari.paginate_array(@threads).page(params[:page])
|
@threads = Kaminari.paginate_array(@threads).page(params[:page])
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class ThreadrepliesController < ApplicationController
|
|||||||
if @reply.update_attributes(reply_params)
|
if @reply.update_attributes(reply_params)
|
||||||
@reply.send_new_reply_mail(old_content)
|
@reply.send_new_reply_mail(old_content)
|
||||||
flash[:notice] = "Reply updated!"
|
flash[:notice] = "Reply updated!"
|
||||||
position = @reply.thread.replies.index(@reply)
|
position = @reply.thread.replies.order(:id).index(@reply)
|
||||||
page = position / Kaminari.config.default_per_page + 1
|
page = position / Kaminari.config.default_per_page + 1
|
||||||
redirect_to forumthread_path(@reply.thread, page: page) + "#reply-#{@reply.id}"
|
redirect_to forumthread_path(@reply.thread, page: page) + "#reply-#{@reply.id}"
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
<div class="item <%= "#{"locked" if thread.locked}#{"sticky" if thread.sticky}" %>">
|
<div class="item <%= "#{"locked" if thread.locked}#{"sticky" if thread.sticky}" %>">
|
||||||
<%= render partial: "labels/label", locals: {label: thread.label} %><%= link_to truncate(thread.title, length: 60, omission: " …"), forumthread_path(thread), title: thread.title %>
|
<%= render partial: "labels/label", locals: {label: thread.label} %><%= link_to truncate(thread.title, length: 60, omission: " …"), forumthread_path(thread), title: thread.title %>
|
||||||
<div class="item-info">
|
<div class="item-info">
|
||||||
<% if rpl = thread.replies.last %>
|
<% if rpl = thread.replies.order(:id).last %>
|
||||||
<%= rpl.author.name %>
|
<%= rpl.author.name %>
|
||||||
<%
|
<%
|
||||||
position = thread.replies.count - 1
|
position = thread.replies.count - 1
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
<div class="item <%= "#{"locked" if thread.locked}#{"sticky" if thread.sticky}" %>">
|
<div class="item <%= "#{"locked" if thread.locked}#{"sticky" if thread.sticky}" %>">
|
||||||
<%= render partial: "labels/label", locals: {label: thread.label} %><%= link_to truncate(thread.title, length: 60, omission: " …"), forumthread_path(thread), title: thread.title %>
|
<%= render partial: "labels/label", locals: {label: thread.label} %><%= link_to truncate(thread.title, length: 60, omission: " …"), forumthread_path(thread), title: thread.title %>
|
||||||
<div class="item-info">
|
<div class="item-info">
|
||||||
<% if rpl = thread.replies.last %>
|
<% if rpl = thread.replies.order(:id).last %>
|
||||||
<%= rpl.author.name %>
|
<%= rpl.author.name %>
|
||||||
<%
|
<%
|
||||||
position = thread.replies.count - 1
|
position = thread.replies.count - 1
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<% title "Edit Thread Reply: #{@reply.thread.title}" %>
|
<% title "Edit Thread Reply: #{@reply.thread.title}" %>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
position = @reply.thread.replies.index(@reply)
|
position = @reply.thread.replies.order(:id).index(@reply)
|
||||||
page = position / Kaminari.config.default_per_page + 1
|
page = position / Kaminari.config.default_per_page + 1
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user