sufia 0.0.8 → 0.1.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.
data/Gemfile CHANGED
@@ -3,6 +3,7 @@ source 'http://rubygems.org'
3
3
  # Please see sufia.gemspec for dependency information.
4
4
  gemspec
5
5
 
6
+ gem 'hydra-head', github: 'projecthydra/hydra-head'
6
7
  #gem 'mail_form', :git => 'git://github.com/psu-stewardship/mail_form.git', :ref => '50c00f0'
7
8
  group :development, :test do
8
9
  gem 'sqlite3'
@@ -69,7 +69,7 @@ class UsersController < ApplicationController
69
69
  def toggle_trophy
70
70
  id = params[:file_id]
71
71
  id = "#{Sufia::Engine.config.id_namespace}:#{id}" unless id.include?(":")
72
- unless current_user.can? :edit, permissions_solr_doc_for_id(id)
72
+ unless current_user.can? :edit, id
73
73
  redirect_to root_path, alert: "You do not have permissions to the file"
74
74
  return false
75
75
  end
@@ -1,6 +1,2 @@
1
1
  <%# render :partial=>'search_form' %>
2
2
  <%= render :partial=>'home_text' %>
3
-
4
- <% sidebar_items << capture do %>
5
- <%= render :partial=>'facets' %>
6
- <% end %>
@@ -18,8 +18,5 @@
18
18
  <div class="<%= params[:action]%>_details">
19
19
  <%= render :partial => "#{params[:controller]}/_#{params[:action]}_partials/default_details", :locals => {:document => document}%>
20
20
  </div>
21
- <% sidebar_items << capture do %>
22
- <%#= render :partial=>"catalog/_show_partials/facets", :locals=>{:document=>document, :facets_display_heading => "This document refers to:"} %>
23
- <% end %>
24
21
 
25
22
  <%= async_load_tag(hydra_asset_downloads_path(params[:id]), 'downloads') %>
@@ -3,10 +3,9 @@
3
3
  //$.ui.dialog.prototype.options["height"]=window.innerHeight *0.75
4
4
  <% end %>
5
5
 
6
- <!--div id="sidebar" class="span3">
7
- <%#= render :partial=>'facets' %>
8
- </div--><!--/well -->
9
-
6
+ <% content_for :sidebar do %>
7
+ <%= render :partial=>'facets' %>
8
+ <% end %>
10
9
 
11
10
  <% unless has_search_parameters? %>
12
11
  <%# if there are no input/search related params, display the "home" partial -%>
@@ -36,10 +35,6 @@
36
35
 
37
36
  <%= render :partial => 'document_list' %>
38
37
 
39
- <% sidebar_items << capture do %>
40
- <%= render :partial=>'facets' %>
41
- <% end %>
42
-
43
38
  <%= render 'results_pagination' %>
44
39
 
45
40
  <% end %>
@@ -34,8 +34,5 @@ limitations under the License.
34
34
  <div class="<%= params[:action]%>_details">
35
35
  <%= render :partial => "#{params[:controller]}/_#{params[:action]}_partials/default_details", :locals => {:document => document}%>
36
36
  </div>
37
- <% sidebar_items << capture do %>
38
- <%#= render :partial=>"catalog/_show_partials/facets", :locals=>{:document=>document, :facets_display_heading => "This document refers to:"} %>
39
- <% end %>
40
37
 
41
38
  <%= async_load_tag(hydra_asset_downloads_path(params[:id]), 'downloads') %>
@@ -1,7 +1,7 @@
1
1
  <!-- This was copied from https://github.com/projectblacklight/blacklight/blob/master/app/views/catalog/facet.html.erb
2
2
  It implements the facets in the same manner as blacklight does for the main catalog for the individual's dashbord
3
3
  -->
4
- <% sidebar_items << capture do %>
4
+ <% content_for :sidebar do %>
5
5
  <p><%= link_back_to_catalog %></p>
6
6
  <% end %>
7
7
 
