sufia 3.1.0 → 3.2.1

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.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +44 -0
  3. data/SUFIA_VERSION +1 -1
  4. data/app/controllers/authorities_controller.rb +0 -14
  5. data/app/controllers/batch_controller.rb +0 -14
  6. data/app/controllers/contact_form_controller.rb +0 -14
  7. data/app/controllers/dashboard_controller.rb +0 -14
  8. data/app/controllers/directory_controller.rb +0 -14
  9. data/app/controllers/downloads_controller.rb +0 -14
  10. data/app/controllers/errors_controller.rb +0 -14
  11. data/app/controllers/generic_files_controller.rb +0 -14
  12. data/app/controllers/mailbox_controller.rb +0 -14
  13. data/app/controllers/static_controller.rb +0 -14
  14. data/app/controllers/users_controller.rb +0 -14
  15. data/app/helpers/blacklight/render_constraints_helper_behavior.rb +0 -14
  16. data/app/helpers/contact_form_helper.rb +0 -14
  17. data/app/helpers/generic_file_helper.rb +0 -14
  18. data/app/helpers/sufia_helper.rb +0 -14
  19. data/app/helpers/trophy_helper.rb +0 -14
  20. data/app/jobs/content_delete_event_job.rb +0 -14
  21. data/app/jobs/content_deposit_event_job.rb +0 -14
  22. data/app/jobs/content_new_version_event_job.rb +0 -14
  23. data/app/jobs/content_restored_version_event_job.rb +0 -14
  24. data/app/jobs/content_update_event_job.rb +0 -14
  25. data/app/jobs/event_job.rb +0 -14
  26. data/app/jobs/user_edit_profile_event_job.rb +0 -14
  27. data/app/jobs/user_follow_event_job.rb +0 -14
  28. data/app/jobs/user_unfollow_event_job.rb +0 -14
  29. data/app/views/dashboard/_heading.html.erb +1 -0
  30. data/app/views/dashboard/index.html.erb +1 -1
  31. data/app/views/generic_files/_permission_form.html.erb +3 -3
  32. data/db/seeds.rb +0 -14
  33. data/lib/generators/sufia/sufia_generator.rb +18 -85
  34. data/lib/generators/sufia/templates/catalog_controller.rb +0 -14
  35. data/lib/generators/sufia/templates/config/action_dispatch_http_upload_monkey_patch.rb +0 -14
  36. data/lib/generators/sufia/templates/migrations/acts_as_follower_migration.rb +0 -14
  37. data/lib/generators/sufia/templates/migrations/add_avatars_to_users.rb +0 -14
  38. data/lib/generators/sufia/templates/migrations/add_groups_to_users.rb +0 -14
  39. data/lib/generators/sufia/templates/migrations/add_ldap_attrs_to_user.rb +0 -14
  40. data/lib/generators/sufia/templates/migrations/add_social_to_users.rb +0 -14
  41. data/lib/generators/sufia/templates/migrations/create_checksum_audit_logs.rb +0 -14
  42. data/lib/generators/sufia/templates/migrations/create_local_authorities.rb +0 -14
  43. data/lib/generators/sufia/templates/migrations/create_version_committers.rb +0 -14
  44. data/lib/sufia/batch_edits_controller_behavior.rb +1 -1
  45. data/lib/sufia/contact_form_controller_behavior.rb +0 -14
  46. data/lib/sufia/controller.rb +1 -15
  47. data/lib/sufia/downloads_controller_behavior.rb +0 -14
  48. data/lib/sufia/files_controller/upload_complete_behavior.rb +5 -0
  49. data/lib/sufia/files_controller_behavior.rb +3 -17
  50. data/lib/sufia/role_mapper.rb +0 -14
  51. data/lib/sufia/version.rb +1 -1
  52. data/lib/tasks/fixtures.rake +0 -14
  53. data/spec/factories/checksum_audit_logs.rb +0 -14
  54. data/spec/lib/sufia/upload_complete_behavior_spec.rb +10 -0
  55. data/spec/models/access_right_spec.rb +57 -0
  56. data/spec/models/generic_file/visibility_spec.rb +19 -0
  57. data/spec/models/generic_file_spec.rb +44 -28
  58. data/spec/support/uploaded_file_monkeypatch.rb +0 -14
  59. data/sufia-models/app/models/batch.rb +0 -14
  60. data/sufia-models/app/models/checksum_audit_log.rb +1 -1
  61. data/sufia-models/app/models/concerns/sufia/models/access_right.rb +79 -0
  62. data/sufia-models/app/models/concerns/sufia/models/with_access_right.rb +33 -0
  63. data/sufia-models/app/models/datastreams/batch_rdf_datastream.rb +0 -14
  64. data/sufia-models/app/models/datastreams/fits_datastream.rb +0 -14
  65. data/sufia-models/app/models/datastreams/generic_file_rdf_datastream.rb +0 -14
  66. data/sufia-models/app/models/datastreams/properties_datastream.rb +0 -14
  67. data/sufia-models/app/models/domain_term.rb +1 -1
  68. data/sufia-models/app/models/follow.rb +0 -14
  69. data/sufia-models/app/models/generic_file.rb +0 -13
  70. data/sufia-models/app/models/local_authority.rb +1 -1
  71. data/sufia-models/app/models/local_authority_entry.rb +1 -1
  72. data/sufia-models/app/models/single_use_link.rb +1 -1
  73. data/sufia-models/app/models/subject_local_authority_entry.rb +0 -14
  74. data/sufia-models/app/models/trophy.rb +1 -1
  75. data/sufia-models/app/models/version_committer.rb +1 -1
  76. data/sufia-models/lib/generators/sufia/models/install_generator.rb +102 -0
  77. data/sufia-models/lib/generators/sufia/models/templates/config/clamav.rb +1 -0
  78. data/sufia-models/lib/generators/sufia/models/templates/config/mailboxer.rb +17 -0
  79. data/{lib/generators/sufia → sufia-models/lib/generators/sufia/models}/templates/config/redis_config.rb +1 -1
  80. data/{lib/generators/sufia → sufia-models/lib/generators/sufia/models}/templates/config/resque_config.rb +1 -1
  81. data/sufia-models/lib/generators/sufia/models/templates/config/setup_mail.rb +3 -0
  82. data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +81 -0
  83. data/sufia-models/lib/generators/sufia/models/templates/migrations/acts_as_follower_migration.rb +17 -0
  84. data/sufia-models/lib/generators/sufia/models/templates/migrations/add_avatars_to_users.rb +9 -0
  85. data/sufia-models/lib/generators/sufia/models/templates/migrations/add_groups_to_users.rb +11 -0
  86. data/sufia-models/lib/generators/sufia/models/templates/migrations/add_ldap_attrs_to_user.rb +27 -0
  87. data/sufia-models/lib/generators/sufia/models/templates/migrations/add_social_to_users.rb +13 -0
  88. data/sufia-models/lib/generators/sufia/models/templates/migrations/create_checksum_audit_logs.rb +20 -0
  89. data/sufia-models/lib/generators/sufia/models/templates/migrations/create_local_authorities.rb +50 -0
  90. data/sufia-models/lib/generators/sufia/models/templates/migrations/create_single_use_links.rb +12 -0
  91. data/sufia-models/lib/generators/sufia/models/templates/migrations/create_trophies.rb +10 -0
  92. data/sufia-models/lib/generators/sufia/models/templates/migrations/create_version_committers.rb +15 -0
  93. data/sufia-models/lib/sufia/models/active_record/deprecated_attr_accessible.rb +16 -0
  94. data/sufia-models/lib/sufia/models/engine.rb +1 -2
  95. data/sufia-models/lib/sufia/models/generic_file/permissions.rb +2 -17
  96. data/sufia-models/lib/sufia/models/generic_file/visibility.rb +65 -0
  97. data/sufia-models/lib/sufia/models/generic_file.rb +3 -2
  98. data/sufia-models/lib/sufia/models/id_service.rb +0 -14
  99. data/sufia-models/lib/sufia/models/jobs/audit_job.rb +0 -14
  100. data/sufia-models/lib/sufia/models/jobs/batch_update_job.rb +3 -17
  101. data/sufia-models/lib/sufia/models/jobs/characterize_job.rb +0 -14
  102. data/sufia-models/lib/sufia/models/jobs/resolrize_job.rb +0 -14
  103. data/sufia-models/lib/sufia/models/jobs/unzip_job.rb +0 -14
  104. data/sufia-models/lib/sufia/models/noid.rb +0 -14
  105. data/sufia-models/lib/sufia/models/solr_document_behavior.rb +0 -14
  106. data/sufia-models/lib/sufia/models/user.rb +1 -15
  107. data/sufia-models/lib/sufia/models/utils.rb +0 -14
  108. data/sufia-models/lib/sufia/models/version.rb +1 -1
  109. data/sufia-models/lib/tasks/resque.rake +0 -14
  110. data/sufia-models/sufia-models.gemspec +3 -3
  111. data/tasks/release.rake +2 -1
  112. data/tasks/sufia-db.rake +0 -14
  113. data/tasks/sufia-dev.rake +0 -1
  114. data/tasks/sufia-fixtures.rake +0 -14
  115. data/tasks/sufia.rake +0 -14
  116. metadata +33 -14
  117. data/lib/generators/sufia/templates/config/clamav.rb +0 -14
  118. data/lib/generators/sufia/templates/config/mailboxer.rb +0 -31
  119. data/lib/generators/sufia/templates/config/setup_mail.rb +0 -17
  120. data/lib/generators/sufia/templates/config/sufia.rb +0 -82
  121. /data/{lib/generators/sufia → sufia-models/lib/generators/sufia/models}/templates/config/redis.yml +0 -0
  122. /data/{lib/generators/sufia → sufia-models/lib/generators/sufia/models}/templates/config/resque_admin.rb +0 -0
