Files
danbooru/app/controllers/artist_commentaries_controller.rb
evazion a7dc05ce63 Enable frozen string literals.
Make all string literals immutable by default.
2021-12-14 21:33:27 -06:00

42 lines
1.2 KiB
Ruby

# frozen_string_literal: true
class ArtistCommentariesController < ApplicationController
respond_to :html, :xml, :json, :js
def index
@commentaries = authorize ArtistCommentary.paginated_search(params)
@commentaries = @commentaries.includes(post: [:uploader, :media_asset]) if request.format.html?
respond_with(@commentaries)
end
def search
end
def show
if params[:id]
@commentary = authorize ArtistCommentary.find(params[:id])
else
@commentary = authorize ArtistCommentary.find_by_post_id!(params[:post_id])
end
respond_with(@commentary) do |format|
format.html { redirect_to post_path(@commentary.post) }
end
end
def create_or_update
post_id = params[:artist_commentary].delete(:post_id)
@artist_commentary = authorize ArtistCommentary.find_or_initialize_by(post_id: post_id)
@artist_commentary.update(permitted_attributes(@artist_commentary))
respond_with(@artist_commentary)
end
def revert
@artist_commentary = authorize ArtistCommentary.find_by_post_id!(params[:id])
@version = @artist_commentary.versions.find(params[:version_id])
@artist_commentary.revert_to!(@version)
respond_with(@artist_commentary)
end
end