@@ -179,7 +179,7 @@ z-index:1;
179
179
  <%= render 'sort_and_per_page' %>
180
180
 
181
181
  <%= render :partial=>'dashboard/document_list' %>
182
- <% sidebar_items << capture do %>
182
+ <% content_for :sidebar do %>
183
183
  <%= render :partial=>'facets' %>
184
184
  <% end %>
185
185
 
@@ -68,7 +68,7 @@ limitations under the License.
68
68
  </div>
69
69
  <% else %>
70
70
  <div class="span17">
71
- <%= sidebar_items.join('').html_safe %>
71
+ <%= yield :sidebar %>
72
72
  </div><!-- /.span17 -->
73
73
  <% if column_class == "three" %>
74
74
  <div class="span63">
@@ -54,17 +54,6 @@ module Sufia::Controller
54
54
  end
55
55
 
56
56
  protected
57
- # Returns the solr permissions document for the given id
58
- # @return solr permissions document
59
- # @example This is the document that you can pass into permissions enforcement methods like 'can?'
60
- # gf = GenericFile.find(params[:id])
61
- # if can? :read, permissions_solr_doc_for_id(gf.pid)
62
- # gf.update_attributes(params[:generic_file])
63
- # end
64
- def permissions_solr_doc_for_id(id)
65
- permissions_solr_response, permissions_solr_document = get_permissions_solr_response_for_doc_id(id)
66
- return permissions_solr_document
67
- end
68
57
 
69
58
  ### Hook which is overridden in Sufia::Ldap::Controller
70
59
  def has_access?
@@ -98,7 +98,8 @@ module Sufia
98
98
  @generic_file = ::GenericFile.new
99
99
  # Relative path is set by the jquery uploader when uploading a directory
100
100
  @generic_file.relative_path = params[:relative_path] if params[:relative_path]
101
- Sufia::GenericFile::Actions.create(@generic_file, file, params[:batch_id], file.original_filename, datastream_id, current_user)
101
+ Sufia::GenericFile::Actions.create_metadata(@generic_file, current_user, params[:batch_id])
102
+ Sufia::GenericFile::Actions.create_content(@generic_file, file, file.original_filename, datastream_id, current_user)
102
103
  respond_to do |format|
103
104
  format.html {
104
105
  retval = render :json => [@generic_file.to_jq_upload].to_json,
@@ -110,7 +111,6 @@ module Sufia
110
111
  }
111
112
  end
112
113
  else
113
- puts "Returned false"
114
114
  retval = render :json => [{:error => "Error creating generic file."}].to_json
115
115
  end
116
116
  end
@@ -1,8 +1,7 @@
1
1
  module Sufia::GenericFile
2
2
  # Actions are decoupled from controller logic so that they may be called from a controller or a background job.
3
3
  module Actions
4
- def self.create(generic_file, file, batch_id, file_name, dsid, user)
5
- generic_file.add_file(file, dsid, file_name)
4
+ def self.create_metadata(generic_file, user, batch_id)
6
5
 
7
6
  generic_file.apply_depositor_metadata(user.user_key)
8
7
  generic_file.date_uploaded = Date.today
@@ -14,6 +13,11 @@ module Sufia::GenericFile
14
13
  else
15
14
  logger.warn "unable to find batch to attach to"
16
15
  end
16
+ generic_file.save!
17
+ end
18
+
19
+ def self.create_content(generic_file, file, file_name, dsid, user)
20
+ generic_file.add_file(file, dsid, file_name)
17
21
 
18
22
  save_tries = 0
19
23
  begin
@@ -54,7 +54,7 @@ class BatchUpdateJob
54
54
  end
55
55
 
56
56
  def update_file(gf, user)
57
- unless user.can? :edit, get_permissions_solr_response_for_doc_id(gf.pid)[1]
57
+ unless user.can? :edit, gf
58
58
  logger.error "User #{user.user_key} DEEEENIED access to #{gf.pid}!"
59
59
  @denied << gf
