fcrepo_admin 0.3.5 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/HISTORY.rdoc +6 -0
- data/README.rdoc +42 -20
- data/app/controllers/fcrepo_admin/associations_controller.rb +7 -0
- data/app/controllers/fcrepo_admin/objects_controller.rb +2 -1
- data/app/helpers/fcrepo_admin/associations_helper.rb +5 -0
- data/app/views/fcrepo_admin/associations/_associations.html.erb +26 -0
- data/app/views/fcrepo_admin/associations/index.html.erb +1 -0
- data/app/views/fcrepo_admin/associations/show.html.erb +11 -0
- data/app/views/fcrepo_admin/catalog/_document.html.erb +6 -0
- data/app/views/fcrepo_admin/datastreams/_content.html.erb +4 -3
- data/app/views/fcrepo_admin/datastreams/_context_nav.html.erb +9 -0
- data/app/views/fcrepo_admin/datastreams/_context_nav_items.html.erb +21 -0
- data/app/views/fcrepo_admin/datastreams/{_datastreams.html → _datastreams.html.erb} +16 -3
- data/app/views/fcrepo_admin/datastreams/_profile.html.erb +9 -10
- data/app/views/fcrepo_admin/datastreams/content.html.erb +1 -0
- data/app/views/fcrepo_admin/datastreams/index.html.erb +1 -4
- data/app/views/fcrepo_admin/datastreams/show.html.erb +1 -14
- data/app/views/fcrepo_admin/objects/_context_nav.html.erb +9 -0
- data/app/views/fcrepo_admin/objects/_context_nav_datastreams.html.erb +13 -0
- data/app/views/fcrepo_admin/objects/_context_nav_items.html.erb +19 -0
- data/app/views/fcrepo_admin/objects/_direct_permissions.html.erb +8 -0
- data/app/views/fcrepo_admin/objects/_inherited_permissions.html.erb +23 -0
- data/app/views/fcrepo_admin/objects/_permissions_list.html.erb +18 -0
- data/app/views/fcrepo_admin/objects/{_permissions_row.html.erb → _permissions_list_item.html.erb} +0 -0
- data/app/views/fcrepo_admin/objects/_properties.html.erb +6 -5
- data/app/views/fcrepo_admin/objects/permissions.html.erb +5 -0
- data/app/views/fcrepo_admin/objects/show.html.erb +3 -46
- data/app/views/layouts/fcrepo_admin/datastreams.html.erb +2 -2
- data/app/views/layouts/fcrepo_admin/objects.html.erb +1 -1
- data/config/locales/fcrepo_admin.en.yml +24 -4
- data/config/routes.rb +7 -2
- data/lib/fcrepo_admin.rb +4 -1
- data/lib/fcrepo_admin/ability.rb +18 -0
- data/lib/fcrepo_admin/controller/associations_controller_behavior.rb +49 -0
- data/lib/fcrepo_admin/controller/catalog_controller_behavior.rb +9 -0
- data/lib/fcrepo_admin/controller/controller_behavior.rb +49 -0
- data/lib/fcrepo_admin/controller/datastreams_controller_behavior.rb +21 -28
- data/lib/fcrepo_admin/controller/objects_controller_behavior.rb +7 -32
- data/lib/fcrepo_admin/helpers/associations_helper_behavior.rb +23 -0
- data/lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb +7 -10
- data/lib/fcrepo_admin/helpers/fcrepo_admin_helper_behavior.rb +5 -10
- data/lib/fcrepo_admin/helpers/objects_helper_behavior.rb +0 -36
- data/lib/fcrepo_admin/version.rb +1 -1
- data/spec/controllers/associations_controller_spec.rb +34 -0
- data/spec/controllers/datastreams_controller_spec.rb +14 -12
- data/spec/controllers/objects_controller_spec.rb +6 -6
- data/spec/factories/fcrepo_admin_factories.rb +10 -6
- data/spec/features/associations/index.html.erb_spec.rb +28 -0
- data/spec/features/datastreams/edit.html.erb_spec.rb +1 -1
- data/spec/features/datastreams/index.html.erb_spec.rb +12 -0
- data/spec/features/datastreams/show.html.erb_spec.rb +1 -1
- data/spec/features/datastreams/upload.html.erb_spec.rb +1 -1
- data/spec/features/objects/audit_trail.html.erb_spec.rb +1 -1
- data/spec/features/objects/permissions.html.erb_spec.rb +19 -0
- data/spec/features/objects/show.html.erb_spec.rb +7 -30
- data/spec/internal/app/models/ability.rb +1 -1
- data/spec/internal/app/models/admin_policy.rb +3 -0
- data/spec/internal/app/models/collection.rb +14 -0
- data/spec/internal/app/models/item.rb +15 -0
- data/spec/internal/app/models/{content_model.rb → part.rb} +2 -1
- metadata +65 -73
- data/app/views/fcrepo_admin/datastreams/_datastream_nav.html.erb +0 -18
- data/app/views/fcrepo_admin/objects/_more_info.html.erb +0 -6
- data/app/views/fcrepo_admin/objects/_permissions.html.erb +0 -12
- data/app/views/fcrepo_admin/objects/_permissions_header.html.erb +0 -7
- data/lib/fcrepo_admin/datastream_ability.rb +0 -22
data/app/views/fcrepo_admin/objects/{_permissions_row.html.erb → _permissions_list_item.html.erb}
RENAMED
File without changes
|
@@ -1,8 +1,9 @@
|
|
1
|
-
<
|
1
|
+
<h3><%= t("fcrepo_admin.object.properties.title") %></h3>
|
2
|
+
<table class="table" style="width: auto">
|
2
3
|
<% object_properties.each do |key, value| %>
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
<tr>
|
5
|
+
<th scope="row"><%= t("fcrepo_admin.object.properties.keys.#{key}") %>:</th>
|
6
|
+
<td><%= value %></td>
|
7
|
+
</tr>
|
7
8
|
<% end %>
|
8
9
|
</table>
|
@@ -1,46 +1,3 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
<li><a href="#tab-properties" data-toggle="tab"><%= t("fcrepo_admin.object.tabs.properties") %></a></li>
|
5
|
-
<li><a href="#tab-permissions" data-toggle="tab"><%= t("fcrepo_admin.object.tabs.permissions") %></a></li>
|
6
|
-
</ul>
|
7
|
-
<div class="tab-content">
|
8
|
-
<div class="tab-pane active" id="tab-datastreams">
|
9
|
-
<%= render :partial => 'fcrepo_admin/datastreams/datastreams', :locals => {:datastreams => @object.datastreams} %>
|
10
|
-
</div>
|
11
|
-
<div class="tab-pane" id="tab-properties">
|
12
|
-
<%= render 'properties' %>
|
13
|
-
</div>
|
14
|
-
<div class="tab-pane" id="tab-permissions">
|
15
|
-
<% if object_has_permissions? %>
|
16
|
-
<h4>Direct Permissions</h4>
|
17
|
-
<%= render :partial => 'permissions', :locals => {:permissions => @object.permissions} %>
|
18
|
-
<h4>Inherited Permissions</h4>
|
19
|
-
<% unless admin_policy_enforcement_enabled? %>
|
20
|
-
<p class="alert">
|
21
|
-
<%= t("fcrepo_admin.object.apo.enforcement_disabled") %>.
|
22
|
-
</p>
|
23
|
-
<% end %>
|
24
|
-
<% if object_model_belongs_to_apo? %>
|
25
|
-
<p>
|
26
|
-
<%= t("fcrepo_admin.object.apo.governed_by") %>:
|
27
|
-
<% if object_has_admin_policy? %>
|
28
|
-
<%= link_to object_admin_policy.pid, fcrepo_admin.object_path(object_admin_policy) %>
|
29
|
-
<% else %>
|
30
|
-
<span class="label"><%= t("fcrepo_admin.object.apo.not_assigned") %></span>
|
31
|
-
<% end %>
|
32
|
-
</p>
|
33
|
-
<% if object_has_inherited_permissions? %>
|
34
|
-
<%= render :partial => 'permissions', :locals => {:permissions => object_inherited_permissions} %>
|
35
|
-
<% end %>
|
36
|
-
<% else %>
|
37
|
-
<p class="alert alert-info">
|
38
|
-
<%= t("fcrepo_admin.object.apo.relationship_undefined") %>: <%= object_type %>.
|
39
|
-
</p>
|
40
|
-
<% end %>
|
41
|
-
<% else %>
|
42
|
-
<%= t("fcrepo_admin.object.permissions.not_supported") %>: <%= object_type %>.
|
43
|
-
<% end %>
|
44
|
-
</div> <!-- /tab-permissions -->
|
45
|
-
</div>
|
46
|
-
</div>
|
1
|
+
<%= render_document_partial @document, :show %>
|
2
|
+
<%= render 'properties' %>
|
3
|
+
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<%= yield %>
|
5
5
|
<% end %>
|
6
6
|
<% content_for :sidebar do %>
|
7
|
-
<%=
|
8
|
-
<%=
|
7
|
+
<%= render 'fcrepo_admin/objects/context_nav' %>
|
8
|
+
<%= render 'fcrepo_admin/datastreams/context_nav' %>
|
9
9
|
<% end %>
|
10
10
|
<%= render :template => 'layouts/fcrepo_admin/default' %>
|
@@ -5,11 +5,16 @@ en:
|
|
5
5
|
datastreams: 'Datastreams'
|
6
6
|
properties: 'Properties'
|
7
7
|
permissions: 'Permissions'
|
8
|
+
associations: 'Associations'
|
8
9
|
nav:
|
9
10
|
header: 'Object Admin'
|
10
11
|
items:
|
11
|
-
summary: '
|
12
|
+
summary: 'Basic View'
|
12
13
|
audit_trail: 'Audit Trail'
|
14
|
+
permissions: 'Permissions'
|
15
|
+
properties: 'Properties'
|
16
|
+
datastreams: 'Datastreams'
|
17
|
+
associations: 'Associations'
|
13
18
|
properties:
|
14
19
|
title: 'Properties'
|
15
20
|
keys:
|
@@ -19,15 +24,28 @@ en:
|
|
19
24
|
modified_date: 'Modified Date'
|
20
25
|
label: 'Label'
|
21
26
|
permissions:
|
27
|
+
title: 'Permissions'
|
22
28
|
no_permissions: 'No permissions.'
|
23
29
|
not_supported: 'This object type does not support Hydra permissions'
|
30
|
+
direct: 'Direct Permissions'
|
31
|
+
inherited: 'Inherited Permissions'
|
24
32
|
header:
|
25
33
|
type: 'Type'
|
26
34
|
name: 'Name'
|
27
35
|
access: 'Access'
|
36
|
+
associations:
|
37
|
+
title: 'Associations'
|
38
|
+
not_assigned: 'not assigned'
|
39
|
+
collection_target: 'object'
|
40
|
+
header:
|
41
|
+
macro: 'Macro'
|
42
|
+
name: 'Association Name'
|
43
|
+
target: 'Target Object(s)'
|
44
|
+
class_name: 'Target Object Type'
|
45
|
+
property: 'Property/Predicate'
|
28
46
|
apo:
|
29
|
-
governed_by: 'Governed
|
30
|
-
not_assigned: '
|
47
|
+
governed_by: 'Governed by admin policy object'
|
48
|
+
not_assigned: 'This object is not governed by an admin policy object'
|
31
49
|
enforcement_disabled: 'Admin policy access control enforcement is disabled'
|
32
50
|
relationship_undefined: 'This object type does not define an admin policy relationship'
|
33
51
|
audit_trail:
|
@@ -44,6 +62,7 @@ en:
|
|
44
62
|
justification: 'Justification'
|
45
63
|
datastreams:
|
46
64
|
title: 'Datastreams'
|
65
|
+
not_persisted: 'Not persisted'
|
47
66
|
header:
|
48
67
|
id: 'Datastream ID'
|
49
68
|
label: 'Label'
|
@@ -54,7 +73,8 @@ en:
|
|
54
73
|
nav:
|
55
74
|
header: 'Datastream Admin'
|
56
75
|
items:
|
57
|
-
summary: '
|
76
|
+
summary: 'Profile'
|
77
|
+
content: 'View Content'
|
58
78
|
edit: 'Edit Content'
|
59
79
|
upload: 'Upload Content'
|
60
80
|
download: 'Download Content'
|
data/config/routes.rb
CHANGED
@@ -2,9 +2,14 @@ FcrepoAdmin::Engine.routes.draw do
|
|
2
2
|
|
3
3
|
scope :module => "fcrepo_admin" do
|
4
4
|
resources :objects, :only => :show do
|
5
|
-
|
6
|
-
|
5
|
+
member do
|
6
|
+
get 'audit_trail'
|
7
|
+
get 'permissions'
|
8
|
+
end
|
9
|
+
resources :associations, :only => [:index, :show]
|
10
|
+
resources :datastreams, :only => [:index, :show, :edit, :update] do
|
7
11
|
member do
|
12
|
+
get 'content'
|
8
13
|
get 'upload'
|
9
14
|
get 'download'
|
10
15
|
end
|
data/lib/fcrepo_admin.rb
CHANGED
@@ -4,16 +4,19 @@ require 'hydra/head'
|
|
4
4
|
|
5
5
|
module FcrepoAdmin
|
6
6
|
autoload :SolrDocumentExtension, 'fcrepo_admin/solr_document_extension'
|
7
|
-
autoload :
|
7
|
+
autoload :Ability, 'fcrepo_admin/ability'
|
8
8
|
module Helpers
|
9
9
|
autoload :BlacklightHelperBehavior, 'fcrepo_admin/helpers/blacklight_helper_behavior'
|
10
10
|
autoload :ObjectsHelperBehavior, 'fcrepo_admin/helpers/objects_helper_behavior'
|
11
11
|
autoload :DatastreamsHelperBehavior, 'fcrepo_admin/helpers/datastreams_helper_behavior'
|
12
|
+
autoload :AssociationsHelperBehavior, 'fcrepo_admin/helpers/associations_helper_behavior'
|
12
13
|
autoload :FcrepoAdminHelperBehavior, 'fcrepo_admin/helpers/fcrepo_admin_helper_behavior'
|
13
14
|
end
|
14
15
|
module Controller
|
15
16
|
autoload :ControllerBehavior, 'fcrepo_admin/controller/controller_behavior'
|
16
17
|
autoload :ObjectsControllerBehavior, 'fcrepo_admin/controller/objects_controller_behavior'
|
17
18
|
autoload :DatastreamsControllerBehavior, 'fcrepo_admin/controller/datastreams_controller_behavior'
|
19
|
+
autoload :AssociationsControllerBehavior, 'fcrepo_admin/controller/associations_controller_behavior'
|
20
|
+
autoload :CatalogControllerBehavior, 'fcrepo_admin/controller/catalog_controller_behavior'
|
18
21
|
end
|
19
22
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module FcrepoAdmin
|
2
|
+
module Ability
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
self.ability_logic += [:fcrepo_admin_aliases]
|
7
|
+
end
|
8
|
+
|
9
|
+
def fcrepo_admin_aliases
|
10
|
+
alias_action :download, :to => :read
|
11
|
+
alias_action :audit_trail, :to => :read
|
12
|
+
alias_action :permissions, :to => :read
|
13
|
+
alias_action :content, :to => :read
|
14
|
+
alias_action :upload, :to => :update
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module FcrepoAdmin::Controller
|
2
|
+
module AssociationsControllerBehavior
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
included do
|
6
|
+
layout 'fcrepo_admin/objects'
|
7
|
+
|
8
|
+
include FcrepoAdmin::Controller::ControllerBehavior
|
9
|
+
|
10
|
+
before_filter :load_and_authorize_object
|
11
|
+
before_filter :load_association, :only => :show
|
12
|
+
end
|
13
|
+
|
14
|
+
def index
|
15
|
+
end
|
16
|
+
|
17
|
+
def show
|
18
|
+
if @association.collection?
|
19
|
+
self.solr_search_params_logic += [:association_filter]
|
20
|
+
@response, @documents = get_search_results({:qt => 'standard'})
|
21
|
+
else
|
22
|
+
target = @object.send("#{@association.name}_id")
|
23
|
+
if target
|
24
|
+
redirect_to :controller => 'objects', :action => 'show', :id => target, :use_route => 'fcrepo_admin'
|
25
|
+
else
|
26
|
+
render :text => "Target not found", :status => 404
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def association_filter(solr_params, user_params)
|
32
|
+
solr_params[:q] = construct_query
|
33
|
+
end
|
34
|
+
|
35
|
+
protected
|
36
|
+
|
37
|
+
# Copied from ActiveFedora::Associations::AssociationCollection
|
38
|
+
def construct_query
|
39
|
+
clauses = {@association.options[:property] => @object.internal_uri}
|
40
|
+
clauses[:has_model] = @association.class_name.constantize.to_class_uri if @association.class_name && @association.class_name != 'ActiveFedora::Base'
|
41
|
+
ActiveFedora::SolrService.construct_query_for_rel(clauses)
|
42
|
+
end
|
43
|
+
|
44
|
+
def load_association
|
45
|
+
@association = @object.reflections[params[:id].to_sym] # XXX raise exception if nil
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -4,6 +4,25 @@ module FcrepoAdmin::Controller
|
|
4
4
|
|
5
5
|
included do
|
6
6
|
helper_method :object_is_auditable?
|
7
|
+
helper_method :object_is_governable?
|
8
|
+
helper_method :object_is_governed_by
|
9
|
+
helper_method :admin_policy_enforcement_enabled?
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def load_and_authorize_object
|
15
|
+
load_object
|
16
|
+
authorize_object
|
17
|
+
end
|
18
|
+
|
19
|
+
def load_object
|
20
|
+
id = params[:object_id] || params[:id]
|
21
|
+
@object = ActiveFedora::Base.find(id, :cast => true)
|
22
|
+
end
|
23
|
+
|
24
|
+
def authorize_object
|
25
|
+
authorize! params[:action].to_sym, @object
|
7
26
|
end
|
8
27
|
|
9
28
|
def object_is_auditable?
|
@@ -14,5 +33,35 @@ module FcrepoAdmin::Controller
|
|
14
33
|
end
|
15
34
|
end
|
16
35
|
|
36
|
+
def admin_policy_enforcement_enabled?
|
37
|
+
# Including Hydra::PolicyAwareAccessControlsEnforcement in ApplicationController
|
38
|
+
# appears to be the only way that APO access control enforcement can be enabled.
|
39
|
+
self.class.ancestors.include?(Hydra::PolicyAwareAccessControlsEnforcement)
|
40
|
+
end
|
41
|
+
|
42
|
+
def object_is_governed_by
|
43
|
+
@object_is_governed_by ||= object_is_governable? && @object.send(is_governed_by_association_name)
|
44
|
+
end
|
45
|
+
|
46
|
+
def object_is_governable?
|
47
|
+
!is_governed_by_association_name.nil?
|
48
|
+
end
|
49
|
+
|
50
|
+
def is_governed_by_association_name
|
51
|
+
@object.reflections.each do |name, reflection|
|
52
|
+
if reflection.macro == :belongs_to && reflection.options[:property] == :is_governed_by # && reflection.class_name == admin_policy_class.to_s
|
53
|
+
return reflection.name
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def admin_policy_class
|
59
|
+
# XXX Ideally we would use Hydra::PolicyAwareAccessControlsEnforcement#policy_class,
|
60
|
+
# but it's only available if it's been included in the application controller, i.e.,
|
61
|
+
# if APO access control enforcement is enabled. We want to know the name of the
|
62
|
+
# relationship regardless of whether policy enforcement is enabled.
|
63
|
+
Hydra.config[:permissions].fetch(:policy_class, Hydra::AdminPolicy)
|
64
|
+
end
|
65
|
+
|
17
66
|
end
|
18
67
|
end
|
@@ -5,19 +5,31 @@ module FcrepoAdmin::Controller
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
layout 'fcrepo_admin/datastreams'
|
8
|
+
layout 'fcrepo_admin/datastreams', :except => :index
|
9
|
+
layout 'fcrepo_admin/objects', :only => :index
|
10
|
+
|
9
11
|
include FcrepoAdmin::Controller::ControllerBehavior
|
10
|
-
|
11
|
-
before_filter :
|
12
|
+
|
13
|
+
before_filter :load_and_authorize_object
|
14
|
+
before_filter :load_datastream, :except => :index
|
15
|
+
|
16
|
+
helper_method :ds_content_is_text?
|
17
|
+
helper_method :ds_content_is_editable?
|
12
18
|
end
|
13
19
|
|
14
20
|
# Additional types of content that should be displayed inline
|
15
21
|
TEXT_MIME_TYPES = ['application/xml', 'application/rdf+xml', 'application/json']
|
16
22
|
MAX_INLINE_SIZE = 1024 * 64
|
17
23
|
|
24
|
+
def index
|
25
|
+
end
|
26
|
+
|
18
27
|
def show
|
19
28
|
end
|
20
29
|
|
30
|
+
def content
|
31
|
+
end
|
32
|
+
|
21
33
|
def download
|
22
34
|
mimetypes = MIME::Types[@datastream.mimeType]
|
23
35
|
send_data @datastream.content, :disposition => 'attachment', :type => @datastream.mimeType, :filename => "#{@datastream.pid.sub(/:/, '_')}_#{@datastream.dsid}.#{mimetypes.first.extensions.first}"
|
@@ -41,38 +53,19 @@ module FcrepoAdmin::Controller
|
|
41
53
|
end
|
42
54
|
|
43
55
|
private
|
44
|
-
|
45
|
-
def load_and_authorize_datastream
|
46
|
-
load_object
|
47
|
-
load_datastream
|
48
|
-
authorize_datastream
|
49
|
-
end
|
50
56
|
|
51
|
-
def load_object
|
52
|
-
@object = ActiveFedora::Base.find(params[:object_id], :cast => true)
|
53
|
-
end
|
54
|
-
|
55
57
|
def load_datastream
|
56
58
|
@datastream = @object.datastreams[params[:id]]
|
57
59
|
end
|
58
60
|
|
59
|
-
def authorize_datastream
|
60
|
-
action = case params[:action]
|
61
|
-
when 'upload'
|
62
|
-
:edit
|
63
|
-
when 'download'
|
64
|
-
:read
|
65
|
-
else
|
66
|
-
params[:action].to_sym
|
67
|
-
end
|
68
|
-
# Datastream permissions are solely based on object permissions
|
69
|
-
authorize! action, @object
|
70
|
-
end
|
71
|
-
|
72
61
|
protected
|
73
62
|
|
74
|
-
def
|
75
|
-
@
|
63
|
+
def ds_content_is_text?
|
64
|
+
@datastream.mimeType.start_with?('text/') || TEXT_MIME_TYPES.include?(@datastream.mimeType)
|
65
|
+
end
|
66
|
+
|
67
|
+
def ds_content_is_editable?
|
68
|
+
ds_content_is_text? && (@datastream.dsSize <= MAX_INLINE_SIZE)
|
76
69
|
end
|
77
70
|
|
78
71
|
end
|
@@ -4,15 +4,19 @@ module FcrepoAdmin::Controller
|
|
4
4
|
|
5
5
|
included do
|
6
6
|
layout 'fcrepo_admin/objects'
|
7
|
+
|
7
8
|
include FcrepoAdmin::Controller::ControllerBehavior
|
9
|
+
|
8
10
|
helper_method :object_properties
|
9
|
-
|
10
|
-
before_filter :
|
11
|
+
|
12
|
+
before_filter :load_and_authorize_object, :except => :show
|
11
13
|
end
|
12
14
|
|
13
15
|
PROPERTIES = [:owner_id, :state, :create_date, :modified_date, :label]
|
14
16
|
|
15
17
|
def show
|
18
|
+
@response, @document = get_solr_response_for_doc_id(params[:id])
|
19
|
+
@object = ActiveFedora::SolrService.reify_solr_results([@document], :load_from_solr => true).first
|
16
20
|
end
|
17
21
|
|
18
22
|
def audit_trail
|
@@ -25,20 +29,7 @@ module FcrepoAdmin::Controller
|
|
25
29
|
end
|
26
30
|
end
|
27
31
|
|
28
|
-
|
29
|
-
|
30
|
-
def load_and_authorize_object
|
31
|
-
load_object
|
32
|
-
authorize_object
|
33
|
-
end
|
34
|
-
|
35
|
-
def load_object
|
36
|
-
@object = ActiveFedora::Base.find(params[:id], :cast => true)
|
37
|
-
end
|
38
|
-
|
39
|
-
def authorize_object
|
40
|
-
action = params[:action] == 'audit_trail' ? :read : params[:action].to_sym
|
41
|
-
authorize! action, @object
|
32
|
+
def permissions
|
42
33
|
end
|
43
34
|
|
44
35
|
protected
|
@@ -47,21 +38,5 @@ module FcrepoAdmin::Controller
|
|
47
38
|
@object_properties ||= PROPERTIES.inject(Hash.new) { |h, p| h[p] = @object.send(p); h }
|
48
39
|
end
|
49
40
|
|
50
|
-
def apo_relationship_name
|
51
|
-
@object.reflections.each_value do |reflection|
|
52
|
-
# XXX This test should also check that reflection class is identical to admin policy class
|
53
|
-
return reflection.name if reflection.options[:property] == :is_governed_by && reflection.macro == :belongs_to
|
54
|
-
end
|
55
|
-
nil
|
56
|
-
end
|
57
|
-
|
58
|
-
def load_apo_info
|
59
|
-
@apo_relationship_name ||= apo_relationship_name
|
60
|
-
@object_admin_policy ||= @apo_relationship_name ? @object.send(@apo_relationship_name) : nil
|
61
|
-
# Including Hydra::PolicyAwareAccessControlsEnforcement in ApplicationController
|
62
|
-
# appears to be the only way that APO access control enforcement can be enabled.
|
63
|
-
@apo_enforcement_enabled ||= self.class.ancestors.include?(Hydra::PolicyAwareAccessControlsEnforcement)
|
64
|
-
end
|
65
|
-
|
66
41
|
end
|
67
42
|
end
|