sufia 3.1.1 → 3.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9537c0a90f4be9d2b36af8a62645507199ffc77a
4
- data.tar.gz: e536d9a829d4be48d76cbbdbf2eb12a3950f044f
3
+ metadata.gz: 413ec81618f38ebb069ddb76be614f250017bbc2
4
+ data.tar.gz: 64cc681395618ad10e3ca14d94a8f85a5993d2e2
5
5
  SHA512:
6
- metadata.gz: 6f23c82aa2258904b7cf4e5d15b898f0b03b0ece32b811fe2ef8b24625e554ddae9bbb4df1e2f82f96a618974d4060264499c60759129e20e48bf02f2ba5b284
7
- data.tar.gz: 2e1a0d550205dc06fec99458409b305e527d87d605e1720bfb99c42e228008c31cbc321e8bdf57fe39356d3c7b52ea6f6ec9264e1eeb42e1c74822d503bb0ec1
6
+ metadata.gz: a255e2a1a59251ad230385c752e455ec6abeb70d7ff9955c13065875c7db0c5a8e02b55e69be71788292e1346b256e28175488d6a57d9604e08cdb304f2e91a1
7
+ data.tar.gz: f032a37d6afd48c48e9abf58240330e30ba2589dabd85f0ae42aba33025b4cf256cd310b583f22309802a29786cf3c6a688e75b4418f182e6a0568765acbfe37
data/History.md CHANGED
@@ -1,4 +1,15 @@
1
1
  # History of Sufia releases
2
+ ## 3.1.2
3
+ * Track changes on visibility [Justin Coyne]
4
+
5
+ * Use an ideomatic setter for visibility [Justin Coyne]
6
+
7
+ * Upgrade mailboxer [Justin Coyne]
8
+
9
+ * Adding a partial for the header of the dashboard to make the wording easier to
10
+ override. [Carolyn Cole]
11
+
12
+ * Improving the better migration template [Jeremy Friesen]
2
13
 
3
14
  ## 3.1.1
4
15
  * Extracting sufia generator behavior [Jeremy Friesen]
@@ -1 +1 @@
1
- 3.1.1
1
+ 3.1.2
@@ -0,0 +1 @@
1
+ <h2 class="heading1">My Dashboard</h2>
@@ -70,7 +70,7 @@ limitations under the License.
70
70
  <div class="accessible-hidden" id="current_user"><%=@user.user_key%></div>
71
71
  <div class="row">
72
72
  <%= render :partial => 'search_form' %>
73
- <h2 class="heading1">My Dashboard</h2>
73
+ <%= render :partial => 'heading' %>
74
74
  </div>
75
75
 
76
76
  <% extra_head_content << render_opensearch_response_metadata.html_safe %>
@@ -46,7 +46,7 @@ module Sufia
46
46
  def update_document(obj)
47
47
  super
48
48
  obj.date_modified = Time.now.ctime
49
- obj.set_visibility(params[:visibility])
49
+ obj.visibility = params[:visibility]
50
50
  end
51
51
 
52
52
  def update
@@ -1,18 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
- # Copyright © 2012 The Pennsylvania State University
3
- #
4
- # Licensed under the Apache License, Version 2.0 (the "License");
5
- # you may not use this file except in compliance with the License.
6
- # You may obtain a copy of the License at
7
- #
8
- # http://www.apache.org/licenses/LICENSE-2.0
9
- #
10
- # Unless required by applicable law or agreed to in writing, software
11
- # distributed under the License is distributed on an "AS IS" BASIS,
12
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- # See the License for the specific language governing permissions and
14
- # limitations under the License.
15
-
16
1
  module Sufia
17
2
  module FilesController
18
3
  autoload :LocalIngestBehavior, 'sufia/files_controller/local_ingest_behavior'
@@ -241,7 +226,7 @@ module Sufia
241
226
  # this is provided so that implementing application can override this behavior and map params to different attributes
242
227
  def update_metadata
243
228
  @generic_file.attributes = @generic_file.sanitize_attributes(params[:generic_file])
244
- @generic_file.set_visibility(params[:visibility])
229
+ @generic_file.visibility = params[:visibility]
245
230
  @generic_file.date_modified = DateTime.now
246
231
  end
247
232
 
@@ -1,3 +1,3 @@
1
1
  module Sufia