60
60
  return
@@ -25,7 +25,7 @@ class ContentDepositEventJob < EventJob
25
25
  # Log the event to the GF's stream
26
26
  gf.log_event(event)
27
27
  # Fan out the event to all followers who have access
28
- depositor.followers.select { |user| user.can? :read, get_permissions_solr_response_for_doc_id(gf.pid)[1] }.each do |follower|
28
+ depositor.followers.select { |user| user.can? :read, gf }.each do |follower|
29
29
  follower.log_event(event)
30
30
  end
31
31
  end
@@ -25,7 +25,7 @@ class ContentNewVersionEventJob < EventJob
25
25
  # Log the event to the GF's stream
26
26
  gf.log_event(event)
27
27
  # Fan out the event to all followers who have access
28
- depositor.followers.select { |user| user.can? :read, get_permissions_solr_response_for_doc_id(gf.pid)[1] }.each do |follower|
28
+ depositor.followers.select { |user| user.can? :read, gf }.each do |follower|
29
29
  follower.log_event(event)
30
30
  end
31
31
  end
@@ -33,7 +33,7 @@ class ContentRestoredVersionEventJob < EventJob
33
33
  # Log the event to the GF's stream
34
34
  gf.log_event(event)
35
35
  # Fan out the event to all followers who have access
36
- depositor.followers.select { |user| user.can? :read, get_permissions_solr_response_for_doc_id(gf.pid)[1] }.each do |follower|
36
+ depositor.followers.select { |user| user.can? :read, gf }.each do |follower|
37
37
  follower.log_event(event)
38
38
  end
39
39
  end
@@ -25,7 +25,7 @@ class ContentUpdateEventJob < EventJob
25
25
  # Log the event to the GF's stream
26
26
  gf.log_event(event)
27
27
  # Fan out the event to all followers who have access
28
- depositor.followers.select { |user| user.can? :read, get_permissions_solr_response_for_doc_id(gf.pid)[1] }.each do |follower|
28
+ depositor.followers.select { |user| user.can? :read, gf }.each do |follower|
29
29
  follower.log_event(event)
30
30
  end
31
31
  end
data/lib/sufia/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Sufia
2
- VERSION = "0.0.8"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -41,6 +41,11 @@ describe BatchController do
41
41
  @file.delete
42
42
  @file2.delete
43
43
  end
44
+ it "should not be editable" do
45
+ ability = Ability.new(@user)
46
+ ability.can?(:edit, @file).should be_true
47
+ ability.can?(:edit, @file2).should be_false
48
+ end
44
49
  it "should equeue a batch update job" do
45
50
  params = {'generic_file' => {'read_groups_string' => '', 'read_users_string' => 'archivist1, archivist2', 'tag' => ['']}, 'id' => @batch.pid, 'controller' => 'batch', 'action' => 'update'}
46
51
  s1 = stub('one')
@@ -34,8 +34,8 @@ describe BatchUpdateJob do
34
34
  end
35
35
  describe "failing update" do
36
36
  it "should check permissions for each file before updating" do
37
- BatchUpdateJob.any_instance.stub(:get_permissions_solr_response_for_doc_id).and_return(["","mock solr permissions"])
38
- User.any_instance.should_receive(:can?).with(:edit, "mock solr permissions").exactly(2).times
37
+ User.any_instance.should_receive(:can?).with(:edit, @file).and_return(false)
38
+ User.any_instance.should_receive(:can?).with(:edit, @file2).and_return(false)
39
39
  params = {'generic_file' => {'read_groups_string' => '', 'read_users_string' => 'archivist1, archivist2', 'tag' => ['']}, 'id' => @batch.pid, 'controller' => 'batch', 'action' => 'update'}.with_indifferent_access
40
40
  BatchUpdateJob.new(@user.user_key, params).run
41
41
  @user.mailbox.inbox[0].messages[0].subject.should == "Batch upload permission denied"
@@ -45,8 +45,8 @@ describe BatchUpdateJob do
45
45
  end
