51fa8f2eb4
• Added: - New Account filtering - PreviewCard viewing/sorting/filtering deleting (todo) - DeletePreviewCardWorker, Service - Status viewing/sorting/filtering deleting - ChatMessage viewing/sorting/filtering deleting (todo) - Account > Follows view • Updated: - LinkBlock to sort alphabetically - Groups to be under "Moderation" instead of "Admin" in navigation.rb - Status in admin to have group name/link - Reports reset button - Group filtering/sorting - LinkBlock filtering/sorting - Account now has bio and few more data points in dashboard
56 lines
1.2 KiB
Ruby
56 lines
1.2 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
module Admin
|
|
class LinkBlocksController < BaseController
|
|
before_action :set_link_block, only: [:show, :destroy]
|
|
|
|
def index
|
|
authorize :link_block, :index?
|
|
@link_blocks = filtered_link_blocks.alphabetical.page(params[:page])
|
|
end
|
|
|
|
def new
|
|
authorize :link_block, :create?
|
|
@link_block = LinkBlock.new
|
|
end
|
|
|
|
def create
|
|
authorize :link_block, :create?
|
|
|
|
@link_block = LinkBlock.new(resource_params)
|
|
|
|
if @link_block.save
|
|
log_action :create, @link_block
|
|
redirect_to admin_link_blocks_path, notice: I18n.t('admin.link_blocks.created_msg')
|
|
else
|
|
render :new
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
authorize @link_block, :destroy?
|
|
@link_block.destroy!
|
|
log_action :destroy, @link_block
|
|
redirect_to admin_link_blocks_path, notice: I18n.t('admin.link_blocks.destroyed_msg')
|
|
end
|
|
|
|
private
|
|
|
|
def filtered_link_blocks
|
|
LinkBlockFilter.new(filter_params).results
|
|
end
|
|
|
|
def set_link_block
|
|
@link_block = LinkBlock.find(params[:id])
|
|
end
|
|
|
|
def filter_params
|
|
params.permit(:link)
|
|
end
|
|
|
|
def resource_params
|
|
params.require(:link_block).permit(:link)
|
|
end
|
|
end
|
|
end
|