2
- VERSION = "3.1.1"
2
+ VERSION = "3.1.2"
3
3
  end
@@ -90,22 +90,38 @@ describe GenericFile do
90
90
  end
91
91
  end
92
92
 
93
+ describe "visibility" do
94
+ it "should not be changed when it's new" do
95
+ subject.should_not be_visibility_changed
96
+ end
97
+ it "should be changed when it has been changed" do
98
+ subject.visibility= 'open'
99
+ subject.should be_visibility_changed
100
+ end
101
+
102
+ it "should not be changed when it's set to its previous value" do
103
+ subject.visibility= 'private'
104
+ subject.should_not be_visibility_changed
105
+ end
106
+
107
+ end
108
+
93
109
  describe "attributes" do
94
110
  it "should have rightsMetadata" do
95
- @file.rightsMetadata.should be_instance_of ParanoidRightsDatastream
111
+ subject.rightsMetadata.should be_instance_of ParanoidRightsDatastream
96
112
  end
97
113
  it "should have properties datastream for depositor" do
98
- @file.properties.should be_instance_of PropertiesDatastream
114
+ subject.properties.should be_instance_of PropertiesDatastream
99
115
  end
100
116
  it "should have apply_depositor_metadata" do
101
- @file.rightsMetadata.edit_access.should == ['jcoyne']
102
- @file.depositor.should == 'jcoyne'
117
+ subject.rightsMetadata.edit_access.should == ['jcoyne']
118
+ subject.depositor.should == 'jcoyne'
103
119
  end
104
120
  it "should have a set of permissions" do