46
46
  describe "passing update" do
47
47
  it "should log a content update event" do
48
- BatchUpdateJob.any_instance.stub(:get_permissions_solr_response_for_doc_id).and_return(["","mock solr permissions"])
49
- User.any_instance.should_receive(:can?).with(:edit, "mock solr permissions").exactly(2).times.and_return(true)
48
+ User.any_instance.should_receive(:can?).with(:edit, @file).and_return(true)
49
+ User.any_instance.should_receive(:can?).with(:edit, @file2).and_return(true)
50
50
  s1 = stub('one')
51
51
  ContentUpdateEventJob.should_receive(:new).with(@file.pid, @user.user_key).and_return(s1)
52
52
  Sufia.queue.should_receive(:push).with(s1).once
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sufia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,14 +9,14 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-28 00:00:00.000000000 Z
12
+ date: 2013-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - "~>"
20
20
  - !ruby/object:Gem::Version
21
21
  version: 3.2.8
22
22
  type: :runtime
@@ -24,7 +24,7 @@ dependencies:
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - "~>"
28
28
  - !ruby/object:Gem::Version
29
29
  version: 3.2.8
30
30
  - !ruby/object:Gem::Dependency
@@ -32,7 +32,7 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ~>
35
+ - - "~>"
36
36
  - !ruby/object:Gem::Version
37
37
  version: 4.0.0
38
38
  type: :runtime
@@ -40,7 +40,7 @@ dependencies:
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ~>
43
+ - - "~>"
44
44
  - !ruby/object:Gem::Version
45
45
  version: 4.0.0
46
46
  - !ruby/object:Gem::Dependency
@@ -48,7 +48,7 @@ dependencies:
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - ! '>='
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  type: :runtime
@@ -56,7 +56,7 @@ dependencies:
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  - !ruby/object:Gem::Dependency
@@ -64,7 +64,7 @@ dependencies:
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
- - - ! '>='
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '5.3'
70
70
  type: :runtime
@@ -72,7 +72,7 @@ dependencies:
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
- - - ! '>='
75
+ - - ">="
76
76
  - !ruby/object:Gem::Version
77
77
  version: '5.3'
78
78
  - !ruby/object:Gem::Dependency
@@ -80,7 +80,7 @@ dependencies:
80
80
  requirement: !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
83
- - - ! '>='
83
+ - - ">="
84
84
  - !ruby/object:Gem::Version
85
85
  version: '5.5'
86
86
  type: :runtime
@@ -88,7 +88,7 @@ dependencies:
88
88
  version_requirements: !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
- - - ! '>='
91
+ - - ">="
92
92
  - !ruby/object:Gem::Version
93
93
  version: '5.5'
94
94
  - !ruby/object:Gem::Dependency
@@ -112,7 +112,7 @@ dependencies:
112
112
  requirement: !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: 0.1.0
118
118
  type: :runtime
@@ -120,7 +120,7 @@ dependencies:
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  none: false
122
122
  requirements:
123
- - - ~>
123
+ - - "~>"
124
124
  - !ruby/object:Gem::Version
125
125
  version: 0.1.0
126
126
  - !ruby/object:Gem::Dependency
@@ -128,7 +128,7 @@ dependencies:
128
128
  requirement: !ruby/object:Gem::Requirement
129
129
  none: false
130
130
  requirements:
131
- - - ~>
131
+ - - "~>"
132
132
  - !ruby/object:Gem::Version
133
133
  version: 1.23.0
134
134
  type: :runtime
@@ -136,7 +136,7 @@ dependencies:
136
136
  version_requirements: !ruby/object:Gem::Requirement
137
137
  none: false
138
138
  requirements:
139
- - - ~>
139
+ - - "~>"
140
140
  - !ruby/object:Gem::Version
141
141
  version: 1.23.0
142
142
  - !ruby/object:Gem::Dependency
@@ -176,7 +176,7 @@ dependencies:
176
176
  requirement: !ruby/object:Gem::Requirement