@@ -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= 'restricted'
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,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
  #Monkey patch UploadedFile so that it responds to read (same as ActionDispatch::Http::UploadedFile). Required by RestClient when posting to fedora.
16
2
  class Rack::Test::UploadedFile
17
3
  def read(*args)
@@ -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 Batch < ActiveFedora::Base
16
2
  include Hydra::ModelMixins::CommonMetadata
17
3
  include Hydra::ModelMixins::RightsMetadata
@@ -1,5 +1,5 @@
1
1
  class ChecksumAuditLog < ActiveRecord::Base
2
- attr_accessible :pass, :pid, :dsid, :version, :created_at if Rails::VERSION::MAJOR == 3
2
+ deprecated_attr_accessible :pass, :pid, :dsid, :version, :created_at
3
3
 
4
4
  def ChecksumAuditLog.get_audit_log(version)
5
5
  ChecksumAuditLog.find_or_create_by_pid_and_dsid_and_version(:pid => version.pid,
@@ -0,0 +1,79 @@
1
+ module Sufia
2
+ module Models
3
+ class AccessRight
4
+ PERMISSION_TEXT_VALUE_PUBLIC = 'public'.freeze
5
+ PERMISSION_TEXT_VALUE_AUTHENTICATED = 'registered'.freeze
6
+ VISIBILITY_TEXT_VALUE_PUBLIC = 'open'.freeze
7
+ VISIBILITY_TEXT_VALUE_EMBARGO = 'open_with_embargo_release_date'.freeze
8
+ VISIBILITY_TEXT_VALUE_AUTHENTICATED = 'psu'.freeze
9
+ VISIBILITY_TEXT_VALUE_PRIVATE = 'restricted'.freeze
10
+
11
+ # @param permissionable [#visibility, #permissions]
12
+ # @example
13
+ # file = GenericFile.find('sufia:1234')
14
+ # access = Sufia::AccessRight.new(file)
15
+ def initialize(permissionable)
16
+ @permissionable = permissionable
17
+ end
18
+
19
+ attr_reader :permissionable
20
+ delegate :persisted?, :permissions, :visibility, to: :permissionable
21
+ protected :persisted?, :permissions, :visibility
22
+
23
+
24
+ def open_access?
25
+ return true if has_visibility_text_for?(VISIBILITY_TEXT_VALUE_PUBLIC)
26
+ # We don't want to know if its under embargo, simply does it have a date.
27
+ # In this way, we can properly inform the label input
28
+ persisted_open_access_permission? && !permissionable.embargo_release_date.present?
29
+ end
30
+
31
+ def open_access_with_embargo_release_date?
32
+ return false unless permissionable_is_embargoable?
33
+ return true if has_visibility_text_for?(VISIBILITY_TEXT_VALUE_EMBARGO)
34
+ # We don't want to know if its under embargo, simply does it have a date.
35
+ # In this way, we can properly inform the label input
36
+ persisted_open_access_permission? && permissionable.embargo_release_date.present?
37
+ end
38
+
39
+ def authenticated_only?
40
+ return false if open_access?
41
+ has_permission_text_for?(PERMISSION_TEXT_VALUE_AUTHENTICATED) ||
42
+ has_visibility_text_for?(VISIBILITY_TEXT_VALUE_AUTHENTICATED)
43
+ end
44
+
45
+ def private?
46
+ return false if open_access?
47
+ return false if authenticated_only?
48
+ return false if open_access_with_embargo_release_date?
49
+ true
50
+ end
51
+
52
+ private
53
+
54
+ def persisted_open_access_permission?
55
+ if persisted?
56
+ has_permission_text_for?(PERMISSION_TEXT_VALUE_PUBLIC)
57
+ else
58
+ visibility.to_s == ''
59
+ end
60
+ end
61
+
62
+ def on_or_after_any_embargo_release_date?
63
+ return true unless permissionable.embargo_release_date
64
+ permissionable.embargo_release_date.to_date < Date.today
65
+ end
66
+
67
+ def permissionable_is_embargoable?
68
+ permissionable.respond_to?(:embargo_release_date)
69
+ end
70
+
71
+ def has_visibility_text_for?(text)
72
+ visibility == text
73
+ end
74
+ def has_permission_text_for?(text)
75
+ !!permissions.detect { |perm| perm[:name] == text }
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,33 @@
1
+ module Sufia
2
+ module Models
3
+ module WithAccessRight
4
+ extend ActiveSupport::Concern
5
+
6
+ def under_embargo?
7
+ @under_embargo ||= rightsMetadata.under_embargo?
8
+ end
9
+
10
+ def open_access?
11
+ access_rights.open_access?
12
+ end
13
+
14
+ def open_access_with_embargo_release_date?
15
+ access_rights.open_access_with_embargo_release_date?
16
+ end
17
+
18
+ def authenticated_only_access?
19
+ access_rights.authenticated_only?
20
+ end
21
+
22
+ def private_access?
23
+ access_rights.private?
24
+ end
25
+
26
+ def access_rights
27
+ @access_rights ||= AccessRight.new(self)
28
+ end
29
+ protected :access_rights
30
+
31
+ end
32
+ end
33
+ end
@@ -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 BatchRdfDatastream < ActiveFedora::NtriplesRDFDatastream
16
2
  map_predicates do |map|
17
3
  map.part(:to => "hasPart", :in => RDF::DC)
@@ -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 FitsDatastream < ActiveFedora::OmDatastream
16
2
  include OM::XML::Document
17
3
 
@@ -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 GenericFileRdfDatastream < ActiveFedora::NtriplesRDFDatastream
16
2
  map_predicates do |map|
17
3
  map.part_of(:to => "isPartOf", :in => RDF::DC)
@@ -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
  # properties datastream: catch-all for info that didn't have another home. Particularly depositor.
16
2
  class PropertiesDatastream < ActiveFedora::OmDatastream
17
3
  set_terminology do |t|
@@ -1,5 +1,5 @@
1
1
  class DomainTerm < ActiveRecord::Base
2
- attr_accessible :model, :term if Rails::VERSION::MAJOR == 3
2
+ deprecated_attr_accessible :model, :term
3
3
 
4
4
  # TODO we should add an index on this join table and remove the uniq query
5
5
  has_and_belongs_to_many :local_authorities, :uniq=> true
@@ -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 Follow < ActiveRecord::Base
16
2
 
17
3
  extend ActsAsFollower::FollowerLib
@@ -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
@@ -2,7 +2,7 @@ require 'rdf'
2
2
  require 'rdf/rdfxml'
3
3
 
4
4
  class LocalAuthority < ActiveRecord::Base
5
- attr_accessible :name if Rails::VERSION::MAJOR == 3
5
+ deprecated_attr_accessible :name
6
6
  # TODO we should add an index on this join table and remove the uniq query
7
7
  has_and_belongs_to_many :domain_terms, :uniq=> true
8
8
  has_many :local_authority_entries
@@ -1,4 +1,4 @@
1
1
  class LocalAuthorityEntry < ActiveRecord::Base
2
2
  belongs_to :local_authority
3
- attr_accessible :local_authority, :label, :uri if Rails::VERSION::MAJOR == 3
3
+ deprecated_attr_accessible :local_authority, :label, :uri
4
4
  end
@@ -1,6 +1,6 @@
1
1
  class SingleUseLink < ActiveRecord::Base
2
2
 
3
- attr_accessible :downloadKey, :expires, :itemId, :path if Rails::VERSION::MAJOR == 3
3
+ deprecated_attr_accessible :downloadKey, :expires, :itemId, :path
4
4
 
5
5
 
6
6
  def self.create_show(item_id)
@@ -1,16 +1,2 @@
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 SubjectLocalAuthorityEntry < ActiveRecord::Base
16
2
  end
@@ -1,5 +1,5 @@
1
1
  class Trophy < ActiveRecord::Base
2
- attr_accessible :generic_file_id, :user_id if Rails::VERSION::MAJOR == 3
2
+ deprecated_attr_accessible :generic_file_id, :user_id
3
3
 
4
4
  validate :count_within_limit, :on => :create
5
5
 
@@ -1,3 +1,3 @@
1
1
  class VersionCommitter < ActiveRecord::Base
2
- attr_accessible :obj_id, :datastream_id, :version_id, :committer_login if Rails::VERSION::MAJOR == 3
2
+ deprecated_attr_accessible :obj_id, :datastream_id, :version_id, :committer_login
3
3
  end
@@ -0,0 +1,102 @@
1
+ # -*- encoding : utf-8 -*-
2
+ require 'rails/generators'
3
+ require 'rails/generators/migration'
4
+
5
+ class Sufia::Models::InstallGenerator < Rails::Generators::Base
6
+ include Rails::Generators::Migration
7
+
8
+ source_root File.expand_path('../templates', __FILE__)
9
+
10
+ argument :model_name, :type => :string , :default => "user"
11
+ desc """
12
+ This generator makes the following changes to your application:
13
+ 1. Creates several database migrations if they do not exist in /db/migrate
14
+ 2. Adds user behavior to the user model
15
+ 3. Creates the sufia.rb configuration file
16
+ 4. Adds Sufia::SolrDocumentBehavior to app/models/solr_document.rb
17
+ 5. Generates mailboxer
18
+ """
19
+
20
+ # Implement the required interface for Rails::Generators::Migration.
21
+ # taken from http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
22
+ def self.next_migration_number(path)
23
+ if @prev_migration_nr
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
31
+ end
32
+ @prev_migration_nr.to_s
33
+ end
34
+
35
+ # Setup the database migrations
36
+ def copy_migrations
37
+ # Can't get this any more DRY, because we need this order.
38
+ [
39
+ "acts_as_follower_migration.rb",
40
+ "add_social_to_users.rb",
41
+ "create_single_use_links.rb",
42
+ "add_ldap_attrs_to_user.rb",
43
+ "add_avatars_to_users.rb",
44
+ "create_checksum_audit_logs.rb",
45
+ "create_version_committers.rb",
46
+ "add_groups_to_users.rb",
47
+ "create_local_authorities.rb",
48
+ "create_trophies.rb"
49
+ ].each do |file|
50
+ better_migration_template file
51
+ end
52
+ end
53
+
54
+ # Add behaviors to the user model
55
+ def inject_sufia_user_behavior
56
+ file_path = "app/models/#{model_name.underscore}.rb"
57
+ if File.exists?(file_path)
58
+ inject_into_class file_path, model_name.classify do
59
+ "# Connects this user object to Sufia behaviors. " +
60
+ "\n include Sufia::User\n"
61
+ end
62
+ else
63
+ puts " \e[31mFailure\e[0m Sufia requires a user object. This generators assumes that the model is defined in the file #{file_path}, which does not exist. If you used a different name, please re-run the generator and provide that name as an argument. Such as \b rails -g sufia client"
64
+ end
65
+ end
66
+
67
+ def create_configuration_files
68
+ copy_file "config/sufia.rb", "config/initializers/sufia.rb"
69
+ copy_file "config/redis.yml", "config/redis.yml"
70
+ copy_file "config/redis_config.rb", "config/initializers/redis_config.rb"
71
+ copy_file "config/resque_admin.rb", "config/initializers/resque_admin.rb"
72
+ copy_file "config/resque_config.rb", "config/initializers/resque_config.rb"
73
+ end
74
+
75
+ # Add behaviors to the SolrDocument model
76
+ def inject_sufia_solr_document_behavior
77
+ file_path = "app/models/solr_document.rb"
78
+ if File.exists?(file_path)
79
+ inject_into_class file_path, "SolrDocument" do
80
+ " # Adds Sufia behaviors to the SolrDocument.\n" +
81
+ " include Sufia::SolrDocumentBehavior\n"
82
+ end
83
+ else
84
+ puts " \e[31mFailure\e[0m Sufia requires a SolrDocument object. This generators assumes that the model is defined in the file #{file_path}, which does not exist."
85
+ end
86
+ end
87
+
88
+ def install_mailboxer
89
+ generate "mailboxer:install"
90
+ end
91
+
92
+ private
93
+
94
+ def better_migration_template(file)
95
+ begin
96
+ migration_template "migrations/#{file}", "db/migrate/#{file}"
97
+ rescue Rails::Generators::Error => e
98
+ say_status("warning", e.message, :yellow)
99
+ end
100
+ end
101
+
102
+ end
@@ -0,0 +1 @@
1
+ ClamAV.instance.loaddb() if defined? ClamAV
@@ -0,0 +1,17 @@
1
+ Mailboxer.setup do |config|
2
+
3
+ #Configures if you applications uses or no the email sending for Notifications and Messages
4
+ config.uses_emails = true
5
+
6
+ #Configures the default from for the email sent for Messages and Notifications of Mailboxer
7
+ config.default_from = "no-reply@mailboxer.com"
8
+
9
+ #Configures the methods needed by mailboxer
10
+ config.email_method = :mailboxer_email
11
+ config.name_method = :name
12
+
13
+ #Configures if you use or not a search engine and wich one are you using
14
+ #Supported enignes: [:solr,:sphinx]
15
+ config.search_enabled = false
16
+ config.search_engine = :solr
17
+ end
@@ -7,7 +7,7 @@ if defined?(PhusionPassenger)
7
7
  config = YAML::load(ERB.new(IO.read(File.join(Rails.root, 'config', 'redis.yml'))).result)[Rails.env].with_indifferent_access
8
8
 
9
9
  # The important two lines
10
- $redis.client.disconnect if $redis
10
+ $redis.client.disconnect if $redis
11
11
  $redis = Redis.new(host: config[:host], port: config[:port], thread_safe: true) rescue nil
12
12
  Resque.redis = $redis
13
13
  Resque.redis.client.reconnect if Resque.redis
@@ -2,4 +2,4 @@ config = YAML::load(ERB.new(IO.read(File.join(Rails.root, 'config', 'redis.yml')
2
2
  Resque.redis = Redis.new(host: config[:host], port: config[:port], thread_safe: true)
3
3
 
4
4
  Resque.inline = Rails.env.test?
5
- Resque.redis.namespace = "#{Sufia::Engine.config.id_namespace}:#{Rails.env}"
5
+ Resque.redis.namespace = "#{Sufia.config.id_namespace}:#{Rails.env}"
@@ -0,0 +1,3 @@
1
+ ActionMailer::Base.smtp_settings = {
2
+ :address => "smtp.psu.edu"
3
+ }