105
- @file.read_groups=['group1', 'group2']
106
- @file.edit_users=['user1']
107
- @file.read_users=['user2', 'user3']
108
- @file.permissions.should == [{:type=>"group", :access=>"read", :name=>"group1"},
121
+ subject.read_groups=['group1', 'group2']
122
+ subject.edit_users=['user1']
123
+ subject.read_users=['user2', 'user3']
124
+ subject.permissions.should == [{:type=>"group", :access=>"read", :name=>"group1"},
109
125
  {:type=>"group", :access=>"read", :name=>"group2"},
110
126
  {:type=>"user", :access=>"read", :name=>"user2"},
111
127
  {:type=>"user", :access=>"read", :name=>"user3"},
@@ -113,51 +129,51 @@ describe GenericFile do
113
129
  end
114
130
  describe "updating permissions" do
115
131
  it "should create new group permissions" do
116
- @file.permissions = {:new_group_name => {'group1'=>'read'}}
117
- @file.permissions.should == [{:type=>"group", :access=>"read", :name=>"group1"},
132
+ subject.permissions = {:new_group_name => {'group1'=>'read'}}
133
+ subject.permissions.should == [{:type=>"group", :access=>"read", :name=>"group1"},
118
134
  {:type=>"user", :access=>"edit", :name=>"jcoyne"}]
119
135
  end
120
136
  it "should create new user permissions" do
121
- @file.permissions = {:new_user_name => {'user1'=>'read'}}
122
- @file.permissions.should == [{:type=>"user", :access=>"read", :name=>"user1"},
137
+ subject.permissions = {:new_user_name => {'user1'=>'read'}}
138
+ subject.permissions.should == [{:type=>"user", :access=>"read", :name=>"user1"},
123
139
  {:type=>"user", :access=>"edit", :name=>"jcoyne"}]
124
140
  end
125
141
  it "should not replace existing groups" do
126
- @file.permissions = {:new_group_name=> {'group1' => 'read'}}
127
- @file.permissions = {:new_group_name=> {'group2' => 'read'}}
128
- @file.permissions.should == [{:type=>"group", :access=>"read", :name=>"group1"},
142
+ subject.permissions = {:new_group_name=> {'group1' => 'read'}}
143
+ subject.permissions = {:new_group_name=> {'group2' => 'read'}}
144
+ subject.permissions.should == [{:type=>"group", :access=>"read", :name=>"group1"},
129
145
  {:type=>"group", :access=>"read", :name=>"group2"},
130
146
  {:type=>"user", :access=>"edit", :name=>"jcoyne"}]
131
147
  end
132
148
  it "should not replace existing users" do
133
- @file.permissions = {:new_user_name=>{'user1'=>'read'}}
134
- @file.permissions = {:new_user_name=>{'user2'=>'read'}}
135
- @file.permissions.should == [{:type=>"user", :access=>"read", :name=>"user1"},
149
+ subject.permissions = {:new_user_name=>{'user1'=>'read'}}
150
+ subject.permissions = {:new_user_name=>{'user2'=>'read'}}
151
+ subject.permissions.should == [{:type=>"user", :access=>"read", :name=>"user1"},
136
152
  {:type=>"user", :access=>"read", :name=>"user2"},
137
153
  {:type=>"user", :access=>"edit", :name=>"jcoyne"}]
138
154
  end
139
155
  it "should update permissions on existing users" do
140
- @file.permissions = {:new_user_name=>{'user1'=>'read'}}
141
- @file.permissions = {:user=>{'user1'=>'edit'}}
142
- @file.permissions.should == [{:type=>"user", :access=>"edit", :name=>"user1"},
156
+ subject.permissions = {:new_user_name=>{'user1'=>'read'}}
157
+ subject.permissions = {:user=>{'user1'=>'edit'}}
158
+ subject.permissions.should == [{:type=>"user", :access=>"edit", :name=>"user1"},
143
159
  {:type=>"user", :access=>"edit", :name=>"jcoyne"}]
144
160
  end
145
161
  it "should update permissions on existing groups" do
146
- @file.permissions = {:new_group_name=>{'group1'=>'read'}}
147
- @file.permissions = {:group=>{'group1'=>'edit'}}
148
- @file.permissions.should == [{:type=>"group", :access=>"edit", :name=>"group1"},
162
+ subject.permissions = {:new_group_name=>{'group1'=>'read'}}
163
+ subject.permissions = {:group=>{'group1'=>'edit'}}
164
+ subject.permissions.should == [{:type=>"group", :access=>"edit", :name=>"group1"},
149
165
  {:type=>"user", :access=>"edit", :name=>"jcoyne"}]
150
166
  end
151
167
  end
152
168
  it "should have a characterization datastream" do
153
- @file.characterization.should be_kind_of FitsDatastream
169
+ subject.characterization.should be_kind_of FitsDatastream
154
170
  end
155
171
  it "should have a dc desc metadata" do
156
- @file.descMetadata.should be_kind_of GenericFileRdfDatastream
172
+ subject.descMetadata.should be_kind_of GenericFileRdfDatastream
157
173
  end
158
174
  it "should have content datastream" do
159
- @file.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
160
- @file.content.should be_kind_of FileContentDatastream
175
+ subject.add_file(File.open(fixture_path + '/world.png'), 'content', 'world.png')
176
+ subject.content.should be_kind_of FileContentDatastream
161
177
  end
162
178
  end
163
179
  describe "delegations" do
@@ -1,16 +1,3 @@
1
- # Copyright © 2012 The Pennsylvania State University
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
1
  class GenericFile < ActiveFedora::Base
15
2
  include Sufia::GenericFile
16
3
  end
@@ -20,10 +20,14 @@ This generator makes the following changes to your application:
20
20
  # Implement the required interface for Rails::Generators::Migration.
21
21
  # taken from http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
22
22
  def self.next_migration_number(path)
23
- unless @prev_migration_nr
24
- @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
25
- else
23
+ if @prev_migration_nr
26
24
  @prev_migration_nr += 1
25
+ else
26
+ if last_migration = Dir[File.join(path, '*.rb')].sort.last
27
+ @prev_migration_nr = last_migration.sub(File.join(path, '/'), '').to_i + 1
28
+ else
29
+ @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
30
+ end
27
31
  end
28
32
  @prev_migration_nr.to_s
29
33
  end
@@ -42,8 +46,8 @@ This generator makes the following changes to your application:
42
46
  "add_groups_to_users.rb",
43
47
  "create_local_authorities.rb",
44
48
  "create_trophies.rb"
45
- ].each do |f|
46
- better_migration_template f
49
+ ].each do |file|
50
+ better_migration_template file
47
51
  end
48
52
  end
49
53
 
@@ -88,12 +92,7 @@ This generator makes the following changes to your application:
88
92
  private
89
93
 
90
94
  def better_migration_template(file)
91
- begin
92
- migration_template "migrations/#{file}", "db/migrate/#{file}"
93
- sleep 1 # ensure scripts have different time stamps
94
- rescue
95
- puts " \e[1m\e[34mMigrations\e[0m " + $!.message
96
- end
95
+ migration_template "migrations/#{file}", "db/migrate/#{file}"
97
96
  end
98
97
 
99
98
  end
@@ -46,13 +46,11 @@ module Sufia
46
46
  require 'sufia/models/noid'
47
47
  require 'sufia/models/file_content'
48
48
  require 'sufia/models/file_content/versions'
49
- require 'sufia/models/generic_file/actions'
50
49
  require 'sufia/models/generic_file/audit'
51
50
  require 'sufia/models/generic_file/characterization'
52
51
  require 'sufia/models/generic_file/derivatives'
53
52
  require 'sufia/models/generic_file/export'
54
53
  require 'sufia/models/generic_file/mime_types'
55
- require 'sufia/models/generic_file/permissions'
56
54
  require 'sufia/models/generic_file/thumbnail'
57
55
  require 'sufia/models/generic_file'
58
56
  require 'sufia/models/user'
@@ -2,8 +2,9 @@ module Sufia
2
2
  module GenericFile
3
3
  extend ActiveSupport::Concern
4
4
  extend ActiveSupport::Autoload
5
- autoload :Actions
6
- autoload :Permissions
5
+ autoload :Actions, 'sufia/models/generic_file/actions'
6
+ autoload :Permissions, 'sufia/models/generic_file/permissions'
7
+ autoload :Visibility, 'sufia/models/generic_file/visibility'
7
8
  autoload :WebForm, 'sufia/models/generic_file/web_form'
8
9
  autoload :AccessibleAttributes, 'sufia/models/generic_file/accessible_attributes'
9
10
  include Sufia::ModelMethods
@@ -4,26 +4,13 @@ module Sufia
4
4
  extend ActiveSupport::Concern
5
5
  #we're overriding the permissions= method which is in RightsMetadata
6
6
  include Hydra::ModelMixins::RightsMetadata
7
+ include Sufia::GenericFile::Visibility
8
+
7
9
  included do
8
10
  has_metadata :name => "rightsMetadata", :type => ParanoidRightsDatastream
9
11
  validate :paranoid_permissions
10
12
  end
11
13
 
12
- def set_visibility(visibility)
13
- # only set explicit permissions
14
- case visibility
15
- when "open"
16
- self.datastreams["rightsMetadata"].permissions({:group=>"public"}, "read")
17
- when "psu"
18
- self.datastreams["rightsMetadata"].permissions({:group=>"registered"}, "read")
19
- self.datastreams["rightsMetadata"].permissions({:group=>"public"}, "none")
20
- when "restricted"
21
- self.datastreams["rightsMetadata"].permissions({:group=>"registered"}, "none")
22
- self.datastreams["rightsMetadata"].permissions({:group=>"public"}, "none")
23
- end
24
- end
25
-
26
-
27
14
  def paranoid_permissions
28
15
  # let the rightsMetadata ds make this determination
29
16
  # - the object instance is passed in for easier access to the props ds
@@ -57,8 +44,6 @@ module Sufia
57
44
  end
58
45
  {'person'=>user_perms, 'group'=>group_perms}
59
46
  end
60
-
61
-
62
47
  end
63
48
  end
64
49
  end
@@ -0,0 +1,59 @@
1
+ module Sufia
2
+ module GenericFile
3
+ module Visibility
4
+ extend ActiveSupport::Concern
5
+ extend Deprecation
6
+ include ActiveModel::Dirty
7
+
8
+ included do
9
+ define_attribute_methods :visibility
10
+ end
11
+
12
+ def visibility= (value)
13
+ # only set explicit permissions
14
+ case value
15
+ when "open"
16
+ public_visibility!
17
+ when "psu"
18
+ registered_visibility!
19
+ when "restricted"
20
+ private_visibility!
21
+ end
22
+ end
23
+
24
+ def public_visibility!
25
+ visibility_will_change! unless visibility == 'public'
26
+ self.datastreams["rightsMetadata"].permissions({:group=>"public"}, "read")
27
+ end
28
+
29
+ def registered_visibility!
30
+ visibility_will_change! unless visibility == 'registered'
31
+ self.datastreams["rightsMetadata"].permissions({:group=>"registered"}, "read")
32
+ self.datastreams["rightsMetadata"].permissions({:group=>"public"}, "none")
33
+ end
34
+
35
+ def private_visibility!
36
+ visibility_will_change! unless visibility == 'private'
37
+ self.datastreams["rightsMetadata"].permissions({:group=>"registered"}, "none")
38
+ self.datastreams["rightsMetadata"].permissions({:group=>"public"}, "none")
39
+ end
40
+
41
+ def visibility
42
+ if read_groups.include? 'public'
43
+ 'public'
44
+ elsif read_groups.include? 'registered'
45
+ 'registered'
46
+ else
47
+ 'private'
48
+ end
49
+ end
50
+
51
+ def set_visibility(visibility)
52
+ Deprecation.warn Permissions, "set_visibility is deprecated, use visibility= instead. set_visibility will be removed in sufia 3.0", caller
53
+ self.visibility= visibility
54
+ end
55
+ end
56
+ end
57
+ end
58
+
59
+
@@ -1,17 +1,3 @@
1
- # Copyright © 2012 The Pennsylvania State University
2
- #
3
- # Licensed under the Apache License, Version 2.0 (the "License");
4
- # you may not use this file except in compliance with the License.
5
- # You may obtain a copy of the License at
6
- #
7
- # http://www.apache.org/licenses/LICENSE-2.0
8
- #
9
- # Unless required by applicable law or agreed to in writing, software
10
- # distributed under the License is distributed on an "AS IS" BASIS,
11
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- # See the License for the specific language governing permissions and
13
- # limitations under the License.
14
-
15
1
  class BatchUpdateJob
16
2
  include Hydra::PermissionsQuery
17
3
  include Rails.application.routes.url_helpers
@@ -60,7 +46,7 @@ class BatchUpdateJob
60
46
  end
61
47
  gf.title = title[gf.pid] if title[gf.pid] rescue gf.label
62
48
  gf.attributes=file_attributes
63
- gf.set_visibility(visibility)
49
+ gf.visibility= visibility
64
50
 
65
51
  save_tries = 0
66
52
  begin
@@ -1,5 +1,5 @@
1
1
  module Sufia
2
2
  module Models
3
- VERSION = "3.1.1"
3
+ VERSION = "3.1.2"
4
4
  end
5
5
  end
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_dependency 'resque', '~> 1.23.0'#, :require => 'resque/server'
37
37
  spec.add_dependency 'resque-pool', '0.3.0'
38
38
  spec.add_dependency 'noid', '~> 0.6.6'
39
- spec.add_dependency 'curationexperts-mailboxer', '0.10.3'
39
+ spec.add_dependency 'mailboxer', '~> 0.11.0'
40
40
  spec.add_dependency 'acts_as_follower', '0.1.1'
41
41
  spec.add_dependency 'paperclip', '~> 3.4.0'
42
42
  spec.add_dependency 'zipruby', '0.3.6'
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: 3.1.1
4
+ version: 3.1.2
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-08-20 00:00:00.000000000 Z
11
+ date: 2013-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sufia-models
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.1.1
19
+ version: 3.1.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 3.1.1
26
+ version: 3.1.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: blacklight
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -376,6 +376,7 @@ files:
376
376
  - app/views/dashboard/_facet_pagination.html.erb
377
377
  - app/views/dashboard/_facet_selected.html.erb
378
378
  - app/views/dashboard/_facets.html.erb
379
+ - app/views/dashboard/_heading.html.erb
379
380
  - app/views/dashboard/_index_partials/_default_group.html.erb
380
381
  - app/views/dashboard/_index_partials/_list_files.html.erb
381
382
  - app/views/dashboard/_index_partials/_thumbnail_display.html.erb
@@ -670,6 +671,7 @@ files:
670
671
  - sufia-models/lib/sufia/models/generic_file/mime_types.rb
671
672
  - sufia-models/lib/sufia/models/generic_file/permissions.rb
672
673
  - sufia-models/lib/sufia/models/generic_file/thumbnail.rb
674
+ - sufia-models/lib/sufia/models/generic_file/visibility.rb
673
675
  - sufia-models/lib/sufia/models/generic_file/web_form.rb
674
676
  - sufia-models/lib/sufia/models/id_service.rb
675
677
  - sufia-models/lib/sufia/models/jobs/active_fedora_pid_based_job.rb