Implement forum topic voting and tag change pruning (#3580)
This commit is contained in:
@@ -116,7 +116,7 @@ class ApplicationController < ActionController::Base
|
||||
fmt.xml { render template: "static/error", status: 501 }
|
||||
end
|
||||
else
|
||||
render :template => "static/error", :status => 500
|
||||
render :template => "static/error", :status => 500, :layout => "blank"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
32
app/controllers/forum_post_votes_controller.rb
Normal file
32
app/controllers/forum_post_votes_controller.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
class ForumPostVotesController < ApplicationController
|
||||
respond_to :js
|
||||
before_action :load_forum_post
|
||||
before_action :load_vote, only: [:destroy]
|
||||
before_action :member_only
|
||||
|
||||
def create
|
||||
@forum_post_vote = @forum_post.votes.create(forum_post_vote_params)
|
||||
respond_with(@forum_post_vote)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@forum_post_vote.destroy
|
||||
respond_with(@forum_post_vote)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_vote
|
||||
@forum_post_vote = @forum_post.votes.where(creator_id: CurrentUser.id).first
|
||||
raise ActiveRecord::RecordNotFound.new if @forum_post_vote.nil?
|
||||
end
|
||||
|
||||
def load_forum_post
|
||||
@forum_post = ForumPost.find(params[:forum_post_id])
|
||||
end
|
||||
|
||||
def forum_post_vote_params
|
||||
params.fetch(:forum_post_vote, {}).permit(:score)
|
||||
end
|
||||
|
||||
end
|
||||
@@ -46,6 +46,7 @@ class ForumTopicsController < ApplicationController
|
||||
@forum_topic.mark_as_read!(CurrentUser.user)
|
||||
end
|
||||
@forum_posts = ForumPost.search(:topic_id => @forum_topic.id).reorder("forum_posts.id").paginate(params[:page])
|
||||
@original_forum_post_id = @forum_topic.original_post.id
|
||||
respond_with(@forum_topic) do |format|
|
||||
format.atom do
|
||||
@forum_posts = @forum_posts.reverse_order.includes(:creator).load
|
||||
|
||||
Reference in New Issue
Block a user