sufia 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/single_use_link_controller.rb +32 -28
- data/app/helpers/sufia_helper.rb +4 -0
- data/app/models/checksum_audit_log.rb +3 -3
- data/app/views/dashboard/_index_partials/_list_files.html.erb +5 -7
- data/app/views/users/index.html.erb +2 -3
- data/config/cucumber.yml +8 -0
- data/lib/generators/sufia/templates/config/sufia.rb +10 -5
- data/lib/sufia.rb +3 -0
- data/lib/sufia/batch_edits_controller_behavior.rb +23 -25
- data/lib/sufia/downloads_controller_behavior.rb +4 -4
- data/lib/sufia/files_controller_behavior.rb +2 -8
- data/lib/sufia/generic_file.rb +7 -11
- data/lib/sufia/solr_document_behavior.rb +4 -8
- data/lib/sufia/user.rb +5 -10
- data/lib/sufia/version.rb +1 -1
- data/spec/controllers/downloads_controller_spec.rb +2 -7
- data/spec/controllers/generic_files_controller_spec.rb +2 -2
- data/spec/models/generic_file_spec.rb +2 -2
- data/tasks/sufia-dev.rake +1 -0
- metadata +4 -3
- data/app/assets/images/NoAccess.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c1ede98424a5850d9fc61805d683d009adc137f
|
4
|
+
data.tar.gz: b4b58df9eb918d41e5852a5afd4917f7771849d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a15c15aa6703dfe883f75db875fa8362f6fb3dc3b5589549a75475dfc2b5fbfb7a8ee41bb9bcabadf1c8dbc3f2ef5fb3c41517a60ea046382afdc3f5f81ba291
|
7
|
+
data.tar.gz: 6af364e8b6a156ca8fdbbe0dcee00c994192e088fb9a662b087dfb47de2386975534d3c96fa769fcc2bcc61644b78416dc73e0fbc279db85f687ed861e68c235
|
@@ -1,33 +1,29 @@
|
|
1
1
|
require 'sufia/single_use_error'
|
2
2
|
|
3
3
|
class SingleUseLinkController < DownloadsController
|
4
|
-
before_filter :authenticate_user!, :except => [:
|
4
|
+
before_filter :authenticate_user!, :except => [:download, :show]
|
5
|
+
before_filter :find_file, :only => [:generate_download, :generate_show]
|
6
|
+
before_filter :authorize_user!, :only => [:generate_download, :generate_show]
|
5
7
|
skip_filter :normalize_identifier
|
6
8
|
prepend_before_filter :normalize_identifier, :except => [:download, :show]
|
7
9
|
rescue_from Sufia::SingleUseError, :with => :render_single_use_error
|
8
|
-
|
10
|
+
|
9
11
|
def generate_download
|
10
|
-
@generic_file = GenericFile.find(params[:id])
|
11
|
-
authorize! :read, @generic_file
|
12
12
|
@su = SingleUseLink.create_download(params[:id])
|
13
13
|
@link = sufia.download_single_use_link_path(@su.downloadKey)
|
14
14
|
respond_to do |format|
|
15
15
|
format.html
|
16
16
|
format.js {render :js => @link}
|
17
17
|
end
|
18
|
-
|
19
18
|
end
|
20
19
|
|
21
20
|
def generate_show
|
22
|
-
@generic_file = GenericFile.find(params[:id])
|
23
|
-
authorize! :read, @generic_file
|
24
21
|
@su = SingleUseLink.create_show(params[:id])
|
25
22
|
@link = sufia.show_single_use_link_path(@su.downloadKey)
|
26
23
|
respond_to do |format|
|
27
24
|
format.html
|
28
25
|
format.js {render :js => @link}
|
29
26
|
end
|
30
|
-
|
31
27
|
end
|
32
28
|
|
33
29
|
def download
|
@@ -35,13 +31,13 @@ class SingleUseLinkController < DownloadsController
|
|
35
31
|
link = lookup_hash
|
36
32
|
|
37
33
|
#grab the item id
|
38
|
-
id = link.itemId
|
39
|
-
|
34
|
+
id = link.itemId
|
35
|
+
|
40
36
|
#check to make sure the path matches
|
41
37
|
not_found if link.path != sufia.download_path(id)
|
42
|
-
|
38
|
+
|
43
39
|
# send the data content
|
44
|
-
asset =
|
40
|
+
asset = GenericFile.find(id)
|
45
41
|
send_content(asset)
|
46
42
|
end
|
47
43
|
|
@@ -49,42 +45,50 @@ class SingleUseLinkController < DownloadsController
|
|
49
45
|
link = lookup_hash
|
50
46
|
|
51
47
|
#grab the item id
|
52
|
-
id = link.itemId
|
53
|
-
|
48
|
+
id = link.itemId
|
49
|
+
|
54
50
|
#check to make sure the path matches
|
55
51
|
not_found if link.path != sufia.generic_file_path(id)
|
56
|
-
|
52
|
+
|
57
53
|
#show the file
|
58
|
-
@generic_file = GenericFile.
|
54
|
+
@generic_file = GenericFile.load_instance_from_solr(id)
|
59
55
|
@terms = @generic_file.terms_for_display
|
60
|
-
|
56
|
+
|
61
57
|
# create a dowload link that is single use for the user since we do not just want to show metadata we want to access it too
|
62
58
|
@su = SingleUseLink.create_download(id)
|
63
59
|
@download_link = sufia.download_single_use_link_path(@su.downloadKey)
|
64
60
|
end
|
65
|
-
|
61
|
+
|
66
62
|
protected
|
67
|
-
|
68
|
-
def
|
63
|
+
|
64
|
+
def authorize_user!
|
65
|
+
authorize! :read, @generic_file
|
66
|
+
end
|
67
|
+
|
68
|
+
def find_file
|
69
|
+
@generic_file = GenericFile.load_instance_from_solr(params[:id])
|
70
|
+
end
|
71
|
+
|
72
|
+
def lookup_hash
|
69
73
|
id = params[:id]
|
70
74
|
# invalid hash send not found
|
71
75
|
link = SingleUseLink.find_by_downloadKey(id) || not_found
|
72
|
-
|
76
|
+
|
73
77
|
# expired hash send not found
|
74
78
|
now = DateTime.now
|
75
|
-
not_found if link.expires <= now
|
76
|
-
|
79
|
+
not_found if link.expires <= now
|
80
|
+
|
77
81
|
# delete the link since it has been used
|
78
82
|
link.destroy
|
79
|
-
|
83
|
+
|
80
84
|
return link
|
81
85
|
end
|
82
|
-
|
86
|
+
|
83
87
|
def not_found
|
84
|
-
raise Sufia::SingleUseError.new('Single
|
88
|
+
raise Sufia::SingleUseError.new('Single-Use Link Not Found')
|
85
89
|
end
|
90
|
+
|
86
91
|
def expired
|
87
|
-
raise Sufia::SingleUseError.new('Single
|
92
|
+
raise Sufia::SingleUseError.new('Single-Use Link Expired')
|
88
93
|
end
|
89
|
-
|
90
94
|
end
|
data/app/helpers/sufia_helper.rb
CHANGED
@@ -39,6 +39,10 @@ module SufiaHelper
|
|
39
39
|
return User.find_by_user_key(recent_document.depositor).name rescue recent_document.depositor
|
40
40
|
end
|
41
41
|
|
42
|
+
def number_of_deposits(user)
|
43
|
+
ActiveFedora::SolrService.query("#{Solrizer.solr_name('depositor', :stored_searchable, :type => :string)}:#{user.user_key}").count
|
44
|
+
end
|
45
|
+
|
42
46
|
def link_to_facet(field, field_string)
|
43
47
|
link_to(field, add_facet_params(field_string, field).merge!({"controller" => "catalog", :action=> "index"}))
|
44
48
|
end
|
@@ -26,10 +26,10 @@ class ChecksumAuditLog < ActiveRecord::Base
|
|
26
26
|
## Check to see if there are previous passing logs that we can delete
|
27
27
|
# we want to keep the first passing event after a failure, the most current passing event, and all failures so that this table doesn't grow too large
|
28
28
|
# Simple way (a little naieve): if the last 2 were passing, delete the first one
|
29
|
-
logs = GenericFile.
|
29
|
+
logs = GenericFile.load_instance_from_solr(version.pid).logs(version.dsid)
|
30
30
|
list = logs.limit(2)
|
31
31
|
if list.size > 1 && (list[0].pass == 1) && (list[1].pass == 1)
|
32
|
-
list[0].delete
|
32
|
+
list[0].delete
|
33
33
|
end
|
34
34
|
end
|
35
|
-
end
|
35
|
+
end
|
@@ -14,14 +14,12 @@ See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
15
15
|
%>
|
16
16
|
|
17
|
-
<!-- scholarsphere over ride -->
|
18
|
-
<!-- the sub on ':' is b.c. jQuery has trouble with '.' or ':'
|
19
|
-
on element ids -->
|
20
17
|
<% noid = document.noid %>
|
21
|
-
<tr id="document_<%= noid
|
22
|
-
<% gf = GenericFile.
|
18
|
+
<tr id="document_<%= noid %>" class="<%= cycle("","zebra") %>">
|
19
|
+
<% gf = GenericFile.load_instance_from_solr(document.id) %>
|
23
20
|
<td width="6%"><%= batch_edit_select(document) %> </td>
|
24
21
|
<td width="1%">
|
22
|
+
<%# This block is for adding/removing the magic wand while batch updates are processing %>
|
25
23
|
<% if gf.processing? %>
|
26
24
|
<i class="icon-magic icon-large <%= 'ss-'+gf.batch.noid%>"/>
|
27
25
|
<% elsif gf.depositor != @user.user_key %>
|
@@ -29,7 +27,7 @@ on element ids -->
|
|
29
27
|
<% end %>
|
30
28
|
</td>
|
31
29
|
<td width="37%">
|
32
|
-
<a href="" title="Click for more details"><i id="expand_<%= noid
|
30
|
+
<a href="" title="Click for more details"><i id="expand_<%= noid %>" class="icon-plus icon-large fleft"></i></a>
|
33
31
|
<%= render :partial => 'dashboard/_index_partials/thumbnail_display', :locals => {:document=>document} %>
|
34
32
|
<span class=center><%= link_to document.title_or_label, sufia.generic_file_path(noid), :id => "src_copy_link#{noid}" %> <br /></span>
|
35
33
|
</td>
|
@@ -67,7 +65,7 @@ on element ids -->
|
|
67
65
|
</div>
|
68
66
|
</td>
|
69
67
|
</tr>
|
70
|
-
<tr class="hide" id="detail_<%= noid
|
68
|
+
<tr class="hide" id="detail_<%= noid %>"> <!-- document detail"> -->
|
71
69
|
<td colspan="6">
|
72
70
|
<table class="expanded-details">
|
73
71
|
<tr>
|
@@ -36,10 +36,9 @@ limitations under the License.
|
|
36
36
|
<td ><a href="<%= sufia.profile_path(URI.escape(user.user_key,'@.')) %>" ><%= user.name %><a></td>
|
37
37
|
<td><a href="<%= sufia.profile_path(URI.escape(user.user_key,'@.')) %>" ><%= user.user_key %><a></td>
|
38
38
|
<td><%= user.department %> </td>
|
39
|
-
<td><%=
|
39
|
+
<td><%= number_of_deposits(user) %> </td>
|
40
40
|
</tr>
|
41
|
-
|
42
|
-
<% end %>
|
41
|
+
<% end %>
|
43
42
|
</tbody>
|
44
43
|
</table>
|
45
44
|
<div class="pager">
|
data/config/cucumber.yml
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
<%
|
2
|
+
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
|
3
|
+
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
|
4
|
+
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
|
5
|
+
%>
|
6
|
+
default: <%= std_opts %> features
|
7
|
+
wip: --tags @wip:3 --wip features
|
8
|
+
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# Returns an array containing the vhost 'CoSign service' value and URL
|
2
2
|
Sufia.config do |config|
|
3
|
-
|
4
|
-
config.fits_path = "fits.sh"
|
3
|
+
|
5
4
|
config.fits_to_desc_mapping= {
|
6
5
|
:file_title => :title,
|
7
6
|
:file_author => :creator
|
@@ -59,14 +58,20 @@ Sufia.config do |config|
|
|
59
58
|
config.queue = Sufia::Resque::Queue
|
60
59
|
|
61
60
|
# Map hostnames onto Google Analytics tracking IDs
|
62
|
-
#config.google_analytics_id = 'UA-99999999-1'
|
61
|
+
# config.google_analytics_id = 'UA-99999999-1'
|
63
62
|
|
64
63
|
|
65
64
|
# Where to store tempfiles, leave blank for the system temp directory (e.g. /tmp)
|
66
|
-
#config.temp_file_base = '/home/developer1'
|
65
|
+
# config.temp_file_base = '/home/developer1'
|
67
66
|
|
68
67
|
# If you have ffmpeg installed and want to transcode audio and video uncomment this line
|
69
|
-
#config.enable_ffmpeg = true
|
68
|
+
# config.enable_ffmpeg = true
|
69
|
+
|
70
|
+
# Specify the Fedora pid prefix:
|
71
|
+
# config.id_namespace = "sufia"
|
72
|
+
|
73
|
+
# Specify the path to the file characterization tool:
|
74
|
+
# config.fits_path = "fits.sh"
|
70
75
|
|
71
76
|
end
|
72
77
|
|
data/lib/sufia.rb
CHANGED
@@ -30,11 +30,14 @@ module Sufia
|
|
30
30
|
config.ffmpeg_path = 'ffmpeg'
|
31
31
|
config.fits_message_length = 5
|
32
32
|
config.temp_file_base = nil
|
33
|
+
config.id_namespace = "sufia"
|
34
|
+
config.fits_path = "fits.sh"
|
33
35
|
|
34
36
|
config.autoload_paths += %W(
|
35
37
|
#{config.root}/lib/sufia/jobs
|
36
38
|
#{config.root}/app/controllers/concerns
|
37
39
|
#{config.root}/app/models/concerns
|
40
|
+
#{config.root}/app/models/datastreams
|
38
41
|
)
|
39
42
|
|
40
43
|
initializer "Patch active_fedora" do
|
@@ -3,7 +3,7 @@ module Sufia
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
def edit
|
6
|
-
super
|
6
|
+
super
|
7
7
|
@generic_file = ::GenericFile.new
|
8
8
|
@generic_file.depositor = current_user.user_key
|
9
9
|
@terms = @generic_file.terms_for_editing - [:title, :format, :resource_type]
|
@@ -17,13 +17,13 @@ module Sufia
|
|
17
17
|
|
18
18
|
# For each of the files in the batch, set the attributes to be the concatination of all the attributes
|
19
19
|
batch.each do |doc_id|
|
20
|
-
gf = ::GenericFile.
|
20
|
+
gf = ::GenericFile.load_instance_from_solr(doc_id)
|
21
21
|
gf.terms_for_editing.each do |key|
|
22
22
|
h[key] ||= []
|
23
|
-
h[key] = (h[key] + gf.send(key)).uniq
|
23
|
+
h[key] = (h[key] + gf.send(key)).uniq
|
24
24
|
end
|
25
|
-
@names << display_title(gf)
|
26
|
-
permissions =
|
25
|
+
@names << display_title(gf)
|
26
|
+
permissions = (permissions + gf.permissions).uniq
|
27
27
|
end
|
28
28
|
|
29
29
|
initialize_fields(h, @show_file)
|
@@ -32,47 +32,46 @@ module Sufia
|
|
32
32
|
# todo sort the access level some how...
|
33
33
|
perm_param ={'user'=>{},'group'=>{"public"=>"1"}}
|
34
34
|
permissions.each{ |perm| perm_param[perm[:type]][perm[:name]] = perm[:access]}
|
35
|
-
@show_file.permissions = HashWithIndifferentAccess.new(perm_param)
|
35
|
+
@show_file.permissions = HashWithIndifferentAccess.new(perm_param)
|
36
36
|
end
|
37
37
|
|
38
|
-
def after_update
|
39
|
-
|
38
|
+
def after_update
|
39
|
+
redirect_to sufia.dashboard_index_path unless request.xhr?
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
def update_document(obj)
|
43
43
|
super
|
44
44
|
obj.date_modified = Time.now.ctime
|
45
45
|
obj.set_visibility(params[:visibility])
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
def update
|
49
49
|
# keep the batch around if we are doing ajax calls
|
50
|
-
batch_sav = batch.dup if request.xhr?
|
50
|
+
batch_sav = batch.dup if request.xhr?
|
51
51
|
catalog_index_path = sufia.dashboard_index_path
|
52
52
|
type = params["update_type"]
|
53
|
-
if
|
54
|
-
|
55
|
-
|
56
|
-
elsif (type == "delete_all")
|
53
|
+
if type == "update"
|
54
|
+
super
|
55
|
+
elsif type == "delete_all"
|
57
56
|
batch.each do |doc_id|
|
58
|
-
gf = ::GenericFile.
|
57
|
+
gf = ::GenericFile.load_instance_from_solr(doc_id)
|
59
58
|
gf.delete
|
60
59
|
end
|
61
|
-
clear_batch!
|
60
|
+
clear_batch!
|
62
61
|
after_update
|
63
62
|
end
|
64
63
|
|
65
64
|
# reset the batch around if we are doing ajax calls
|
66
65
|
if request.xhr?
|
67
|
-
self.batch = batch_sav.dup
|
66
|
+
self.batch = batch_sav.dup
|
68
67
|
@key = params["key"]
|
69
|
-
if
|
70
|
-
|
68
|
+
if @key != "permissions"
|
69
|
+
@vals = params["generic_file"][@key]
|
71
70
|
else
|
72
|
-
|
73
|
-
end
|
71
|
+
@vals = [""]
|
72
|
+
end
|
74
73
|
render :update_edit
|
75
|
-
end
|
74
|
+
end
|
76
75
|
end
|
77
76
|
|
78
77
|
protected
|
@@ -80,10 +79,9 @@ module Sufia
|
|
80
79
|
# override this method if you need to initialize more complex RDF assertions (b-nodes)
|
81
80
|
def initialize_fields(attributes, file)
|
82
81
|
file.terms_for_editing.each do |key|
|
83
|
-
# if value is empty, we create an one element array to loop over for output
|
82
|
+
# if value is empty, we create an one element array to loop over for output
|
84
83
|
file[key] = attributes[key].empty? ? [''] : attributes[key]
|
85
84
|
end
|
86
85
|
end
|
87
|
-
|
88
86
|
end
|
89
87
|
end
|
@@ -25,13 +25,13 @@ module Sufia
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def show
|
28
|
-
if can? :read, params[
|
29
|
-
asset = ActiveFedora::Base.
|
28
|
+
if can? :read, params[:id]
|
29
|
+
asset = ActiveFedora::Base.load_instance_from_solr(params[:id])
|
30
30
|
# we can now examine @asset and determine if we should send_content, or some other action.
|
31
31
|
send_content (asset)
|
32
32
|
else
|
33
|
-
logger.info "Can not read #{params[
|
34
|
-
|
33
|
+
logger.info "Can not read #{params[:id]}"
|
34
|
+
raise Hydra::AccessDenied.new("You do not have sufficient access privileges to read this document, which has been marked private.", :read, params[:id])
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
@@ -57,12 +57,6 @@ module Sufia
|
|
57
57
|
@groups = current_user.groups
|
58
58
|
end
|
59
59
|
|
60
|
-
# routed to /files/:id
|
61
|
-
def index
|
62
|
-
@generic_files = ::GenericFile.find(:all, :rows => ::GenericFile.count)
|
63
|
-
render :json => @generic_files.map(&:to_jq_upload).to_json
|
64
|
-
end
|
65
|
-
|
66
60
|
# routed to /files/:id (DELETE)
|
67
61
|
def destroy
|
68
62
|
pid = @generic_file.noid
|
@@ -81,7 +75,7 @@ module Sufia
|
|
81
75
|
if !file
|
82
76
|
json_error "Error! No file for upload", 'unknown file', :status => :unprocessable_entity
|
83
77
|
elsif (empty_file?(file))
|
84
|
-
json_error "Error! Zero Length File!", file.original_filename
|
78
|
+
json_error "Error! Zero Length File!", file.original_filename
|
85
79
|
elsif (!terms_accepted?)
|
86
80
|
json_error "You must accept the terms of service!", file.original_filename
|
87
81
|
else
|
@@ -89,7 +83,7 @@ module Sufia
|
|
89
83
|
end
|
90
84
|
rescue => error
|
91
85
|
logger.error "GenericFilesController::create rescued #{error.class}\n\t#{error.to_s}\n #{error.backtrace.join("\n")}\n\n"
|
92
|
-
json_error "Error occurred while creating generic file."
|
86
|
+
json_error "Error occurred while creating generic file."
|
93
87
|
ensure
|
94
88
|
# remove the tempfile (only if it is a temp file)
|
95
89
|
file.tempfile.delete if file.respond_to?(:tempfile)
|
data/lib/sufia/generic_file.rb
CHANGED
@@ -13,13 +13,12 @@ module Sufia
|
|
13
13
|
autoload :Actions
|
14
14
|
autoload :Permissions
|
15
15
|
include Sufia::ModelMethods
|
16
|
-
include Sufia::Noid
|
16
|
+
include Sufia::Noid
|
17
17
|
include Sufia::GenericFile::Thumbnail
|
18
18
|
include Sufia::GenericFile::Export
|
19
19
|
include Sufia::GenericFile::Characterization
|
20
20
|
include Sufia::GenericFile::Audit
|
21
21
|
include Sufia::GenericFile::Permissions
|
22
|
-
|
23
22
|
|
24
23
|
included do
|
25
24
|
has_metadata :name => "descMetadata", :type => GenericFileRdfDatastream
|
@@ -35,14 +34,14 @@ module Sufia
|
|
35
34
|
:contributor, :title, :tag, :description, :rights,
|
36
35
|
:publisher, :date_created, :subject,
|
37
36
|
:resource_type, :identifier, :language]
|
37
|
+
|
38
38
|
around_save :characterize_if_changed, :retry_warming
|
39
39
|
before_save :remove_blank_assertions
|
40
|
-
|
41
40
|
end
|
42
41
|
|
43
42
|
def delete
|
44
|
-
|
45
|
-
|
43
|
+
self.cleanup_trophies
|
44
|
+
super
|
46
45
|
end
|
47
46
|
|
48
47
|
def remove_blank_assertions
|
@@ -95,7 +94,7 @@ module Sufia
|
|
95
94
|
# fail for good if the tries is greater than 3
|
96
95
|
raise if save_tries >=3
|
97
96
|
sleep 0.01
|
98
|
-
retry
|
97
|
+
retry
|
99
98
|
rescue ActiveResource::ResourceConflict => error
|
100
99
|
conflict_tries += 1
|
101
100
|
logger.warn "Retry caught Active Resource Conflict #{self.pid}: #{error.inspect}"
|
@@ -111,8 +110,7 @@ module Sufia
|
|
111
110
|
retry
|
112
111
|
else
|
113
112
|
raise
|
114
|
-
end
|
115
|
-
|
113
|
+
end
|
116
114
|
end
|
117
115
|
end
|
118
116
|
|
@@ -120,7 +118,6 @@ module Sufia
|
|
120
118
|
Trophy.destroy_all(generic_file_id: self.noid)
|
121
119
|
end
|
122
120
|
|
123
|
-
|
124
121
|
def related_files
|
125
122
|
relateds = begin
|
126
123
|
self.batch.generic_files
|
@@ -136,7 +133,7 @@ module Sufia
|
|
136
133
|
# Unstemmed, searchable, stored
|
137
134
|
def self.noid_indexer
|
138
135
|
@noid_indexer ||= Solrizer::Descriptor.new(:text, :indexed, :stored)
|
139
|
-
end
|
136
|
+
end
|
140
137
|
|
141
138
|
def to_solr(solr_doc={}, opts={})
|
142
139
|
super(solr_doc, opts)
|
@@ -192,6 +189,5 @@ module Sufia
|
|
192
189
|
return false if !self.batch.methods.include? :status
|
193
190
|
return (!self.batch.status.empty?) && (self.batch.status.count == 1) && (self.batch.status[0] == "processing")
|
194
191
|
end
|
195
|
-
|
196
192
|
end
|
197
193
|
end
|
@@ -19,18 +19,16 @@ module Sufia
|
|
19
19
|
title || label
|
20
20
|
end
|
21
21
|
|
22
|
-
|
23
22
|
##
|
24
23
|
# Give our SolrDocument an ActiveModel::Naming appropriate route_key
|
25
24
|
def route_key
|
26
|
-
get('
|
25
|
+
get(Solrizer.solr_name('has_model', :symbol)).split(':').last.downcase
|
27
26
|
end
|
28
27
|
|
29
|
-
|
30
28
|
##
|
31
|
-
# Offer the source (ActiveFedora-based) model to Rails for some of the
|
32
|
-
# Rails methods (e.g. link_to).
|
33
|
-
# @example
|
29
|
+
# Offer the source (ActiveFedora-based) model to Rails for some of the
|
30
|
+
# Rails methods (e.g. link_to).
|
31
|
+
# @example
|
34
32
|
# link_to '...', SolrDocument(:id => 'bXXXXXX5').new => <a href="/dams_object/bXXXXXX5">...</a>
|
35
33
|
def to_model
|
36
34
|
m = ActiveFedora::Base.load_instance_from_solr(id, self)
|
@@ -42,7 +40,6 @@ module Sufia
|
|
42
40
|
self[Solrizer.solr_name('noid', Sufia::GenericFile.noid_indexer)]
|
43
41
|
end
|
44
42
|
|
45
|
-
|
46
43
|
def date_uploaded
|
47
44
|
field = self[Solrizer.solr_name("desc_metadata__date_uploaded", :stored_sortable, type: :date)]
|
48
45
|
return unless field.present?
|
@@ -53,7 +50,6 @@ module Sufia
|
|
53
50
|
end
|
54
51
|
end
|
55
52
|
|
56
|
-
|
57
53
|
def depositor(default = '')
|
58
54
|
val = Array(self[Solrizer.solr_name("depositor")]).first
|
59
55
|
val.present? ? val : default
|
data/lib/sufia/user.rb
CHANGED
@@ -65,18 +65,13 @@ module Sufia::User
|
|
65
65
|
|
66
66
|
# method needed for trophies
|
67
67
|
def trophies
|
68
|
-
|
68
|
+
trophies = Trophy.where(:user_id => self.id)
|
69
69
|
return trophies
|
70
70
|
end
|
71
|
-
|
71
|
+
|
72
72
|
#method to get the trophy ids without the namespace included
|
73
73
|
def trophy_ids
|
74
|
-
trophies
|
75
|
-
trophies.each do |t|
|
76
|
-
@trophies << GenericFile.find("#{Sufia::Engine.config.id_namespace}:#{t.generic_file_id}")
|
77
|
-
|
78
|
-
end
|
79
|
-
return trophies
|
74
|
+
trophies.map { |t| "#{Sufia::Engine.config.id_namespace}:#{t.generic_file_id}" }
|
80
75
|
end
|
81
76
|
|
82
77
|
# method needed for messaging
|
@@ -84,7 +79,7 @@ module Sufia::User
|
|
84
79
|
return nil
|
85
80
|
end
|
86
81
|
|
87
|
-
# The basic groups method, override or will fallback to Sufia::Ldap::User
|
82
|
+
# The basic groups method, override or will fallback to Sufia::Ldap::User
|
88
83
|
def groups
|
89
84
|
return self.group_list ? self.group_list.split(";?;") : []
|
90
85
|
end
|
@@ -93,7 +88,7 @@ module Sufia::User
|
|
93
88
|
@ability ||= Ability.new(self)
|
94
89
|
end
|
95
90
|
|
96
|
-
module ClassMethods
|
91
|
+
module ClassMethods
|
97
92
|
def current
|
98
93
|
Thread.current[:user]
|
99
94
|
end
|
data/lib/sufia/version.rb
CHANGED
@@ -16,12 +16,6 @@ require 'spec_helper'
|
|
16
16
|
|
17
17
|
describe DownloadsController do
|
18
18
|
|
19
|
-
describe "routing" do
|
20
|
-
it "should route" do
|
21
|
-
assert_recognizes( {:controller=>"downloads", :action=>"show", "id"=>"test1"}, "/downloads/test1?filename=my%20dog.jpg" )
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
19
|
describe "default_datastream?" do
|
26
20
|
it "should be true when no datastram_id is passed" do
|
27
21
|
controller.should be_default_datastream
|
@@ -103,7 +97,8 @@ describe DownloadsController do
|
|
103
97
|
describe "show" do
|
104
98
|
it "should deny access" do
|
105
99
|
get "show", :id => "test1"
|
106
|
-
response.should redirect_to
|
100
|
+
response.should redirect_to root_path
|
101
|
+
flash[:alert].should == "You do not have sufficient access privileges to read this document, which has been marked private."
|
107
102
|
end
|
108
103
|
end
|
109
104
|
end
|
@@ -33,8 +33,8 @@ describe GenericFilesController do
|
|
33
33
|
begin
|
34
34
|
Batch.find("sample:batch_id").delete
|
35
35
|
rescue
|
36
|
-
end
|
37
|
-
@mock.delete unless @mock.inner_object.class == ActiveFedora::UnsavedDigitalObject
|
36
|
+
end
|
37
|
+
@mock.delete unless @mock.inner_object.class == ActiveFedora::UnsavedDigitalObject
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should render error the file wasn't actually a file" do
|
@@ -279,8 +279,8 @@ describe GenericFile do
|
|
279
279
|
local[Solrizer.solr_name("desc_metadata__part_of")].should be_nil
|
280
280
|
local[Solrizer.solr_name("desc_metadata__date_uploaded")].should be_nil
|
281
281
|
local[Solrizer.solr_name("desc_metadata__date_modified")].should be_nil
|
282
|
-
local[Solrizer.solr_name("desc_metadata__date_uploaded", :stored_sortable, type: :date)].should ==
|
283
|
-
local[Solrizer.solr_name("desc_metadata__date_modified", :stored_sortable, type: :date)].should ==
|
282
|
+
local[Solrizer.solr_name("desc_metadata__date_uploaded", :stored_sortable, type: :date)].should == '2011-01-01T00:00:00Z'
|
283
|
+
local[Solrizer.solr_name("desc_metadata__date_modified", :stored_sortable, type: :date)].should == '2012-01-01T00:00:00Z'
|
284
284
|
local[Solrizer.solr_name("desc_metadata__rights")].should == ["Wide open, buddy."]
|
285
285
|
local[Solrizer.solr_name("desc_metadata__related_url")].should be_nil
|
286
286
|
local[Solrizer.solr_name("desc_metadata__contributor")].should == ["Mohammad"]
|
data/tasks/sufia-dev.rake
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sufia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Coyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-05-
|
11
|
+
date: 2013-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -335,7 +335,6 @@ files:
|
|
335
335
|
- LICENSE.md
|
336
336
|
- README.md
|
337
337
|
- Rakefile
|
338
|
-
- app/assets/images/NoAccess.png
|
339
338
|
- app/assets/images/blacklight/bg.png
|
340
339
|
- app/assets/images/blacklight/border.png
|
341
340
|
- app/assets/images/blacklight/bul_sq_gry.gif
|
@@ -637,6 +636,7 @@ files:
|
|
637
636
|
- app/views/users/notifications_number.js.erb
|
638
637
|
- app/views/users/show.html.erb
|
639
638
|
- bin/audit_repository
|
639
|
+
- config/cucumber.yml
|
640
640
|
- config/jetty.yml
|
641
641
|
- config/locales/sufia.en.yml
|
642
642
|
- config/routes.rb
|
@@ -1003,3 +1003,4 @@ test_files:
|
|
1003
1003
|
- spec/views/single_user_link/generate_download.html.erb_spec.rb
|
1004
1004
|
- spec/views/single_user_link/generate_show.html.erb_spec.rb
|
1005
1005
|
- spec/views/single_user_link/show.html.erb_spec.rb
|
1006
|
+
has_rdoc:
|
Binary file
|