Implement forum topic voting and tag change pruning (#3580)

This commit is contained in:
Albert Yi
2018-04-16 16:09:39 -07:00
parent 45fad069d7
commit f2b525a6d2
182 changed files with 558 additions and 554 deletions

View File

@@ -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

View 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

View File

@@ -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