177
177
  none: false
178
178
  requirements:
179
- - - ! '>='
179
+ - - ">="
180
180
  - !ruby/object:Gem::Version
181
181
  version: '0'
182
182
  type: :runtime
@@ -184,7 +184,7 @@ dependencies:
184
184
  version_requirements: !ruby/object:Gem::Requirement
185
185
  none: false
186
186
  requirements:
187
- - - ! '>='
187
+ - - ">="
188
188
  - !ruby/object:Gem::Version
189
189
  version: '0'
190
190
  - !ruby/object:Gem::Dependency
@@ -240,7 +240,7 @@ dependencies:
240
240
  requirement: !ruby/object:Gem::Requirement
241
241
  none: false
242
242
  requirements:
243
- - - ! '>='
243
+ - - ">="
244
244
  - !ruby/object:Gem::Version
245
245
  version: '0'
246
246
  type: :runtime
@@ -248,7 +248,7 @@ dependencies:
248
248
  version_requirements: !ruby/object:Gem::Requirement
249
249
  none: false
250
250
  requirements:
251
- - - ! '>='
251
+ - - ">="
252
252
  - !ruby/object:Gem::Version
253
253
  version: '0'
254
254
  - !ruby/object:Gem::Dependency
@@ -368,7 +368,7 @@ dependencies:
368
368
  requirement: !ruby/object:Gem::Requirement
369
369
  none: false
370
370
  requirements:
371
- - - ! '>='
371
+ - - ">="
372
372
  - !ruby/object:Gem::Version
373
373
  version: '0'
374
374
  type: :runtime
@@ -376,7 +376,7 @@ dependencies:
376
376
  version_requirements: !ruby/object:Gem::Requirement
377
377
  none: false
378
378
  requirements:
379
- - - ! '>='
379
+ - - ">="
380
380
  - !ruby/object:Gem::Version
381
381
  version: '0'
382
382
  - !ruby/object:Gem::Dependency
@@ -384,7 +384,7 @@ dependencies:
384
384
  requirement: !ruby/object:Gem::Requirement
385
385
  none: false
386
386
  requirements:
387
- - - ~>
387
+ - - "~>"
388
388
  - !ruby/object:Gem::Version
389
389
  version: '2.0'
390
390
  type: :runtime
@@ -392,7 +392,7 @@ dependencies:
392
392
  version_requirements: !ruby/object:Gem::Requirement
393
393
  none: false
394
394
  requirements:
395
- - - ~>
395
+ - - "~>"
396
396
  - !ruby/object:Gem::Version
397
397
  version: '2.0'
398
398
  description: Sufia is a Rails engine for creating a self-deposit institutional repository
@@ -403,9 +403,9 @@ executables:
403
403
  extensions: []
404
404
  extra_rdoc_files: []
405
405
  files:
406
- - .gitignore
407
- - .gitmodules
408
- - .rspec
406
+ - ".gitignore"
407
+ - ".gitmodules"
408
+ - ".rspec"
409
409
  - Gemfile
410
410
  - LICENSE.md
411
411
  - README.md
@@ -933,18 +933,18 @@ require_paths:
933
933
  required_ruby_version: !ruby/object:Gem::Requirement
934
934
  none: false
935
935
  requirements:
936
- - - ! '>='
936
+ - - ">="
937
937
  - !ruby/object:Gem::Version
938
938
  version: '0'
939
939
  required_rubygems_version: !ruby/object:Gem::Requirement
940
940
  none: false
941
941
  requirements:
942
- - - ! '>='
942
+ - - ">="
943
943
  - !ruby/object:Gem::Version
944
944
  version: '0'
945
945
  requirements: []
946
946
  rubyforge_project:
947
- rubygems_version: 1.8.24
947
+ rubygems_version: 1.8.25
948
948
  signing_key:
949
949
  specification_version: 3
950
950
  summary: Sufia was extracted from ScholarSphere developed by Penn State University