fcrepo_admin 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY.rdoc +8 -3
- data/app/controllers/fcrepo_admin/datastreams_controller.rb +27 -21
- data/app/controllers/fcrepo_admin/objects_controller.rb +16 -41
- data/app/helpers/fcrepo_admin/objects_helper.rb +41 -1
- data/app/views/fcrepo_admin/datastreams/_content.html.erb +0 -4
- data/app/views/fcrepo_admin/datastreams/_context_nav_items.html.erb +17 -0
- data/app/views/fcrepo_admin/datastreams/edit.html.erb +8 -14
- data/app/views/fcrepo_admin/datastreams/upload.html.erb +10 -0
- data/app/views/fcrepo_admin/objects/_context_nav_items.html.erb +9 -0
- data/app/views/fcrepo_admin/objects/_properties.html.erb +1 -1
- data/app/views/fcrepo_admin/objects/audit_trail.html.erb +9 -9
- data/app/views/fcrepo_admin/objects/show.html.erb +8 -8
- data/app/views/fcrepo_admin/shared/_context_nav_list.html.erb +5 -0
- data/app/views/layouts/fcrepo_admin/datastreams.html.erb +2 -1
- data/app/views/layouts/fcrepo_admin/objects.html.erb +1 -1
- data/config/locales/fcrepo_admin.en.yml +19 -14
- data/config/routes.rb +6 -1
- data/lib/fcrepo_admin/version.rb +1 -1
- data/spec/features/datastreams/edit.html.erb_spec.rb +0 -3
- data/spec/features/datastreams/show.html.erb_spec.rb +1 -1
- data/spec/features/datastreams/upload.html.erb_spec.rb +27 -0
- data/spec/features/objects/audit_trail.html.erb_spec.rb +1 -1
- data/spec/features/objects/show.html.erb_spec.rb +2 -2
- metadata +9 -8
- data/app/views/fcrepo_admin/objects/_object_nav.html.erb +0 -5
- data/app/views/fcrepo_admin/objects/_object_nav_items.html.erb +0 -9
- data/lib/fcrepo_admin/controller_behavior.rb +0 -32
- data/spec/fixtures/auditable.foxml.xml +0 -110
data/HISTORY.rdoc
CHANGED
@@ -1,12 +1,17 @@
|
|
1
|
-
=== 0.3.
|
1
|
+
=== 0.3.1
|
2
|
+
|
3
|
+
* Object and datastream context nav menus added.
|
4
|
+
* Audit trail moved into objects controller
|
5
|
+
|
6
|
+
== 0.3.0
|
2
7
|
|
3
8
|
* Feature: Permissions and inherited permissions added to object show view.
|
4
9
|
|
5
|
-
|
10
|
+
== 0.2.0
|
6
11
|
|
7
12
|
* Feature: Datastream content editing.
|
8
13
|
|
9
|
-
|
14
|
+
== 0.1.0
|
10
15
|
|
11
16
|
Initial release to RubyGems.
|
12
17
|
|
@@ -3,68 +3,74 @@ require 'mime/types'
|
|
3
3
|
module FcrepoAdmin
|
4
4
|
class DatastreamsController < ApplicationController
|
5
5
|
|
6
|
-
# include FcrepoAdmin::ControllerBehavior
|
7
|
-
|
8
6
|
layout 'fcrepo_admin/datastreams'
|
9
7
|
|
10
8
|
# Additional types of content that should be displayed inline
|
11
9
|
TEXT_MIME_TYPES = ['application/xml', 'application/rdf+xml', 'application/json']
|
10
|
+
MAX_INLINE_SIZE = 1024 * 64
|
12
11
|
|
13
|
-
|
14
|
-
before_filter :load_and_authorize_datastream # , :except => :index
|
15
|
-
# before_filter :load_datastream, :only => :download
|
12
|
+
before_filter :load_and_authorize_datastream
|
16
13
|
before_filter :inline_filter, :only => [:show, :edit]
|
17
14
|
|
18
|
-
# def index
|
19
|
-
# end
|
20
|
-
|
21
15
|
def show
|
22
|
-
if params[:download]
|
23
|
-
mimetypes = MIME::Types[@datastream.mimeType]
|
24
|
-
send_data @datastream.content, :disposition => 'attachment', :type => @datastream.mimeType, :filename => "#{@datastream.pid.sub(/:/, '_')}_#{@datastream.dsid}.#{mimetypes.first.extensions.first}"
|
25
|
-
end
|
26
16
|
end
|
27
17
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
18
|
+
def download
|
19
|
+
mimetypes = MIME::Types[@datastream.mimeType]
|
20
|
+
send_data @datastream.content, :disposition => 'attachment', :type => @datastream.mimeType, :filename => "#{@datastream.pid.sub(/:/, '_')}_#{@datastream.dsid}.#{mimetypes.first.extensions.first}"
|
21
|
+
end
|
32
22
|
|
33
23
|
def edit
|
34
24
|
end
|
35
25
|
|
26
|
+
def upload
|
27
|
+
end
|
28
|
+
|
36
29
|
def update
|
37
|
-
if params[:file]
|
30
|
+
if params[:file] # file uploaded
|
38
31
|
@datastream.content = params[:file].read
|
39
|
-
else
|
32
|
+
else # content submitted
|
40
33
|
@datastream.content = params[:content]
|
41
34
|
end
|
42
35
|
@object.save
|
43
|
-
flash[:notice] = "Datastream content updated."
|
36
|
+
flash[:notice] = "Datastream content updated." # i18n
|
44
37
|
redirect_to fcrepo_admin.object_datastream_url(@object, @datastream.dsid)
|
45
38
|
end
|
46
39
|
|
47
40
|
private
|
48
41
|
|
49
42
|
def load_and_authorize_datastream
|
43
|
+
load_object
|
50
44
|
load_datastream
|
51
45
|
authorize_datastream
|
52
46
|
end
|
47
|
+
|
48
|
+
def load_object
|
49
|
+
@object = ActiveFedora::Base.find(params[:object_id], :cast => true)
|
50
|
+
end
|
53
51
|
|
54
52
|
def load_datastream
|
55
|
-
@object = ActiveFedora::Base.find(params[:object_id], :cast => true)
|
56
53
|
@datastream = @object.datastreams[params[:id]]
|
57
54
|
end
|
58
55
|
|
59
56
|
def authorize_datastream
|
57
|
+
action = case params[:action]
|
58
|
+
when 'upload'
|
59
|
+
:edit
|
60
|
+
when 'download'
|
61
|
+
:read
|
62
|
+
else
|
63
|
+
params[:action].to_sym
|
64
|
+
end
|
60
65
|
# Datastream permissions are solely based on object permissions
|
61
|
-
authorize!
|
66
|
+
authorize! action, @object
|
62
67
|
end
|
63
68
|
|
64
69
|
protected
|
65
70
|
|
66
71
|
def inline_filter
|
67
72
|
@inline = @datastream.mimeType.start_with?('text/') || TEXT_MIME_TYPES.include?(@datastream.mimeType)
|
73
|
+
# @inline &&= @datastream.dsSize <= MAX_INLINE_SIZE
|
68
74
|
end
|
69
75
|
|
70
76
|
end
|
@@ -5,14 +5,10 @@ module FcrepoAdmin
|
|
5
5
|
|
6
6
|
PROPERTIES = [:owner_id, :state, :create_date, :modified_date, :label]
|
7
7
|
|
8
|
-
helper_method :apo_enforcement_enabled?
|
9
8
|
helper_method :object_properties
|
10
|
-
helper_method :admin_policy_object?
|
11
|
-
helper_method :object_type
|
12
|
-
helper_method :has_permissions?
|
13
9
|
|
14
10
|
before_filter :load_and_authorize_object
|
15
|
-
before_filter :load_apo_info, :only => :show
|
11
|
+
before_filter :load_apo_info, :only => :show
|
16
12
|
|
17
13
|
def show
|
18
14
|
end
|
@@ -43,49 +39,28 @@ module FcrepoAdmin
|
|
43
39
|
|
44
40
|
protected
|
45
41
|
|
46
|
-
def apo_enforcement_enabled?
|
47
|
-
# Including Hydra::PolicyAwareAccessControlsEnforcement in ApplicationController
|
48
|
-
# appears to be the only way that APO access control enforcement can be enabled.
|
49
|
-
self.class.ancestors.include?(Hydra::PolicyAwareAccessControlsEnforcement)
|
50
|
-
end
|
51
|
-
|
52
42
|
def object_properties
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
def object_type
|
59
|
-
@object.class.to_s
|
43
|
+
unless @object_properties
|
44
|
+
@object_properties = {}
|
45
|
+
PROPERTIES.each { |p| @object_properties[p] = @object.send(p) }
|
46
|
+
end
|
47
|
+
@object_properties
|
60
48
|
end
|
61
49
|
|
62
|
-
def
|
63
|
-
@apo_relationship_name = nil
|
64
|
-
@apo = nil
|
50
|
+
def apo_relationship_name
|
65
51
|
@object.reflections.each_value do |reflection|
|
66
|
-
|
67
|
-
|
68
|
-
@apo_relationship_name = reflection.name
|
69
|
-
@apo = @object.send(@apo_relationship_name)
|
70
|
-
break
|
71
|
-
end
|
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
|
72
54
|
end
|
55
|
+
nil
|
73
56
|
end
|
74
57
|
|
75
|
-
def
|
76
|
-
@
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
@
|
81
|
-
end
|
82
|
-
|
83
|
-
def apo_class
|
84
|
-
# XXX Ideally we would use Hydra::PolicyAwareAccessControlsEnforcement#policy_class,
|
85
|
-
# but it's only available if it's been included in the application controller, i.e.,
|
86
|
-
# if APO access control enforcement is enabled. We want to know the name of the
|
87
|
-
# relationship regardless of whether policy enforcement is enabled.
|
88
|
-
Hydra.config[:permissions].fetch(:policy_class, Hydra::AdminPolicy)
|
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)
|
89
64
|
end
|
90
65
|
|
91
66
|
end
|
@@ -2,7 +2,47 @@ module FcrepoAdmin
|
|
2
2
|
module ObjectsHelper
|
3
3
|
|
4
4
|
def object_title
|
5
|
-
"#{
|
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))
|
6
46
|
end
|
7
47
|
|
8
48
|
end
|
@@ -0,0 +1,17 @@
|
|
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,15 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
<%= text_area_tag "content", @datastream.content, :size => "50x20", :class => "field span9" %>
|
10
|
-
</div>
|
11
|
-
<% end %>
|
12
|
-
<p>
|
13
|
-
<%= submit_tag t("fcrepo_admin.datastream.edit.submit"), :confirm => t("fcrepo_admin.datastream.edit.confirm"), :class => "btn btn-primary" %>
|
14
|
-
</p>
|
1
|
+
<h4><%= t("fcrepo_admin.datastream.edit.header") %></h4>
|
2
|
+
<%= form_tag fcrepo_admin.object_datastream_path(@datastream.pid, @datastream.dsid), :method => :put do %>
|
3
|
+
<div>
|
4
|
+
<%= text_area_tag "content", @datastream.content, :size => "50x20", :class => "field", :style => "width: 100%" %>
|
5
|
+
</div>
|
6
|
+
<p>
|
7
|
+
<%= submit_tag t("fcrepo_admin.datastream.edit.submit"), :confirm => t("fcrepo_admin.datastream.edit.confirm"), :class => "btn btn-primary" %>
|
8
|
+
</p>
|
15
9
|
<% end %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<h4><%= t("fcrepo_admin.datastream.upload.header") %></h4>
|
2
|
+
<%= form_tag fcrepo_admin.object_datastream_path(@datastream.pid, @datastream.dsid), :method => :put, :multipart => true do %>
|
3
|
+
<div>
|
4
|
+
<%= file_field_tag "file" %>
|
5
|
+
</div>
|
6
|
+
<p>
|
7
|
+
<%= submit_tag t("fcrepo_admin.datastream.upload.submit"), :confirm => t("fcrepo_admin.datastream.upload.confirm"), :class => "btn btn-primary" %>
|
8
|
+
</p>
|
9
|
+
<% end %>
|
10
|
+
|
@@ -0,0 +1,9 @@
|
|
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
|
+
<li>
|
8
|
+
<%= link_to_unless_current t("fcrepo_admin.object.nav.items.audit_trail"), fcrepo_admin.audit_trail_object_path(object) %>
|
9
|
+
</li>
|
@@ -1,19 +1,19 @@
|
|
1
|
-
<h3><%= t("fcrepo_admin.audit_trail.title") %></h3>
|
1
|
+
<h3><%= t("fcrepo_admin.object.audit_trail.title") %></h3>
|
2
2
|
|
3
3
|
<p>
|
4
|
-
<%= link_to t("fcrepo_admin.audit_trail.download"), "#{fcrepo_admin.audit_trail_object_path(@object)}?download=true", :class => "btn btn-primary" %>
|
4
|
+
<%= link_to t("fcrepo_admin.object.audit_trail.download"), "#{fcrepo_admin.audit_trail_object_path(@object)}?download=true", :class => "btn btn-primary" %>
|
5
5
|
</p>
|
6
6
|
|
7
7
|
<table class="table table-bordered table-condensed table-striped">
|
8
8
|
<thead>
|
9
9
|
<tr>
|
10
|
-
<th scope="col"><%= t("fcrepo_admin.audit_trail.record.id") %></th>
|
11
|
-
<th scope="col"><%= t("fcrepo_admin.audit_trail.record.process_type") %></th>
|
12
|
-
<th scope="col"><%= t("fcrepo_admin.audit_trail.record.action") %></th>
|
13
|
-
<th scope="col"><%= t("fcrepo_admin.audit_trail.record.component_id") %></th>
|
14
|
-
<th scope="col"><%= t("fcrepo_admin.audit_trail.record.responsibility") %></th>
|
15
|
-
<th scope="col"><%= t("fcrepo_admin.audit_trail.record.date") %></th>
|
16
|
-
<th scope="col"><%= t("fcrepo_admin.audit_trail.record.justification") %></th>
|
10
|
+
<th scope="col"><%= t("fcrepo_admin.object.audit_trail.record.id") %></th>
|
11
|
+
<th scope="col"><%= t("fcrepo_admin.object.audit_trail.record.process_type") %></th>
|
12
|
+
<th scope="col"><%= t("fcrepo_admin.object.audit_trail.record.action") %></th>
|
13
|
+
<th scope="col"><%= t("fcrepo_admin.object.audit_trail.record.component_id") %></th>
|
14
|
+
<th scope="col"><%= t("fcrepo_admin.object.audit_trail.record.responsibility") %></th>
|
15
|
+
<th scope="col"><%= t("fcrepo_admin.object.audit_trail.record.date") %></th>
|
16
|
+
<th scope="col"><%= t("fcrepo_admin.object.audit_trail.record.justification") %></th>
|
17
17
|
</tr>
|
18
18
|
</thead>
|
19
19
|
<tbody>
|
@@ -9,29 +9,29 @@
|
|
9
9
|
<%= render :partial => 'fcrepo_admin/datastreams/datastreams', :locals => {:datastreams => @object.datastreams} %>
|
10
10
|
</div>
|
11
11
|
<div class="tab-pane" id="tab-properties">
|
12
|
-
<%= render
|
12
|
+
<%= render 'properties' %>
|
13
13
|
</div>
|
14
14
|
<div class="tab-pane" id="tab-permissions">
|
15
|
-
<% if
|
15
|
+
<% if object_has_permissions? %>
|
16
16
|
<h4>Direct Permissions</h4>
|
17
17
|
<%= render :partial => 'permissions', :locals => {:permissions => @object.permissions} %>
|
18
18
|
<h4>Inherited Permissions</h4>
|
19
|
-
<% unless
|
19
|
+
<% unless admin_policy_enforcement_enabled? %>
|
20
20
|
<p class="alert">
|
21
21
|
<%= t("fcrepo_admin.object.apo.enforcement_disabled") %>.
|
22
22
|
</p>
|
23
23
|
<% end %>
|
24
|
-
<% if
|
24
|
+
<% if object_model_belongs_to_apo? %>
|
25
25
|
<p>
|
26
26
|
<%= t("fcrepo_admin.object.apo.governed_by") %>:
|
27
|
-
<% if
|
28
|
-
<%= link_to
|
27
|
+
<% if object_has_admin_policy? %>
|
28
|
+
<%= link_to object_admin_policy.pid, fcrepo_admin.object_path(object_admin_policy) %>
|
29
29
|
<% else %>
|
30
30
|
<span class="label"><%= t("fcrepo_admin.object.apo.not_assigned") %></span>
|
31
31
|
<% end %>
|
32
32
|
</p>
|
33
|
-
<% if
|
34
|
-
<%= render :partial => 'permissions', :locals => {:permissions =>
|
33
|
+
<% if object_has_inherited_permissions? %>
|
34
|
+
<%= render :partial => 'permissions', :locals => {:permissions => object_inherited_permissions} %>
|
35
35
|
<% end %>
|
36
36
|
<% else %>
|
37
37
|
<p class="alert alert-info">
|
@@ -4,6 +4,7 @@
|
|
4
4
|
<%= yield %>
|
5
5
|
<% end %>
|
6
6
|
<% content_for :sidebar do %>
|
7
|
-
<%= render :partial => 'fcrepo_admin/
|
7
|
+
<%= render :partial => 'fcrepo_admin/objects/context_nav_items', :locals => {:object => @object}, :layout => 'fcrepo_admin/shared/context_nav_list' %>
|
8
|
+
<%= render :partial => 'fcrepo_admin/datastreams/context_nav_items', :locals => {:datastream => @datastream, :object => @object}, :layout => 'fcrepo_admin/shared/context_nav_list' %>
|
8
9
|
<% end %>
|
9
10
|
<%= render :template => 'layouts/fcrepo_admin/default' %>
|
@@ -3,6 +3,6 @@
|
|
3
3
|
<%= yield %>
|
4
4
|
<% end %>
|
5
5
|
<% content_for :sidebar do %>
|
6
|
-
<%= render :partial => 'fcrepo_admin/objects/
|
6
|
+
<%= render :partial => 'fcrepo_admin/objects/context_nav_items', :locals => {:object => @object}, :layout => 'fcrepo_admin/shared/context_nav_list' %>
|
7
7
|
<% end %>
|
8
8
|
<%= render :template => 'layouts/fcrepo_admin/default' %>
|
@@ -30,17 +30,17 @@ en:
|
|
30
30
|
not_assigned: 'Not Assigned'
|
31
31
|
enforcement_disabled: 'Admin policy access control enforcement is disabled'
|
32
32
|
relationship_undefined: 'This object type does not define an admin policy relationship'
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
33
|
+
audit_trail:
|
34
|
+
title: 'Audit Trail'
|
35
|
+
download: 'Download'
|
36
|
+
record:
|
37
|
+
id: 'Record ID'
|
38
|
+
process_type: 'Process Type'
|
39
|
+
action: 'Action'
|
40
|
+
component_id: 'Component ID'
|
41
|
+
responsibility: 'Responsibility'
|
42
|
+
date: 'Date'
|
43
|
+
justification: 'Justification'
|
44
44
|
datastreams:
|
45
45
|
title: 'Datastreams'
|
46
46
|
header:
|
@@ -55,6 +55,7 @@ en:
|
|
55
55
|
items:
|
56
56
|
summary: 'Datastream Summary'
|
57
57
|
edit: 'Edit Content'
|
58
|
+
upload: 'Upload Content'
|
58
59
|
download: 'Download Content'
|
59
60
|
object: 'Object Admin'
|
60
61
|
tabs:
|
@@ -78,8 +79,12 @@ en:
|
|
78
79
|
dsChecksumType: 'Checksum Type'
|
79
80
|
dsChecksum: 'Checksum'
|
80
81
|
edit:
|
81
|
-
|
82
|
-
|
82
|
+
header: 'Edit Content'
|
83
|
+
confirm: "These changes are not validated and cannot be undone!"
|
84
|
+
submit: 'Update'
|
85
|
+
upload:
|
86
|
+
header: 'Upload Content'
|
83
87
|
confirm: "These changes are not validated and cannot be undone!"
|
84
|
-
submit: '
|
88
|
+
submit: 'Upload'
|
89
|
+
|
85
90
|
|
data/config/routes.rb
CHANGED
@@ -3,7 +3,12 @@ FcrepoAdmin::Engine.routes.draw do
|
|
3
3
|
scope :module => "fcrepo_admin" do
|
4
4
|
resources :objects, :only => :show do
|
5
5
|
get 'audit_trail', :on => :member
|
6
|
-
resources :datastreams, :only => [:show, :edit, :update]
|
6
|
+
resources :datastreams, :only => [:show, :edit, :update] do
|
7
|
+
member do
|
8
|
+
get 'upload'
|
9
|
+
get 'download'
|
10
|
+
end
|
11
|
+
end
|
7
12
|
end
|
8
13
|
end
|
9
14
|
|
data/lib/fcrepo_admin/version.rb
CHANGED
@@ -17,9 +17,6 @@ describe "datastreams/edit.html.erb" do
|
|
17
17
|
user.delete
|
18
18
|
object.delete
|
19
19
|
Warden.test_reset!
|
20
|
-
end
|
21
|
-
it "should provide an upload form to replace content" do
|
22
|
-
|
23
20
|
end
|
24
21
|
it "should provide a text field to edit/replace text content" do
|
25
22
|
fill_in "content", :with => <<EOS
|
@@ -17,7 +17,7 @@ describe "datastreams/show.html.erb" do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
it "should have a link to download the datastream content" do
|
20
|
-
page.should have_link(I18n.t("fcrepo_admin.datastream.download"), :href =>
|
20
|
+
page.should have_link(I18n.t("fcrepo_admin.datastream.download"), :href => fcrepo_admin.download_object_datastream_path(object, dsid))
|
21
21
|
end
|
22
22
|
context "user can edit" do
|
23
23
|
let(:user) { FactoryGirl.create(:user) }
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.configure do |c|
|
4
|
+
Warden.test_mode!
|
5
|
+
end
|
6
|
+
|
7
|
+
describe "datastreams/upload.html.erb" do
|
8
|
+
let(:object) { FactoryGirl.create(:content_model) }
|
9
|
+
let(:user) { FactoryGirl.create(:user) }
|
10
|
+
before {
|
11
|
+
object.permissions = [{type: 'user', name: user.email, access: 'edit'}]
|
12
|
+
object.save
|
13
|
+
login_as(user, :scope => :user, :run_callbacks => false)
|
14
|
+
visit fcrepo_admin.upload_object_datastream_path(object, "descMetadata")
|
15
|
+
}
|
16
|
+
after do
|
17
|
+
user.delete
|
18
|
+
object.delete
|
19
|
+
Warden.test_reset!
|
20
|
+
end
|
21
|
+
it "should provide an upload form" do
|
22
|
+
attach_file "file", File.join(Rails.root, "spec", "fixtures", "files", "descMetadata.xml")
|
23
|
+
click_button I18n.t("fcrepo_admin.datastream.upload.submit")
|
24
|
+
object.reload
|
25
|
+
object.title.should == "Altered Test Component"
|
26
|
+
end
|
27
|
+
end
|
@@ -6,6 +6,6 @@ describe "audit_trail.html.erb" do
|
|
6
6
|
it "should display the audit trail" do
|
7
7
|
visit fcrepo_admin.audit_trail_object_path(object)
|
8
8
|
page.should have_content(object.pid)
|
9
|
-
page.should have_link(I18n.t("fcrepo_admin.audit_trail.download"), :href => "#{fcrepo_admin.audit_trail_object_path(object)}?download=true")
|
9
|
+
page.should have_link(I18n.t("fcrepo_admin.object.audit_trail.download"), :href => "#{fcrepo_admin.audit_trail_object_path(object)}?download=true")
|
10
10
|
end
|
11
11
|
end
|
@@ -20,7 +20,7 @@ describe "objects/show.html.erb" do
|
|
20
20
|
end
|
21
21
|
it "should link to its audit trail" do
|
22
22
|
visit fcrepo_admin.object_path(object)
|
23
|
-
page.should have_link(I18n.t("fcrepo_admin.audit_trail.title"), :href => fcrepo_admin.audit_trail_object_path(object))
|
23
|
+
page.should have_link(I18n.t("fcrepo_admin.object.audit_trail.title"), :href => fcrepo_admin.audit_trail_object_path(object))
|
24
24
|
end
|
25
25
|
it "should display the object's permissions"
|
26
26
|
end
|
@@ -29,7 +29,7 @@ describe "objects/show.html.erb" do
|
|
29
29
|
after { object.admin_policy.delete }
|
30
30
|
it "should link to the APO" do
|
31
31
|
visit fcrepo_admin.object_path(object)
|
32
|
-
page.should have_link(object.admin_policy.pid, :href => fcrepo_admin.object_path(object.admin_policy
|
32
|
+
page.should have_link(object.admin_policy.pid, :href => fcrepo_admin.object_path(object.admin_policy))
|
33
33
|
end
|
34
34
|
it "should display the inherited permissions"
|
35
35
|
end
|
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.2
|
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-19 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: hydra-head
|
@@ -262,21 +262,23 @@ files:
|
|
262
262
|
- app/mailers/.gitkeep
|
263
263
|
- app/models/.gitkeep
|
264
264
|
- app/views/fcrepo_admin/datastreams/_content.html.erb
|
265
|
+
- app/views/fcrepo_admin/datastreams/_context_nav_items.html.erb
|
265
266
|
- app/views/fcrepo_admin/datastreams/_datastream_nav.html.erb
|
266
267
|
- app/views/fcrepo_admin/datastreams/_datastreams.html
|
267
268
|
- app/views/fcrepo_admin/datastreams/_profile.html.erb
|
268
269
|
- app/views/fcrepo_admin/datastreams/edit.html.erb
|
269
270
|
- app/views/fcrepo_admin/datastreams/index.html.erb
|
270
271
|
- app/views/fcrepo_admin/datastreams/show.html.erb
|
272
|
+
- app/views/fcrepo_admin/datastreams/upload.html.erb
|
273
|
+
- app/views/fcrepo_admin/objects/_context_nav_items.html.erb
|
271
274
|
- app/views/fcrepo_admin/objects/_more_info.html.erb
|
272
|
-
- app/views/fcrepo_admin/objects/_object_nav.html.erb
|
273
|
-
- app/views/fcrepo_admin/objects/_object_nav_items.html.erb
|
274
275
|
- app/views/fcrepo_admin/objects/_permissions.html.erb
|
275
276
|
- app/views/fcrepo_admin/objects/_permissions_header.html.erb
|
276
277
|
- app/views/fcrepo_admin/objects/_permissions_row.html.erb
|
277
278
|
- app/views/fcrepo_admin/objects/_properties.html.erb
|
278
279
|
- app/views/fcrepo_admin/objects/audit_trail.html.erb
|
279
280
|
- app/views/fcrepo_admin/objects/show.html.erb
|
281
|
+
- app/views/fcrepo_admin/shared/_context_nav_list.html.erb
|
280
282
|
- app/views/layouts/fcrepo_admin/datastreams.html.erb
|
281
283
|
- app/views/layouts/fcrepo_admin/default.html.erb
|
282
284
|
- app/views/layouts/fcrepo_admin/objects.html.erb
|
@@ -287,7 +289,6 @@ files:
|
|
287
289
|
- lib/assets/.gitkeep
|
288
290
|
- lib/fcrepo_admin.rb
|
289
291
|
- lib/fcrepo_admin/blacklight_helper_behavior.rb
|
290
|
-
- lib/fcrepo_admin/controller_behavior.rb
|
291
292
|
- lib/fcrepo_admin/datastream_ability.rb
|
292
293
|
- lib/fcrepo_admin/engine.rb
|
293
294
|
- lib/fcrepo_admin/solr_document_extension.rb
|
@@ -300,9 +301,9 @@ files:
|
|
300
301
|
- spec/factories/user_factories.rb
|
301
302
|
- spec/features/datastreams/edit.html.erb_spec.rb
|
302
303
|
- spec/features/datastreams/show.html.erb_spec.rb
|
304
|
+
- spec/features/datastreams/upload.html.erb_spec.rb
|
303
305
|
- spec/features/objects/audit_trail.html.erb_spec.rb
|
304
306
|
- spec/features/objects/show.html.erb_spec.rb
|
305
|
-
- spec/fixtures/auditable.foxml.xml
|
306
307
|
- spec/internal/README.rdoc
|
307
308
|
- spec/internal/Rakefile
|
308
309
|
- spec/internal/app/assets/javascripts/application.js
|
@@ -375,7 +376,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
375
376
|
version: '0'
|
376
377
|
segments:
|
377
378
|
- 0
|
378
|
-
hash:
|
379
|
+
hash: 1491170108417626237
|
379
380
|
requirements: []
|
380
381
|
rubyforge_project:
|
381
382
|
rubygems_version: 1.8.25
|
@@ -389,9 +390,9 @@ test_files:
|
|
389
390
|
- spec/factories/user_factories.rb
|
390
391
|
- spec/features/datastreams/edit.html.erb_spec.rb
|
391
392
|
- spec/features/datastreams/show.html.erb_spec.rb
|
393
|
+
- spec/features/datastreams/upload.html.erb_spec.rb
|
392
394
|
- spec/features/objects/audit_trail.html.erb_spec.rb
|
393
395
|
- spec/features/objects/show.html.erb_spec.rb
|
394
|
-
- spec/fixtures/auditable.foxml.xml
|
395
396
|
- spec/internal/README.rdoc
|
396
397
|
- spec/internal/Rakefile
|
397
398
|
- spec/internal/app/assets/javascripts/application.js
|
@@ -1,9 +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
|
-
<li>
|
8
|
-
<%= link_to_unless_current t("fcrepo_admin.object.nav.items.audit_trail"), fcrepo_admin.audit_trail_object_path(object) %>
|
9
|
-
</li>
|
@@ -1,32 +0,0 @@
|
|
1
|
-
module FcrepoAdmin
|
2
|
-
module ControllerBehavior
|
3
|
-
|
4
|
-
def load_and_authz_object
|
5
|
-
load_object
|
6
|
-
authorize_object
|
7
|
-
end
|
8
|
-
|
9
|
-
def load_object
|
10
|
-
@object = ActiveFedora::Base.find(params[:id], :cast => true)
|
11
|
-
end
|
12
|
-
|
13
|
-
def authorize_object
|
14
|
-
authorize! params[:action].to_sym, @object
|
15
|
-
end
|
16
|
-
|
17
|
-
def load_and_authz_datastream
|
18
|
-
load_datastream
|
19
|
-
authorize_datastream
|
20
|
-
end
|
21
|
-
|
22
|
-
def load_datastream
|
23
|
-
@object ||= ActiveFedora::Base.find(params[:object_id], :cast => true)
|
24
|
-
@datastream = @object.datastreams[params[:id]]
|
25
|
-
end
|
26
|
-
|
27
|
-
def authorize_datastream
|
28
|
-
authorize! params[:action].to_sym, @datastream
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
32
|
-
end
|
@@ -1,110 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<foxml:digitalObject VERSION="1.1" PID="changeme:242"
|
3
|
-
xmlns:foxml="info:fedora/fedora-system:def/foxml#"
|
4
|
-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
5
|
-
xsi:schemaLocation="info:fedora/fedora-system:def/foxml# http://www.fedora.info/definitions/1/0/foxml1-1.xsd">
|
6
|
-
<foxml:objectProperties>
|
7
|
-
<foxml:property NAME="info:fedora/fedora-system:def/model#state" VALUE="Active"/>
|
8
|
-
<foxml:property NAME="info:fedora/fedora-system:def/model#label" VALUE=""/>
|
9
|
-
<foxml:property NAME="info:fedora/fedora-system:def/model#ownerId" VALUE="fedoraAdmin"/>
|
10
|
-
<foxml:property NAME="info:fedora/fedora-system:def/model#createdDate" VALUE="2013-02-25T16:43:05.802Z"/>
|
11
|
-
<foxml:property NAME="info:fedora/fedora-system:def/view#lastModifiedDate" VALUE="2013-02-25T16:43:06.379Z"/>
|
12
|
-
</foxml:objectProperties>
|
13
|
-
<foxml:datastream ID="AUDIT" STATE="A" CONTROL_GROUP="X" VERSIONABLE="false">
|
14
|
-
<foxml:datastreamVersion ID="AUDIT.0" LABEL="Audit Trail for this object" CREATED="2013-02-25T16:43:05.802Z" MIMETYPE="text/xml" FORMAT_URI="info:fedora/fedora-system:format/xml.fedora.audit">
|
15
|
-
<foxml:xmlContent>
|
16
|
-
<audit:auditTrail xmlns:audit="info:fedora/fedora-system:def/audit#">
|
17
|
-
<audit:record ID="AUDREC1">
|
18
|
-
<audit:process type="Fedora API-M"/>
|
19
|
-
<audit:action>addDatastream</audit:action>
|
20
|
-
<audit:componentID>RELS-EXT</audit:componentID>
|
21
|
-
<audit:responsibility>fedoraAdmin</audit:responsibility>
|
22
|
-
<audit:date>2013-02-25T16:43:06.219Z</audit:date>
|
23
|
-
<audit:justification></audit:justification>
|
24
|
-
</audit:record>
|
25
|
-
<audit:record ID="AUDREC2">
|
26
|
-
<audit:process type="Fedora API-M"/>
|
27
|
-
<audit:action>addDatastream</audit:action>
|
28
|
-
<audit:componentID>descMetadata</audit:componentID>
|
29
|
-
<audit:responsibility>fedoraAdmin</audit:responsibility>
|
30
|
-
<audit:date>2013-02-25T16:43:06.315Z</audit:date>
|
31
|
-
<audit:justification></audit:justification>
|
32
|
-
</audit:record>
|
33
|
-
<audit:record ID="AUDREC3">
|
34
|
-
<audit:process type="Fedora API-M"/>
|
35
|
-
<audit:action>addDatastream</audit:action>
|
36
|
-
<audit:componentID>rightsMetadata</audit:componentID>
|
37
|
-
<audit:responsibility>fedoraAdmin</audit:responsibility>
|
38
|
-
<audit:date>2013-02-25T16:43:06.379Z</audit:date>
|
39
|
-
<audit:justification></audit:justification>
|
40
|
-
</audit:record>
|
41
|
-
</audit:auditTrail>
|
42
|
-
</foxml:xmlContent>
|
43
|
-
</foxml:datastreamVersion>
|
44
|
-
</foxml:datastream>
|
45
|
-
<foxml:datastream ID="DC" STATE="A" CONTROL_GROUP="X" VERSIONABLE="true">
|
46
|
-
<foxml:datastreamVersion ID="DC1.0" LABEL="Dublin Core Record for this object" CREATED="2013-02-25T16:43:05.802Z" MIMETYPE="text/xml" FORMAT_URI="http://www.openarchives.org/OAI/2.0/oai_dc/" SIZE="341">
|
47
|
-
<foxml:contentDigest TYPE="SHA-256" DIGEST="eb075bf6da5903e54464631dc998f66f95bffde9f4137132796457d31de5cd44"/>
|
48
|
-
<foxml:xmlContent>
|
49
|
-
<oai_dc:dc xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
|
50
|
-
<dc:identifier>changeme:242</dc:identifier>
|
51
|
-
</oai_dc:dc>
|
52
|
-
</foxml:xmlContent>
|
53
|
-
</foxml:datastreamVersion>
|
54
|
-
</foxml:datastream>
|
55
|
-
<foxml:datastream ID="RELS-EXT" STATE="A" CONTROL_GROUP="X" VERSIONABLE="true">
|
56
|
-
<foxml:datastreamVersion ID="RELS-EXT.0" LABEL="Fedora Object-to-Object Relationship Metadata" CREATED="2013-02-25T16:43:06.219Z" MIMETYPE="application/rdf+xml" SIZE="284">
|
57
|
-
<foxml:contentDigest TYPE="SHA-256" DIGEST="013d2229de7bd91c61256563eff1b475cd1e8f7e45a2f15de5a36f2d20ec2852"/>
|
58
|
-
<foxml:xmlContent>
|
59
|
-
<rdf:RDF xmlns:ns0="info:fedora/fedora-system:def/model#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
60
|
-
<rdf:Description rdf:about="info:fedora/changeme:242">
|
61
|
-
<ns0:hasModel rdf:resource="info:fedora/afmodel:TestModel"></ns0:hasModel>
|
62
|
-
</rdf:Description>
|
63
|
-
</rdf:RDF>
|
64
|
-
</foxml:xmlContent>
|
65
|
-
</foxml:datastreamVersion>
|
66
|
-
</foxml:datastream>
|
67
|
-
<foxml:datastream ID="descMetadata" STATE="A" CONTROL_GROUP="X" VERSIONABLE="true">
|
68
|
-
<foxml:datastreamVersion ID="descMetadata.0" LABEL="" CREATED="2013-02-25T16:43:06.315Z" MIMETYPE="text/xml" SIZE="215">
|
69
|
-
<foxml:contentDigest TYPE="SHA-256" DIGEST="3f588eca58dea77b31c9ed0b90e4560288a419856c4bb744fab9c7fe8749ad19"/>
|
70
|
-
<foxml:xmlContent>
|
71
|
-
<dc xmlns:dcterms="http://purl.org/dc/terms/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
72
|
-
<dcterms:title>Fcrepo Test Object</dcterms:title>
|
73
|
-
<dcterms:identifier>test00001</dcterms:identifier>
|
74
|
-
</dc>
|
75
|
-
</foxml:xmlContent>
|
76
|
-
</foxml:datastreamVersion>
|
77
|
-
</foxml:datastream>
|
78
|
-
<foxml:datastream ID="rightsMetadata" STATE="A" CONTROL_GROUP="X" VERSIONABLE="true">
|
79
|
-
<foxml:datastreamVersion ID="rightsMetadata.0" LABEL="" CREATED="2013-02-25T16:43:06.379Z" MIMETYPE="text/xml" SIZE="596">
|
80
|
-
<foxml:contentDigest TYPE="SHA-256" DIGEST="472f8634b31bd425dadd9206531ab02a70c08c22e4250bb2b0d3dd0314cfb240"/>
|
81
|
-
<foxml:xmlContent>
|
82
|
-
<rightsMetadata xmlns="http://hydra-collab.stanford.edu/schemas/rightsMetadata/v1" version="0.1">
|
83
|
-
<copyright>
|
84
|
-
<human type="title"></human>
|
85
|
-
<human type="description"></human>
|
86
|
-
<machine type="uri"></machine>
|
87
|
-
</copyright>
|
88
|
-
<access type="discover">
|
89
|
-
<human></human>
|
90
|
-
<machine></machine>
|
91
|
-
</access>
|
92
|
-
<access type="read">
|
93
|
-
<human></human>
|
94
|
-
<machine>
|
95
|
-
<group>public</group>
|
96
|
-
</machine>
|
97
|
-
</access>
|
98
|
-
<access type="edit">
|
99
|
-
<human></human>
|
100
|
-
<machine></machine>
|
101
|
-
</access>
|
102
|
-
<embargo>
|
103
|
-
<human></human>
|
104
|
-
<machine></machine>
|
105
|
-
</embargo>
|
106
|
-
</rightsMetadata>
|
107
|
-
</foxml:xmlContent>
|
108
|
-
</foxml:datastreamVersion>
|
109
|
-
</foxml:datastream>
|
110
|
-
</foxml:digitalObject>
|