edit link for original forum post goes to edit topic action
This commit is contained in:
@@ -26,6 +26,7 @@ class ForumTopicsController < ApplicationController
|
||||
def show
|
||||
@forum_topic = ForumTopic.find(params[:id])
|
||||
@forum_posts = ForumPost.search(:topic_id => @forum_topic.id).order("forum_posts.id").paginate(params[:page])
|
||||
@forum_posts.all
|
||||
respond_with(@forum_topic)
|
||||
end
|
||||
|
||||
|
||||
@@ -118,6 +118,10 @@ class ForumPost < ActiveRecord::Base
|
||||
((ForumPost.where("topic_id = ? and created_at <= ?", topic_id, created_at).count) / Danbooru.config.posts_per_page.to_f).ceil
|
||||
end
|
||||
|
||||
def is_original_post?
|
||||
ForumPost.exists?(["id = ? and id = (select _.id from forum_posts _ where _.topic_id = ? order by _.id asc limit 1)", id, topic_id])
|
||||
end
|
||||
|
||||
def build_response
|
||||
dup.tap do |x|
|
||||
x.body = x.quoted_response
|
||||
|
||||
@@ -27,7 +27,11 @@
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% if forum_post.editable_by?(CurrentUser.user) %>
|
||||
<li><%= link_to "Edit", edit_forum_post_path(forum_post.id) %></li>
|
||||
<% if forum_post.is_original_post? %>
|
||||
<li><%= link_to "Edit", edit_forum_topic_path(forum_post.topic) %></li>
|
||||
<% else %>
|
||||
<li><%= link_to "Edit", edit_forum_post_path(forum_post.id) %></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<li><%= link_to "Parent", forum_topic_path(forum_post.topic, :page => forum_post.forum_topic_page) %></li>
|
||||
<li><%= link_to "Permalink", forum_post_path(forum_post) %></li>
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
<li>|</li>
|
||||
<li><%= link_to "Reply", new_forum_post_path(:topic_id => @forum_topic.id) %></li>
|
||||
<% if !@forum_topic.new_record? && @forum_topic.editable_by?(CurrentUser.user) %>
|
||||
<li><%= link_to "Edit topic", edit_forum_topic_path(@forum_topic) %></li>
|
||||
<li><%= link_to "Edit", edit_forum_topic_path(@forum_topic) %></li>
|
||||
<% if CurrentUser.is_moderator? %>
|
||||
<li><%= link_to "Delete topic", forum_topic_path(@forum_topic), :remote => true, :method => :delete, :confirm => "Do you want to delete this forum topic?" %></li>
|
||||
<li><%= link_to "Delete", forum_topic_path(@forum_topic), :remote => true, :method => :delete, :confirm => "Do you want to delete this forum topic?" %></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user