fcrepo_admin 0.3.3 → 0.3.4
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.
- data/HISTORY.rdoc +19 -1
- data/README.rdoc +41 -2
- data/app/controllers/fcrepo_admin/datastreams_controller.rb +1 -74
- data/app/controllers/fcrepo_admin/objects_controller.rb +1 -63
- data/app/helpers/fcrepo_admin/datastreams_helper.rb +3 -0
- data/app/helpers/fcrepo_admin/objects_helper.rb +2 -48
- data/app/views/fcrepo_admin/shared/_context_nav.html.erb +12 -0
- data/app/views/layouts/fcrepo_admin/datastreams.html.erb +2 -2
- data/app/views/layouts/fcrepo_admin/objects.html.erb +1 -1
- data/lib/fcrepo_admin.rb +11 -2
- data/lib/fcrepo_admin/{controller_behavior.rb → controller/controller_behavior.rb} +1 -1
- data/lib/fcrepo_admin/controller/datastreams_controller_behavior.rb +80 -0
- data/lib/fcrepo_admin/controller/objects_controller_behavior.rb +67 -0
- data/lib/fcrepo_admin/{blacklight_helper_behavior.rb → helpers/blacklight_helper_behavior.rb} +2 -2
- data/lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb +25 -0
- data/lib/fcrepo_admin/helpers/fcrepo_admin_helper_behavior.rb +22 -0
- data/lib/fcrepo_admin/helpers/objects_helper_behavior.rb +50 -0
- data/lib/fcrepo_admin/version.rb +1 -1
- data/spec/internal/app/helpers/blacklight_helper.rb +1 -1
- metadata +12 -8
- data/app/views/fcrepo_admin/datastreams/_context_nav_items.html.erb +0 -17
- data/app/views/fcrepo_admin/objects/_context_nav_items.html.erb +0 -11
- data/app/views/fcrepo_admin/shared/_context_nav_list.html.erb +0 -5
data/HISTORY.rdoc
CHANGED
|
@@ -1,7 +1,25 @@
|
|
|
1
|
+
=== 0.3.4
|
|
2
|
+
|
|
3
|
+
* Moved FcrepoAdmin::BlacklightHelperBehavior to FcrepoAdmin::Helpers::BlacklightHelperBehavior.
|
|
4
|
+
* FcrepoAdmin::ObjectsHelper methods can now be easily overridden.
|
|
5
|
+
* DatastreamsHelper module added.
|
|
6
|
+
* Shared helper methods in new module FcrepoAdmin::Helpers::FcrepoAdminHelperBehavior.
|
|
7
|
+
* Objects and datastreams controller behaviors are now easily overrideable.
|
|
8
|
+
* Refactored object and datastream context navs for greater reusability.
|
|
9
|
+
|
|
10
|
+
=== 0.3.3
|
|
11
|
+
|
|
12
|
+
* Audit trail functionality fails gracefully (i.e., if object does not implement ActiveFedora::Auditable)
|
|
13
|
+
|
|
14
|
+
=== 0.3.2
|
|
15
|
+
|
|
16
|
+
* Separated datastream and object context navigation menus.
|
|
17
|
+
* Added object helpers.
|
|
18
|
+
|
|
1
19
|
=== 0.3.1
|
|
2
20
|
|
|
3
21
|
* Object and datastream context nav menus added.
|
|
4
|
-
* Audit trail moved into objects controller
|
|
22
|
+
* Audit trail moved into objects controller.
|
|
5
23
|
|
|
6
24
|
== 0.3.0
|
|
7
25
|
|
data/README.rdoc
CHANGED
|
@@ -46,12 +46,51 @@ See https://github.com/projecthydra/hydra-head/wiki/Installation-Prerequisites.
|
|
|
46
46
|
|
|
47
47
|
* Customize catalog search results (optional)
|
|
48
48
|
|
|
49
|
-
If you would like catalog search results items to link to the object
|
|
49
|
+
If you would like catalog search results items to link to the fcrepo_admin object show view
|
|
50
50
|
instead of the catalog show view, create app/helpers/blacklight_helper.rb with this content:
|
|
51
51
|
|
|
52
52
|
module BlacklightHelper
|
|
53
53
|
include Blacklight::BlacklightHelperBehavior # Default Blacklight behaviors
|
|
54
|
-
include FcrepoAdmin::BlacklightHelperBehavior # fcrepo_admin overrides
|
|
54
|
+
include FcrepoAdmin::Helpers::BlacklightHelperBehavior # fcrepo_admin overrides
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
* Add audit trail support (optional)
|
|
58
|
+
|
|
59
|
+
To enable access to the Fedora audit trail data through the fcrepo_admin UI, add your ActiveFedora models:
|
|
60
|
+
|
|
61
|
+
include ActiveFedora::Auditable
|
|
62
|
+
|
|
63
|
+
=== Overriding fcrepo_admin behaviors
|
|
64
|
+
|
|
65
|
+
* Object view helpers
|
|
66
|
+
|
|
67
|
+
Create app/helpers/fcrepo_admin/objects_helper.rb with this content:
|
|
68
|
+
|
|
69
|
+
module FcrepoAdmin::ObjectsHelper
|
|
70
|
+
include FcrepoAdmin::Helpers::ObjectsHelperBehavior
|
|
71
|
+
# override and/or add methods here
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
In particular you may want to override #object_title.
|
|
75
|
+
|
|
76
|
+
* Controllers
|
|
77
|
+
|
|
78
|
+
To override/extend the objects controller, create app/controllers/fcrepo_admin/objects_controller.rb:
|
|
79
|
+
|
|
80
|
+
module FcrepoAdmin
|
|
81
|
+
class ObjectsController < ApplicationController
|
|
82
|
+
include FcrepoAdmin::Controller::ObjectsControllerBehavior
|
|
83
|
+
# add your customizations
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
To override/extend the datastreams controller, create app/controllers/fcrepo_admin/datastreams_controller.rb:
|
|
88
|
+
|
|
89
|
+
module FcrepoAdmin
|
|
90
|
+
class DatastreamsController < ApplicationController
|
|
91
|
+
include FcrepoAdmin::Controller::DatastreamsControllerBehavior
|
|
92
|
+
# add your customizations
|
|
93
|
+
end
|
|
55
94
|
end
|
|
56
95
|
|
|
57
96
|
=== License
|
|
@@ -1,79 +1,6 @@
|
|
|
1
|
-
require 'mime/types'
|
|
2
|
-
|
|
3
1
|
module FcrepoAdmin
|
|
4
2
|
class DatastreamsController < ApplicationController
|
|
5
|
-
|
|
6
|
-
include FcrepoAdmin::ControllerBehavior
|
|
7
|
-
|
|
8
|
-
layout 'fcrepo_admin/datastreams'
|
|
9
|
-
|
|
10
|
-
# Additional types of content that should be displayed inline
|
|
11
|
-
TEXT_MIME_TYPES = ['application/xml', 'application/rdf+xml', 'application/json']
|
|
12
|
-
MAX_INLINE_SIZE = 1024 * 64
|
|
13
|
-
|
|
14
|
-
before_filter :load_and_authorize_datastream
|
|
15
|
-
before_filter :inline_filter, :only => [:show, :edit]
|
|
16
|
-
|
|
17
|
-
def show
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def download
|
|
21
|
-
mimetypes = MIME::Types[@datastream.mimeType]
|
|
22
|
-
send_data @datastream.content, :disposition => 'attachment', :type => @datastream.mimeType, :filename => "#{@datastream.pid.sub(/:/, '_')}_#{@datastream.dsid}.#{mimetypes.first.extensions.first}"
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def edit
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def upload
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def update
|
|
32
|
-
if params[:file] # file uploaded
|
|
33
|
-
@datastream.content = params[:file].read
|
|
34
|
-
else # content submitted
|
|
35
|
-
@datastream.content = params[:content]
|
|
36
|
-
end
|
|
37
|
-
@object.save
|
|
38
|
-
flash[:notice] = "Datastream content updated." # i18n
|
|
39
|
-
redirect_to fcrepo_admin.object_datastream_url(@object, @datastream.dsid)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
private
|
|
43
|
-
|
|
44
|
-
def load_and_authorize_datastream
|
|
45
|
-
load_object
|
|
46
|
-
load_datastream
|
|
47
|
-
authorize_datastream
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
def load_object
|
|
51
|
-
@object = ActiveFedora::Base.find(params[:object_id], :cast => true)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
def load_datastream
|
|
55
|
-
@datastream = @object.datastreams[params[:id]]
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def authorize_datastream
|
|
59
|
-
action = case params[:action]
|
|
60
|
-
when 'upload'
|
|
61
|
-
:edit
|
|
62
|
-
when 'download'
|
|
63
|
-
:read
|
|
64
|
-
else
|
|
65
|
-
params[:action].to_sym
|
|
66
|
-
end
|
|
67
|
-
# Datastream permissions are solely based on object permissions
|
|
68
|
-
authorize! action, @object
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
protected
|
|
72
|
-
|
|
73
|
-
def inline_filter
|
|
74
|
-
@inline = (@datastream.mimeType.start_with?('text/') || TEXT_MIME_TYPES.include?(@datastream.mimeType)) && @datastream.dsSize <= MAX_INLINE_SIZE
|
|
75
|
-
end
|
|
76
|
-
|
|
3
|
+
include FcrepoAdmin::Controller::DatastreamsControllerBehavior
|
|
77
4
|
end
|
|
78
5
|
end
|
|
79
6
|
|
|
@@ -1,67 +1,5 @@
|
|
|
1
1
|
module FcrepoAdmin
|
|
2
2
|
class ObjectsController < ApplicationController
|
|
3
|
-
|
|
4
|
-
include FcrepoAdmin::ControllerBehavior
|
|
5
|
-
|
|
6
|
-
layout 'fcrepo_admin/objects'
|
|
7
|
-
|
|
8
|
-
PROPERTIES = [:owner_id, :state, :create_date, :modified_date, :label]
|
|
9
|
-
|
|
10
|
-
helper_method :object_properties
|
|
11
|
-
|
|
12
|
-
before_filter :load_and_authorize_object
|
|
13
|
-
before_filter :load_apo_info, :only => :show
|
|
14
|
-
|
|
15
|
-
def show
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def audit_trail
|
|
19
|
-
if object_is_auditable?
|
|
20
|
-
if params[:download]
|
|
21
|
-
send_data @object.audit_trail.to_xml, :disposition => 'inline', :type => 'text/xml'
|
|
22
|
-
end
|
|
23
|
-
else
|
|
24
|
-
render :text => I18n.t("fcrepo_admin.object.audit_trail.not_implemented"), :status => 404
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
private
|
|
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
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
protected
|
|
45
|
-
|
|
46
|
-
def object_properties
|
|
47
|
-
@object_properties ||= PROPERTIES.inject(Hash.new) { |h, p| h[p] = @object.send(p); h }
|
|
48
|
-
end
|
|
49
|
-
|
|
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
|
-
|
|
3
|
+
include FcrepoAdmin::Controller::ObjectsControllerBehavior
|
|
66
4
|
end
|
|
67
5
|
end
|
|
@@ -1,49 +1,3 @@
|
|
|
1
|
-
module FcrepoAdmin
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def object_title
|
|
5
|
-
"#{object_type} #{@object.pid}"
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
def object_type
|
|
9
|
-
@object.class.to_s
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def object_has_permissions?
|
|
13
|
-
@object.is_a?(Hydra::ModelMixins::RightsMetadata)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def object_model_belongs_to_apo?
|
|
17
|
-
!@apo_relationship_name.nil?
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def object_admin_policy
|
|
21
|
-
@object_admin_policy
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def object_has_admin_policy?
|
|
25
|
-
!object_admin_policy.nil?
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def object_has_inherited_permissions?
|
|
29
|
-
object_has_admin_policy?
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def object_inherited_permissions
|
|
33
|
-
object_admin_policy && object_admin_policy.default_permissions
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def admin_policy_enforcement_enabled?
|
|
37
|
-
@apo_enforcement_enabled
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def admin_policy_object?
|
|
41
|
-
# XXX Ideally we would use Hydra::PolicyAwareAccessControlsEnforcement#policy_class,
|
|
42
|
-
# but it's only available if it's been included in the application controller, i.e.,
|
|
43
|
-
# if APO access control enforcement is enabled. We want to know the name of the
|
|
44
|
-
# relationship regardless of whether policy enforcement is enabled.
|
|
45
|
-
@object.is_a?(Hydra.config[:permissions].fetch(:policy_class, Hydra::AdminPolicy))
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
end
|
|
1
|
+
module FcrepoAdmin::ObjectsHelper
|
|
2
|
+
include FcrepoAdmin::Helpers::ObjectsHelperBehavior
|
|
49
3
|
end
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<%= yield %>
|
|
5
5
|
<% end %>
|
|
6
6
|
<% content_for :sidebar do %>
|
|
7
|
-
<%=
|
|
8
|
-
<%=
|
|
7
|
+
<%= render_object_context_nav %>
|
|
8
|
+
<%= render_datastream_context_nav %>
|
|
9
9
|
<% end %>
|
|
10
10
|
<%= render :template => 'layouts/fcrepo_admin/default' %>
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
<%= yield %>
|
|
4
4
|
<% end %>
|
|
5
5
|
<% content_for :sidebar do %>
|
|
6
|
-
<%=
|
|
6
|
+
<%= render_object_context_nav %>
|
|
7
7
|
<% end %>
|
|
8
8
|
<%= render :template => 'layouts/fcrepo_admin/default' %>
|
data/lib/fcrepo_admin.rb
CHANGED
|
@@ -4,7 +4,16 @@ require 'hydra/head'
|
|
|
4
4
|
|
|
5
5
|
module FcrepoAdmin
|
|
6
6
|
autoload :SolrDocumentExtension, 'fcrepo_admin/solr_document_extension'
|
|
7
|
-
autoload :ControllerBehavior, 'fcrepo_admin/controller_behavior'
|
|
8
7
|
autoload :DatastreamAbility, 'fcrepo_admin/datastream_ability'
|
|
9
|
-
|
|
8
|
+
module Helpers
|
|
9
|
+
autoload :BlacklightHelperBehavior, 'fcrepo_admin/helpers/blacklight_helper_behavior'
|
|
10
|
+
autoload :ObjectsHelperBehavior, 'fcrepo_admin/helpers/objects_helper_behavior'
|
|
11
|
+
autoload :DatastreamsHelperBehavior, 'fcrepo_admin/helpers/datastreams_helper_behavior'
|
|
12
|
+
autoload :FcrepoAdminHelperBehavior, 'fcrepo_admin/helpers/fcrepo_admin_helper_behavior'
|
|
13
|
+
end
|
|
14
|
+
module Controller
|
|
15
|
+
autoload :ControllerBehavior, 'fcrepo_admin/controller/controller_behavior'
|
|
16
|
+
autoload :ObjectsControllerBehavior, 'fcrepo_admin/controller/objects_controller_behavior'
|
|
17
|
+
autoload :DatastreamsControllerBehavior, 'fcrepo_admin/controller/datastreams_controller_behavior'
|
|
18
|
+
end
|
|
10
19
|
end
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
require 'mime/types'
|
|
2
|
+
|
|
3
|
+
module FcrepoAdmin::Controller
|
|
4
|
+
module DatastreamsControllerBehavior
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
|
|
7
|
+
included do
|
|
8
|
+
layout 'fcrepo_admin/datastreams'
|
|
9
|
+
include FcrepoAdmin::Controller::ControllerBehavior
|
|
10
|
+
before_filter :load_and_authorize_datastream
|
|
11
|
+
before_filter :inline_filter, :only => [:show, :edit]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Additional types of content that should be displayed inline
|
|
15
|
+
TEXT_MIME_TYPES = ['application/xml', 'application/rdf+xml', 'application/json']
|
|
16
|
+
MAX_INLINE_SIZE = 1024 * 64
|
|
17
|
+
|
|
18
|
+
def show
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def download
|
|
22
|
+
mimetypes = MIME::Types[@datastream.mimeType]
|
|
23
|
+
send_data @datastream.content, :disposition => 'attachment', :type => @datastream.mimeType, :filename => "#{@datastream.pid.sub(/:/, '_')}_#{@datastream.dsid}.#{mimetypes.first.extensions.first}"
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def edit
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def upload
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def update
|
|
33
|
+
if params[:file] # file uploaded
|
|
34
|
+
@datastream.content = params[:file].read
|
|
35
|
+
else # content submitted
|
|
36
|
+
@datastream.content = params[:content]
|
|
37
|
+
end
|
|
38
|
+
@object.save
|
|
39
|
+
flash[:notice] = "Datastream content updated." # i18n
|
|
40
|
+
redirect_to fcrepo_admin.object_datastream_url(@object, @datastream.dsid)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
private
|
|
44
|
+
|
|
45
|
+
def load_and_authorize_datastream
|
|
46
|
+
load_object
|
|
47
|
+
load_datastream
|
|
48
|
+
authorize_datastream
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def load_object
|
|
52
|
+
@object = ActiveFedora::Base.find(params[:object_id], :cast => true)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def load_datastream
|
|
56
|
+
@datastream = @object.datastreams[params[:id]]
|
|
57
|
+
end
|
|
58
|
+
|
|
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
|
+
protected
|
|
73
|
+
|
|
74
|
+
def inline_filter
|
|
75
|
+
@inline = (@datastream.mimeType.start_with?('text/') || TEXT_MIME_TYPES.include?(@datastream.mimeType)) && @datastream.dsSize <= MAX_INLINE_SIZE
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
module FcrepoAdmin::Controller
|
|
2
|
+
module ObjectsControllerBehavior
|
|
3
|
+
extend ActiveSupport::Concern
|
|
4
|
+
|
|
5
|
+
included do
|
|
6
|
+
layout 'fcrepo_admin/objects'
|
|
7
|
+
include FcrepoAdmin::Controller::ControllerBehavior
|
|
8
|
+
helper_method :object_properties
|
|
9
|
+
before_filter :load_and_authorize_object
|
|
10
|
+
before_filter :load_apo_info, :only => :show
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
PROPERTIES = [:owner_id, :state, :create_date, :modified_date, :label]
|
|
14
|
+
|
|
15
|
+
def show
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def audit_trail
|
|
19
|
+
if object_is_auditable?
|
|
20
|
+
if params[:download]
|
|
21
|
+
send_data @object.audit_trail.to_xml, :disposition => 'inline', :type => 'text/xml'
|
|
22
|
+
end
|
|
23
|
+
else
|
|
24
|
+
render :text => I18n.t("fcrepo_admin.object.audit_trail.not_implemented"), :status => 404
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
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
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
protected
|
|
45
|
+
|
|
46
|
+
def object_properties
|
|
47
|
+
@object_properties ||= PROPERTIES.inject(Hash.new) { |h, p| h[p] = @object.send(p); h }
|
|
48
|
+
end
|
|
49
|
+
|
|
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
|
+
end
|
|
67
|
+
end
|
data/lib/fcrepo_admin/{blacklight_helper_behavior.rb → helpers/blacklight_helper_behavior.rb}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
module FcrepoAdmin
|
|
1
|
+
module FcrepoAdmin::Helpers
|
|
2
2
|
module BlacklightHelperBehavior
|
|
3
3
|
|
|
4
4
|
def link_to_document(doc, opts={:label=>nil, :counter => nil, :results_view => true})
|
|
5
5
|
opts[:label] ||= blacklight_config.index.show_link.to_sym
|
|
6
6
|
label = render_document_index_label doc, opts
|
|
7
|
-
link_to label, fcrepo_admin.object_path(doc.id)
|
|
7
|
+
link_to label, fcrepo_admin.object_path(doc.id)
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module FcrepoAdmin::Helpers
|
|
2
|
+
module DatastreamsHelperBehavior
|
|
3
|
+
include FcrepoAdmin::Helpers::FcrepoAdminHelperBehavior
|
|
4
|
+
|
|
5
|
+
def datastream_context_nav_header
|
|
6
|
+
t("fcrepo_admin.datastream.nav.header")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def datastream_context_nav_items
|
|
10
|
+
items = []
|
|
11
|
+
items << [t("fcrepo_admin.datastream.nav.items.summary"), fcrepo_admin.object_datastream_path(@object, @datastream.dsid)]
|
|
12
|
+
if can? :edit, @object
|
|
13
|
+
items << [t("fcrepo_admin.datastream.nav.items.edit"), fcrepo_admin.edit_object_datastream_path(@object, @datastream.dsid)]
|
|
14
|
+
end
|
|
15
|
+
items << [t("fcrepo_admin.datastream.nav.items.upload"), fcrepo_admin.upload_object_datastream_path(@object, @datastream.dsid)]
|
|
16
|
+
items << [t("fcrepo_admin.datastream.nav.items.download"), fcrepo_admin.download_object_datastream_path(@object, @datastream.dsid)]
|
|
17
|
+
items
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def render_datastream_context_nav
|
|
21
|
+
render :partial => 'fcrepo_admin/shared/context_nav', :locals => {:header => datastream_context_nav_header, :items => datastream_context_nav_items}
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module FcrepoAdmin::Helpers
|
|
2
|
+
module FcrepoAdminHelperBehavior
|
|
3
|
+
|
|
4
|
+
def object_context_nav_items
|
|
5
|
+
items = []
|
|
6
|
+
items << [t("fcrepo_admin.object.nav.items.summary"), fcrepo_admin.object_path(@object)]
|
|
7
|
+
if object_is_auditable?
|
|
8
|
+
items << [t("fcrepo_admin.object.nav.items.audit_trail"), fcrepo_admin.audit_trail_object_path(@object)]
|
|
9
|
+
end
|
|
10
|
+
items
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def object_context_nav_header
|
|
14
|
+
t("fcrepo_admin.object.nav.header")
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def render_object_context_nav
|
|
18
|
+
render :partial => 'fcrepo_admin/shared/context_nav', :locals => {:header => object_context_nav_header, :items => object_context_nav_items}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
module FcrepoAdmin::Helpers
|
|
2
|
+
module ObjectsHelperBehavior
|
|
3
|
+
include FcrepoAdmin::Helpers::FcrepoAdminHelperBehavior
|
|
4
|
+
|
|
5
|
+
def object_title
|
|
6
|
+
"#{object_type} #{@object.pid}"
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def object_type
|
|
10
|
+
@object.class.to_s
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def object_has_permissions?
|
|
14
|
+
@object.is_a?(Hydra::ModelMixins::RightsMetadata)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def object_model_belongs_to_apo?
|
|
18
|
+
!@apo_relationship_name.nil?
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def object_admin_policy
|
|
22
|
+
@object_admin_policy
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def object_has_admin_policy?
|
|
26
|
+
!object_admin_policy.nil?
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def object_has_inherited_permissions?
|
|
30
|
+
object_has_admin_policy?
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def object_inherited_permissions
|
|
34
|
+
object_admin_policy && object_admin_policy.default_permissions
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def admin_policy_enforcement_enabled?
|
|
38
|
+
@apo_enforcement_enabled
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def admin_policy_object?
|
|
42
|
+
# XXX Ideally we would use Hydra::PolicyAwareAccessControlsEnforcement#policy_class,
|
|
43
|
+
# but it's only available if it's been included in the application controller, i.e.,
|
|
44
|
+
# if APO access control enforcement is enabled. We want to know the name of the
|
|
45
|
+
# relationship regardless of whether policy enforcement is enabled.
|
|
46
|
+
@object.is_a?(Hydra.config[:permissions].fetch(:policy_class, Hydra::AdminPolicy))
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
end
|
data/lib/fcrepo_admin/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fcrepo_admin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.3.
|
|
4
|
+
version: 0.3.4
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -12,7 +12,7 @@ authors:
|
|
|
12
12
|
autorequire:
|
|
13
13
|
bindir: bin
|
|
14
14
|
cert_chain: []
|
|
15
|
-
date: 2013-04-
|
|
15
|
+
date: 2013-04-29 00:00:00.000000000 Z
|
|
16
16
|
dependencies:
|
|
17
17
|
- !ruby/object:Gem::Dependency
|
|
18
18
|
name: hydra-head
|
|
@@ -258,11 +258,11 @@ files:
|
|
|
258
258
|
- Rakefile
|
|
259
259
|
- app/controllers/fcrepo_admin/datastreams_controller.rb
|
|
260
260
|
- app/controllers/fcrepo_admin/objects_controller.rb
|
|
261
|
+
- app/helpers/fcrepo_admin/datastreams_helper.rb
|
|
261
262
|
- app/helpers/fcrepo_admin/objects_helper.rb
|
|
262
263
|
- app/mailers/.gitkeep
|
|
263
264
|
- app/models/.gitkeep
|
|
264
265
|
- app/views/fcrepo_admin/datastreams/_content.html.erb
|
|
265
|
-
- app/views/fcrepo_admin/datastreams/_context_nav_items.html.erb
|
|
266
266
|
- app/views/fcrepo_admin/datastreams/_datastream_nav.html.erb
|
|
267
267
|
- app/views/fcrepo_admin/datastreams/_datastreams.html
|
|
268
268
|
- app/views/fcrepo_admin/datastreams/_profile.html.erb
|
|
@@ -270,7 +270,6 @@ files:
|
|
|
270
270
|
- app/views/fcrepo_admin/datastreams/index.html.erb
|
|
271
271
|
- app/views/fcrepo_admin/datastreams/show.html.erb
|
|
272
272
|
- app/views/fcrepo_admin/datastreams/upload.html.erb
|
|
273
|
-
- app/views/fcrepo_admin/objects/_context_nav_items.html.erb
|
|
274
273
|
- app/views/fcrepo_admin/objects/_more_info.html.erb
|
|
275
274
|
- app/views/fcrepo_admin/objects/_permissions.html.erb
|
|
276
275
|
- app/views/fcrepo_admin/objects/_permissions_header.html.erb
|
|
@@ -278,7 +277,7 @@ files:
|
|
|
278
277
|
- app/views/fcrepo_admin/objects/_properties.html.erb
|
|
279
278
|
- app/views/fcrepo_admin/objects/audit_trail.html.erb
|
|
280
279
|
- app/views/fcrepo_admin/objects/show.html.erb
|
|
281
|
-
- app/views/fcrepo_admin/shared/
|
|
280
|
+
- app/views/fcrepo_admin/shared/_context_nav.html.erb
|
|
282
281
|
- app/views/layouts/fcrepo_admin/datastreams.html.erb
|
|
283
282
|
- app/views/layouts/fcrepo_admin/default.html.erb
|
|
284
283
|
- app/views/layouts/fcrepo_admin/objects.html.erb
|
|
@@ -288,10 +287,15 @@ files:
|
|
|
288
287
|
- fcrepo_admin.gemspec
|
|
289
288
|
- lib/assets/.gitkeep
|
|
290
289
|
- lib/fcrepo_admin.rb
|
|
291
|
-
- lib/fcrepo_admin/
|
|
292
|
-
- lib/fcrepo_admin/
|
|
290
|
+
- lib/fcrepo_admin/controller/controller_behavior.rb
|
|
291
|
+
- lib/fcrepo_admin/controller/datastreams_controller_behavior.rb
|
|
292
|
+
- lib/fcrepo_admin/controller/objects_controller_behavior.rb
|
|
293
293
|
- lib/fcrepo_admin/datastream_ability.rb
|
|
294
294
|
- lib/fcrepo_admin/engine.rb
|
|
295
|
+
- lib/fcrepo_admin/helpers/blacklight_helper_behavior.rb
|
|
296
|
+
- lib/fcrepo_admin/helpers/datastreams_helper_behavior.rb
|
|
297
|
+
- lib/fcrepo_admin/helpers/fcrepo_admin_helper_behavior.rb
|
|
298
|
+
- lib/fcrepo_admin/helpers/objects_helper_behavior.rb
|
|
295
299
|
- lib/fcrepo_admin/solr_document_extension.rb
|
|
296
300
|
- lib/fcrepo_admin/version.rb
|
|
297
301
|
- lib/tasks/.gitkeep
|
|
@@ -377,7 +381,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
377
381
|
version: '0'
|
|
378
382
|
segments:
|
|
379
383
|
- 0
|
|
380
|
-
hash:
|
|
384
|
+
hash: 4077346936896984845
|
|
381
385
|
requirements: []
|
|
382
386
|
rubyforge_project:
|
|
383
387
|
rubygems_version: 1.8.25
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<li class="nav-header">
|
|
2
|
-
<%= t("fcrepo_admin.datastream.nav.header") %>
|
|
3
|
-
</li>
|
|
4
|
-
<li>
|
|
5
|
-
<%= link_to_unless_current t("fcrepo_admin.datastream.nav.items.summary"), fcrepo_admin.object_datastream_path(object, datastream.dsid) %>
|
|
6
|
-
</li>
|
|
7
|
-
<% if can? :edit, object %>
|
|
8
|
-
<li>
|
|
9
|
-
<%= link_to_unless_current t("fcrepo_admin.datastream.nav.items.edit"), fcrepo_admin.edit_object_datastream_path(object, datastream.dsid) %>
|
|
10
|
-
</li>
|
|
11
|
-
<li>
|
|
12
|
-
<%= link_to_unless_current t("fcrepo_admin.datastream.nav.items.upload"), fcrepo_admin.upload_object_datastream_path(object, datastream.dsid) %>
|
|
13
|
-
</li>
|
|
14
|
-
<% end %>
|
|
15
|
-
<li>
|
|
16
|
-
<%= link_to t("fcrepo_admin.datastream.nav.items.download"), fcrepo_admin.download_object_datastream_path(object, datastream.dsid) %>
|
|
17
|
-
</li>
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<li class="nav-header">
|
|
2
|
-
<%= t("fcrepo_admin.object.nav.header") %>
|
|
3
|
-
</li>
|
|
4
|
-
<li>
|
|
5
|
-
<%= link_to_unless_current t("fcrepo_admin.object.nav.items.summary"), fcrepo_admin.object_path(object) %>
|
|
6
|
-
</li>
|
|
7
|
-
<% if object_is_auditable? %>
|
|
8
|
-
<li>
|
|
9
|
-
<%= link_to_unless_current t("fcrepo_admin.object.nav.items.audit_trail"), fcrepo_admin.audit_trail_object_path(object) %>
|
|
10
|
-
</li>
|
|
11
|
-
<% end %>
|