-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Authorize update/create on a per-class basis
Previously it was checking access to create ActiveFedora::Base
- Loading branch information
Showing
12 changed files
with
134 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--colour | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
HydraEditor::Engine.routes.draw do | ||
resources :records, only: [:new, :edit, :create, :update], :constraints => { :id => /[a-zA-Z0-9_.:]+/ } | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
source "http://rubygems.org" | ||
source "https://rubygems.org" | ||
|
||
gemspec :path=>"../" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
source "http://rubygems.org" | ||
source "https://rubygems.org" | ||
|
||
gemspec :path=>"../" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,24 @@ | ||
require "cancan" | ||
require "hydra_editor/engine" | ||
require "bootstrap_forms" | ||
|
||
module HydraEditor | ||
|
||
class InvalidType < RuntimeError; end | ||
|
||
extend ActiveSupport::Autoload | ||
|
||
autoload :ControllerResource | ||
|
||
def self.models= val | ||
@models = val | ||
end | ||
|
||
def self.models | ||
@models ||= [] | ||
end | ||
|
||
def self.valid_model?(type) | ||
models.include? type | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
class HydraEditor::ControllerResource < CanCan::ControllerResource | ||
def find_resource | ||
ActiveFedora::Base.find(id_param, cast: true) | ||
end | ||
|
||
def resource_class | ||
raise HydraEditor::InvalidType, "Lost the type" unless has_valid_type? | ||
type_param.constantize | ||
end | ||
|
||
def has_valid_type? | ||
HydraEditor.valid_model? type_param | ||
end | ||
|
||
def type_param | ||
@params[:type] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
module HydraEditor | ||
class Engine < ::Rails::Engine | ||
engine_name 'hydra_editor' | ||
config.paths.add "app/helpers/concerns", eager_load: true | ||
config.paths.add "app/controllers/concerns", eager_load: true | ||
config.paths.add "app/models/concerns", eager_load: true | ||
config.autoload_paths += %W( | ||
#{config.root}/app/helpers/concerns | ||
#{config.root}/app/controllers/concerns | ||
#{config.root}/app/models/concerns | ||
) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.