Update abilities for ckeditor4 images
Add the image controller to use the obsolete load_and_authorize_resource and authorize_resource methods in the gem
This commit is contained in:
committed by
Javi Martín
parent
424535c1ae
commit
8e68f4bbd0
36
app/controllers/ckeditor/pictures_controller.rb
Normal file
36
app/controllers/ckeditor/pictures_controller.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
class Ckeditor::PicturesController < Ckeditor::ApplicationController
|
||||
load_and_authorize_resource
|
||||
def index
|
||||
@pictures = Ckeditor.picture_adapter.find_all(ckeditor_pictures_scope)
|
||||
@pictures = Ckeditor::Paginatable.new(@pictures).page(params[:page])
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render :layout => @pictures.first_page? }
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@picture = Ckeditor.picture_model.new
|
||||
respond_with_asset(@picture)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@picture.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to pictures_path }
|
||||
format.json { render :nothing => true, :status => 204 }
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def find_asset
|
||||
@picture = Ckeditor.picture_adapter.get!(params[:id])
|
||||
end
|
||||
|
||||
def authorize_resource
|
||||
model = (@picture || Ckeditor.picture_model)
|
||||
@authorization_adapter.try(:authorize, params[:action], model)
|
||||
end
|
||||
end
|
||||
@@ -3,6 +3,10 @@ module Abilities
|
||||
include CanCan::Ability
|
||||
|
||||
def initialize(user)
|
||||
can :access, :ckeditor # needed to access Ckeditor filebrowser
|
||||
can [:access, :read, :create, :destroy], Ckeditor::Picture
|
||||
can [:access, :read, :create, :destroy], Ckeditor::AttachmentFile
|
||||
|
||||
can [:read, :map], Debate
|
||||
can [:read, :map, :summary, :share], Proposal
|
||||
can :read, Comment
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
Rails.application.routes.draw do
|
||||
|
||||
mount Ckeditor::Engine => '/ckeditor'
|
||||
if Rails.env.development? || Rails.env.staging?
|
||||
get '/sandbox' => 'sandbox#index'
|
||||
get '/sandbox/*template' => 'sandbox#show'
|
||||
|
||||
Reference in New Issue
Block a user