hydra-head 4.0.1 → 4.0.2

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 (153) hide show
  1. data/.gitmodules +1 -0
  2. data/HISTORY.textile +6 -0
  3. data/app/assets/stylesheets/hydra/styles.css +1 -1
  4. data/app/controllers/user_sessions_controller.rb +1 -1
  5. data/app/helpers/hydra/application_helper_behavior.rb +0 -2
  6. data/app/helpers/hydra/blacklight_helper_behavior.rb +13 -16
  7. data/app/helpers/hydra/generic_content_objects_helper_behavior.rb +1 -6
  8. data/app/helpers/hydra/hydra_fedora_metadata_helper_behavior.rb +3 -1
  9. data/app/helpers/hydra/personalization_helper_behavior.rb +1 -1
  10. data/app/models/common_metadata_asset.rb +1 -1
  11. data/app/models/hydra/ability.rb +1 -1
  12. data/app/models/hydra/datastream/properties.rb +2 -2
  13. data/app/models/hydra/datastream/rights_metadata.rb +2 -2
  14. data/app/models/mods_asset.rb +3 -0
  15. data/app/models/superuser.rb +1 -1
  16. data/app/models/user_attribute.rb +2 -1
  17. data/app/models/uses_default_partials.rb +4 -3
  18. data/app/views/_user_util_links.html.erb +2 -2
  19. data/config/fedora.yml +1 -0
  20. data/config/solr.yml +1 -2
  21. data/hydra-head.gemspec +5 -4
  22. data/lib/generators/hydra/head_generator.rb +1 -1
  23. data/lib/generators/hydra/hyhead_fixtures_generator.rb +10 -10
  24. data/lib/hydra-head/engine.rb +0 -1
  25. data/lib/hydra-head/version.rb +1 -1
  26. data/lib/hydra/access_controls_enforcement.rb +1 -1
  27. data/lib/hydra/file_assets_helper.rb +3 -3
  28. data/lib/hydra/generic_content.rb +1 -1
  29. data/lib/hydra/generic_image.rb +2 -2
  30. data/lib/hydra/generic_user_attributes.rb +6 -4
  31. data/lib/hydra/model_mixins.rb +8 -3
  32. data/lib/hydra/model_mixins/rights_metadata.rb +357 -0
  33. data/lib/hydra/models/file_asset.rb +1 -1
  34. data/lib/hydra/mods_dataset.rb +5 -2
  35. data/lib/hydra/rights_metadata.rb +2 -2
  36. data/lib/hydra/superuser_attributes.rb +6 -5
  37. data/lib/mediashelf/active_fedora_helper.rb +1 -1
  38. data/lib/prev_next_links.rb +8 -3
  39. data/lib/user_attributes_loader.rb +22 -15
  40. data/lib/uva/mods_index_methods.rb +1 -1
  41. data/tasks/hydra-head.rake +4 -15
  42. data/tasks/hydra_jetty.rake +10 -1
  43. data/test_support/etc/Gemfile +13 -4
  44. data/test_support/features/support/paths.rb +5 -5
  45. data/test_support/spec/helpers/blacklight_helper_spec.rb +9 -5
  46. data/test_support/spec/helpers/generic_content_objects_helper_spec.rb +8 -0
  47. data/test_support/spec/helpers/hydra_fedora_metadata_helper_spec.rb +3 -0
  48. data/test_support/spec/helpers/hydra_helper_spec.rb +0 -1
  49. data/test_support/spec/models/generic_image_spec.rb +27 -30
  50. data/test_support/spec/models/user_spec.rb +9 -1
  51. data/test_support/spec/unit/rights_metadata_spec.rb +80 -0
  52. metadata +29 -111
  53. data/Gemfile.lock +0 -302
  54. data/test_support/etc/rvmrc +0 -32
  55. data/vendor/cache/RedCloth-4.2.9.gem +0 -0
  56. data/vendor/cache/actionmailer-3.2.3.gem +0 -0
  57. data/vendor/cache/actionpack-3.2.3.gem +0 -0
  58. data/vendor/cache/active-fedora-4.0.0.gem +0 -0
  59. data/vendor/cache/activemodel-3.2.3.gem +0 -0
  60. data/vendor/cache/activerecord-3.2.3.gem +0 -0
  61. data/vendor/cache/activeresource-3.2.3.gem +0 -0
  62. data/vendor/cache/activesupport-3.2.3.gem +0 -0
  63. data/vendor/cache/addressable-2.2.7.gem +0 -0
  64. data/vendor/cache/akami-1.0.0.gem +0 -0
  65. data/vendor/cache/arel-3.0.2.gem +0 -0
  66. data/vendor/cache/bcrypt-ruby-3.0.1.gem +0 -0
  67. data/vendor/cache/blacklight-3.3.2.gem +0 -0
  68. data/vendor/cache/block_helpers-0.3.3.gem +0 -0
  69. data/vendor/cache/builder-3.0.0.gem +0 -0
  70. data/vendor/cache/cancan-1.6.7.gem +0 -0
  71. data/vendor/cache/capybara-1.1.2.gem +0 -0
  72. data/vendor/cache/childprocess-0.3.1.gem +0 -0
  73. data/vendor/cache/chunky_png-1.2.5.gem +0 -0
  74. data/vendor/cache/compass-0.12.1.gem +0 -0
  75. data/vendor/cache/compass-rails-1.0.1.gem +0 -0
  76. data/vendor/cache/compass-susy-plugin-0.9.gem +0 -0
  77. data/vendor/cache/cucumber-1.1.9.gem +0 -0
  78. data/vendor/cache/cucumber-rails-1.3.0.gem +0 -0
  79. data/vendor/cache/daemons-1.1.8.gem +0 -0
  80. data/vendor/cache/devise-2.0.4.gem +0 -0
  81. data/vendor/cache/diff-lcs-1.1.3.gem +0 -0
  82. data/vendor/cache/equivalent-xml-0.2.9.gem +0 -0
  83. data/vendor/cache/erubis-2.7.0.gem +0 -0
  84. data/vendor/cache/factory_girl-2.6.4.gem +0 -0
  85. data/vendor/cache/fastercsv-1.5.4.gem +0 -0
  86. data/vendor/cache/ffi-1.0.11.gem +0 -0
  87. data/vendor/cache/fssm-0.2.9.gem +0 -0
  88. data/vendor/cache/gherkin-2.9.3.gem +0 -0
  89. data/vendor/cache/gyoku-0.4.4.gem +0 -0
  90. data/vendor/cache/hike-1.2.1.gem +0 -0
  91. data/vendor/cache/httpi-0.9.6.gem +0 -0
  92. data/vendor/cache/i18n-0.6.0.gem +0 -0
  93. data/vendor/cache/jettywrapper-1.2.1.gem +0 -0
  94. data/vendor/cache/journey-1.0.3.gem +0 -0
  95. data/vendor/cache/jquery-rails-2.0.2.gem +0 -0
  96. data/vendor/cache/json-1.6.6.gem +0 -0
  97. data/vendor/cache/kaminari-0.13.0.gem +0 -0
  98. data/vendor/cache/libwebsocket-0.1.3.gem +0 -0
  99. data/vendor/cache/logger-1.2.8.gem +0 -0
  100. data/vendor/cache/mail-2.4.4.gem +0 -0
  101. data/vendor/cache/marc-0.4.4.gem +0 -0
  102. data/vendor/cache/mediashelf-loggable-0.4.9.gem +0 -0
  103. data/vendor/cache/metaclass-0.0.1.gem +0 -0
  104. data/vendor/cache/mime-types-1.18.gem +0 -0
  105. data/vendor/cache/mocha-0.11.0.gem +0 -0
  106. data/vendor/cache/multi_json-1.3.2.gem +0 -0
  107. data/vendor/cache/multipart-post-1.1.2.gem +0 -0
  108. data/vendor/cache/nokogiri-1.5.2.gem +0 -0
  109. data/vendor/cache/nori-1.1.0.gem +0 -0
  110. data/vendor/cache/om-1.6.0.gem +0 -0
  111. data/vendor/cache/orm_adapter-0.0.7.gem +0 -0
  112. data/vendor/cache/polyglot-0.3.3.gem +0 -0
  113. data/vendor/cache/rack-1.4.1.gem +0 -0
  114. data/vendor/cache/rack-cache-1.2.gem +0 -0
  115. data/vendor/cache/rack-ssl-1.3.2.gem +0 -0
  116. data/vendor/cache/rack-test-0.6.1.gem +0 -0
  117. data/vendor/cache/rails-3.2.3.gem +0 -0
  118. data/vendor/cache/railties-3.2.3.gem +0 -0
  119. data/vendor/cache/rake-0.9.2.2.gem +0 -0
  120. data/vendor/cache/rdf-0.3.5.2.gem +0 -0
  121. data/vendor/cache/rdf-rdfxml-0.3.5.gem +0 -0
  122. data/vendor/cache/rdoc-3.12.gem +0 -0
  123. data/vendor/cache/rest-client-1.6.7.gem +0 -0
  124. data/vendor/cache/rsolr-1.0.8.gem +0 -0
  125. data/vendor/cache/rsolr-ext-1.0.3.gem +0 -0
  126. data/vendor/cache/rspec-2.9.0.gem +0 -0
  127. data/vendor/cache/rspec-core-2.9.0.gem +0 -0
  128. data/vendor/cache/rspec-expectations-2.9.1.gem +0 -0
  129. data/vendor/cache/rspec-mocks-2.9.0.gem +0 -0
  130. data/vendor/cache/rspec-rails-2.9.0.gem +0 -0
  131. data/vendor/cache/rubydora-0.5.8.gem +0 -0
  132. data/vendor/cache/rubyzip-0.9.7.gem +0 -0
  133. data/vendor/cache/sanitize-2.0.3.gem +0 -0
  134. data/vendor/cache/sass-3.1.16.gem +0 -0
  135. data/vendor/cache/sass-rails-3.2.5.gem +0 -0
  136. data/vendor/cache/savon-0.9.9.gem +0 -0
  137. data/vendor/cache/selenium-webdriver-2.21.2.gem +0 -0
  138. data/vendor/cache/solrizer-1.2.0.gem +0 -0
  139. data/vendor/cache/solrizer-fedora-2.0.0.gem +0 -0
  140. data/vendor/cache/sprockets-2.1.2.gem +0 -0
  141. data/vendor/cache/sqlite3-1.3.6.gem +0 -0
  142. data/vendor/cache/stomp-1.2.2.gem +0 -0
  143. data/vendor/cache/term-ansicolor-1.0.7.gem +0 -0
  144. data/vendor/cache/thor-0.14.6.gem +0 -0
  145. data/vendor/cache/tilt-1.3.3.gem +0 -0
  146. data/vendor/cache/treetop-1.4.10.gem +0 -0
  147. data/vendor/cache/tzinfo-0.3.33.gem +0 -0
  148. data/vendor/cache/unicode-0.4.2.gem +0 -0
  149. data/vendor/cache/warden-1.1.1.gem +0 -0
  150. data/vendor/cache/wasabi-2.1.0.gem +0 -0
  151. data/vendor/cache/xml-simple-1.1.1.gem +0 -0
  152. data/vendor/cache/xpath-0.1.4.gem +0 -0
  153. data/vendor/cache/yard-0.7.5.gem +0 -0
@@ -1,9 +1,8 @@
1
+ require 'deprecation'
1
2
  module Hydra::GenericUserAttributes
3
+ extend Deprecation
2
4
 
3
- def self.included(base)
4
- ActiveSupport::Deprecation.warn("Hydra::GenericUserAttributes has been deprecated and will be removed no later than release 6. Use devise or similar.")
5
- super
6
- end
5
+ self.deprecation_horizon = 'hydra-head 5.x'
7
6
 
8
7
  USER_ATTRIBUTES = ['first_name','last_name','full_name','affiliation','photo']
9
8
 
@@ -15,14 +14,17 @@ module Hydra::GenericUserAttributes
15
14
  def #{m}
16
15
  get_user_attribute "#{m}"
17
16
  end
17
+ deprecation_deprecate :#{m}
18
18
  EOM
19
19
  end
20
20
 
21
+
21
22
  # Retrieves the UserAttribute object for the user. This defaults to the packaged ActiveRecord object, but can be overwritten with #user_attributes=
22
23
  # @return an object containing the user's attributes. If providing a localized class, be sure to include the default attributes of first_name, last_name, full_name, affiliation and photo.
23
24
  def user_attributes
24
25
  @user_attributes ||= user_attribute
25
26
  end
27
+ deprecation_deprecate :user_attributes
26
28
 
27
29
  private
28
30
 
@@ -1,3 +1,8 @@
1
- # will be changed in 5.x so all the model code is autoload-ed
2
- module Hydra::ModelMixins;end
3
- Dir[File.join(File.dirname(__FILE__), "model_mixins", "*.rb")].each {|f| require f}
1
+ module Hydra::ModelMixins
2
+ extend ActiveSupport::Autoload
3
+ eager_autoload do
4
+ autoload :ModsObject
5
+ autoload :CommonMetadata
6
+ autoload :RightsMetadata
7
+ end
8
+ end
@@ -0,0 +1,357 @@
1
+ module Hydra
2
+ module ModelMixins
3
+ module RightsMetadata
4
+
5
+
6
+ ## Updates those permissions that are provided to it. Does not replace any permissions unless they are provided
7
+ # @example
8
+ # obj.permissions= [{:name=>"group1", :access=>"discover", :type=>'group'},
9
+ # {:name=>"group2", :access=>"discover", :type=>'group'}]
10
+ def permissions=(params)
11
+ perm_hash = {'person' => rightsMetadata.individuals, 'group'=> rightsMetadata.groups}
12
+
13
+ params.each do |row|
14
+ if row[:type] == 'user'
15
+ perm_hash['person'][row[:name]] = row[:access]
16
+ else
17
+ perm_hash['group'][row[:name]] = row[:access]
18
+ end
19
+ end
20
+
21
+ rightsMetadata.update_permissions(perm_hash)
22
+ end
23
+
24
+
25
+ ## Returns a list with all the permissions on the object.
26
+ # @example
27
+ # [{:name=>"group1", :access=>"discover", :type=>'group'},
28
+ # {:name=>"group2", :access=>"discover", :type=>'group'},
29
+ # {:name=>"user2", :access=>"read", :type=>'user'},
30
+ # {:name=>"user1", :access=>"edit", :type=>'user'},
31
+ # {:name=>"user3", :access=>"read", :type=>'user'}]
32
+ def permissions
33
+ (rightsMetadata.groups.map {|x| {:type=>'group', :access=>x[1], :name=>x[0] }} +
34
+ rightsMetadata.individuals.map {|x| {:type=>'user', :access=>x[1], :name=>x[0]}})
35
+
36
+ end
37
+
38
+ # Return a list of groups that have discover permission
39
+ def discover_groups
40
+ rightsMetadata.groups.map {|k, v| k if v == 'discover'}.compact
41
+ end
42
+
43
+ # Grant discover permissions to the groups specified. Revokes discover permission for all other groups.
44
+ # @param[Array] groups a list of group names
45
+ # @example
46
+ # r.discover_groups= ['one', 'two', 'three']
47
+ # r.discover_groups
48
+ # => ['one', 'two', 'three']
49
+ #
50
+ def discover_groups=(groups)
51
+ set_discover_groups(groups, discover_groups)
52
+ end
53
+
54
+ # Grant discover permissions to the groups specified. Revokes discover permission for all other groups.
55
+ # @param[String] groups a list of group names
56
+ # @example
57
+ # r.discover_groups_string= 'one, two, three'
58
+ # r.discover_groups
59
+ # => ['one', 'two', 'three']
60
+ #
61
+ def discover_groups_string=(groups)
62
+ self.discover_groups=groups.split(/[\s,]+/)
63
+ end
64
+
65
+ # Display the groups a comma delimeted string
66
+ def discover_groups_string
67
+ self.discover_groups.join(', ')
68
+ end
69
+
70
+ # Grant discover permissions to the groups specified. Revokes discover permission for
71
+ # any of the eligible_groups that are not in groups.
72
+ # This may be used when different users are responsible for setting different
73
+ # groups. Supply the groups the current user is responsible for as the
74
+ # 'eligible_groups'
75
+ # @param[Array] groups a list of groups
76
+ # @param[Array] eligible_groups the groups that are eligible to have their discover permssion revoked.
77
+ # @example
78
+ # r.discover_groups = ['one', 'two', 'three']
79
+ # r.discover_groups
80
+ # => ['one', 'two', 'three']
81
+ # r.set_discover_groups(['one'], ['three'])
82
+ # r.discover_groups
83
+ # => ['one', 'two'] ## 'two' was not eligible to be removed
84
+ #
85
+ def set_discover_groups(groups, eligible_groups)
86
+ set_entities(:discover, :group, groups, eligible_groups)
87
+ end
88
+
89
+ def discover_users
90
+ rightsMetadata.individuals.map {|k, v| k if v == 'discover'}.compact
91
+ end
92
+
93
+ # Grant discover permissions to the users specified. Revokes discover permission for all other users.
94
+ # @param[Array] users a list of usernames
95
+ # @example
96
+ # r.discover_users= ['one', 'two', 'three']
97
+ # r.discover_users
98
+ # => ['one', 'two', 'three']
99
+ #
100
+ def discover_users=(users)
101
+ set_discover_users(users, discover_users)
102
+ end
103
+
104
+ # Grant discover permissions to the groups specified. Revokes discover permission for all other users.
105
+ # @param[String] users a list of usernames
106
+ # @example
107
+ # r.discover_users_string= 'one, two, three'
108
+ # r.discover_users
109
+ # => ['one', 'two', 'three']
110
+ #
111
+ def discover_users_string=(users)
112
+ self.discover_users=users.split(/[\s,]+/)
113
+ end
114
+
115
+ # Display the users as a comma delimeted string
116
+ def discover_users_string
117
+ self.discover_users.join(', ')
118
+ end
119
+
120
+ # Grant discover permissions to the users specified. Revokes discover permission for
121
+ # any of the eligible_users that are not in users.
122
+ # This may be used when different users are responsible for setting different
123
+ # users. Supply the users the current user is responsible for as the
124
+ # 'eligible_users'
125
+ # @param[Array] users a list of users
126
+ # @param[Array] eligible_users the users that are eligible to have their discover permssion revoked.
127
+ # @example
128
+ # r.discover_users = ['one', 'two', 'three']
129
+ # r.discover_users
130
+ # => ['one', 'two', 'three']
131
+ # r.set_discover_users(['one'], ['three'])
132
+ # r.discover_users
133
+ # => ['one', 'two'] ## 'two' was not eligible to be removed
134
+ #
135
+ def set_discover_users(users, eligible_users)
136
+ set_entities(:discover, :person, users, eligible_users)
137
+ end
138
+
139
+ # Return a list of groups that have discover permission
140
+ def read_groups
141
+ rightsMetadata.groups.map {|k, v| k if v == 'read'}.compact
142
+ end
143
+
144
+ # Grant read permissions to the groups specified. Revokes read permission for all other groups.
145
+ # @param[Array] groups a list of group names
146
+ # @example
147
+ # r.read_groups= ['one', 'two', 'three']
148
+ # r.read_groups
149
+ # => ['one', 'two', 'three']
150
+ #
151
+ def read_groups=(groups)
152
+ set_read_groups(groups, read_groups)
153
+ end
154
+
155
+ # Grant read permissions to the groups specified. Revokes read permission for all other groups.
156
+ # @param[String] groups a list of group names
157
+ # @example
158
+ # r.read_groups_string= 'one, two, three'
159
+ # r.read_groups
160
+ # => ['one', 'two', 'three']
161
+ #
162
+ def read_groups_string=(groups)
163
+ self.read_groups=groups.split(/[\s,]+/)
164
+ end
165
+
166
+ # Display the groups a comma delimeted string
167
+ def read_groups_string
168
+ self.read_groups.join(', ')
169
+ end
170
+
171
+ # Grant read permissions to the groups specified. Revokes read permission for
172
+ # any of the eligible_groups that are not in groups.
173
+ # This may be used when different users are responsible for setting different
174
+ # groups. Supply the groups the current user is responsible for as the
175
+ # 'eligible_groups'
176
+ # @param[Array] groups a list of groups
177
+ # @param[Array] eligible_groups the groups that are eligible to have their read permssion revoked.
178
+ # @example
179
+ # r.read_groups = ['one', 'two', 'three']
180
+ # r.read_groups
181
+ # => ['one', 'two', 'three']
182
+ # r.set_read_groups(['one'], ['three'])
183
+ # r.read_groups
184
+ # => ['one', 'two'] ## 'two' was not eligible to be removed
185
+ #
186
+ def set_read_groups(groups, eligible_groups)
187
+ set_entities(:read, :group, groups, eligible_groups)
188
+ end
189
+
190
+ def read_users
191
+ rightsMetadata.individuals.map {|k, v| k if v == 'read'}.compact
192
+ end
193
+
194
+ # Grant read permissions to the users specified. Revokes read permission for all other users.
195
+ # @param[Array] users a list of usernames
196
+ # @example
197
+ # r.read_users= ['one', 'two', 'three']
198
+ # r.read_users
199
+ # => ['one', 'two', 'three']
200
+ #
201
+ def read_users=(users)
202
+ set_read_users(users, read_users)
203
+ end
204
+
205
+ # Grant read permissions to the groups specified. Revokes read permission for all other users.
206
+ # @param[String] users a list of usernames
207
+ # @example
208
+ # r.read_users_string= 'one, two, three'
209
+ # r.read_users
210
+ # => ['one', 'two', 'three']
211
+ #
212
+ def read_users_string=(users)
213
+ self.read_users=users.split(/[\s,]+/)
214
+ end
215
+
216
+ # Display the users as a comma delimeted string
217
+ def read_users_string
218
+ self.read_users.join(', ')
219
+ end
220
+
221
+ # Grant read permissions to the users specified. Revokes read permission for
222
+ # any of the eligible_users that are not in users.
223
+ # This may be used when different users are responsible for setting different
224
+ # users. Supply the users the current user is responsible for as the
225
+ # 'eligible_users'
226
+ # @param[Array] users a list of users
227
+ # @param[Array] eligible_users the users that are eligible to have their read permssion revoked.
228
+ # @example
229
+ # r.read_users = ['one', 'two', 'three']
230
+ # r.read_users
231
+ # => ['one', 'two', 'three']
232
+ # r.set_read_users(['one'], ['three'])
233
+ # r.read_users
234
+ # => ['one', 'two'] ## 'two' was not eligible to be removed
235
+ #
236
+ def set_read_users(users, eligible_users)
237
+ set_entities(:read, :person, users, eligible_users)
238
+ end
239
+
240
+
241
+ # Return a list of groups that have edit permission
242
+ def edit_groups
243
+ rightsMetadata.groups.map {|k, v| k if v == 'edit'}.compact
244
+ end
245
+
246
+ # Grant edit permissions to the groups specified. Revokes edit permission for all other groups.
247
+ # @param[Array] groups a list of group names
248
+ # @example
249
+ # r.edit_groups= ['one', 'two', 'three']
250
+ # r.edit_groups
251
+ # => ['one', 'two', 'three']
252
+ #
253
+ def edit_groups=(groups)
254
+ set_edit_groups(groups, edit_groups)
255
+ end
256
+
257
+ # Grant edit permissions to the groups specified. Revokes edit permission for all other groups.
258
+ # @param[String] groups a list of group names
259
+ # @example
260
+ # r.edit_groups_string= 'one, two, three'
261
+ # r.edit_groups
262
+ # => ['one', 'two', 'three']
263
+ #
264
+ def edit_groups_string=(groups)
265
+ self.edit_groups=groups.split(/[\s,]+/)
266
+ end
267
+
268
+ # Display the groups a comma delimeted string
269
+ def edit_groups_string
270
+ self.edit_groups.join(', ')
271
+ end
272
+
273
+ # Grant edit permissions to the groups specified. Revokes edit permission for
274
+ # any of the eligible_groups that are not in groups.
275
+ # This may be used when different users are responsible for setting different
276
+ # groups. Supply the groups the current user is responsible for as the
277
+ # 'eligible_groups'
278
+ # @param[Array] groups a list of groups
279
+ # @param[Array] eligible_groups the groups that are eligible to have their edit permssion revoked.
280
+ # @example
281
+ # r.edit_groups = ['one', 'two', 'three']
282
+ # r.edit_groups
283
+ # => ['one', 'two', 'three']
284
+ # r.set_edit_groups(['one'], ['three'])
285
+ # r.edit_groups
286
+ # => ['one', 'two'] ## 'two' was not eligible to be removed
287
+ #
288
+ def set_edit_groups(groups, eligible_groups)
289
+ set_entities(:edit, :group, groups, eligible_groups)
290
+ end
291
+
292
+ def edit_users
293
+ rightsMetadata.individuals.map {|k, v| k if v == 'edit'}.compact
294
+ end
295
+
296
+ # Grant edit permissions to the groups specified. Revokes edit permission for all other groups.
297
+ # @param[Array] users a list of usernames
298
+ # @example
299
+ # r.edit_users= ['one', 'two', 'three']
300
+ # r.edit_users
301
+ # => ['one', 'two', 'three']
302
+ #
303
+ def edit_users=(users)
304
+ set_edit_users(users, edit_users)
305
+ end
306
+
307
+ # Grant edit permissions to the users specified. Revokes edit permission for
308
+ # any of the eligible_users that are not in users.
309
+ # This may be used when different users are responsible for setting different
310
+ # users. Supply the users the current user is responsible for as the
311
+ # 'eligible_users'
312
+ # @param[Array] users a list of users
313
+ # @param[Array] eligible_users the users that are eligible to have their edit permssion revoked.
314
+ # @example
315
+ # r.edit_users = ['one', 'two', 'three']
316
+ # r.edit_users
317
+ # => ['one', 'two', 'three']
318
+ # r.set_edit_users(['one'], ['three'])
319
+ # r.edit_users
320
+ # => ['one', 'two'] ## 'two' was not eligible to be removed
321
+ #
322
+ def set_edit_users(users, eligible_users)
323
+ set_entities(:edit, :person, users, eligible_users)
324
+ end
325
+
326
+
327
+ private
328
+
329
+ # @param permission either :discover, :read or :edit
330
+ # @param type either :person or :group
331
+ # @param values Values to set
332
+ # @param changeable Values we are allowed to change
333
+ def set_entities(permission, type, values, changeable)
334
+ g = preserved(type, permission)
335
+ (changeable - values).each do |entity|
336
+ #Strip permissions from users not provided
337
+ g[entity] = 'none'
338
+ end
339
+ values.each { |name| g[name] = permission.to_s}
340
+ rightsMetadata.update_permissions(type.to_s=>g)
341
+ end
342
+
343
+ ## Get those permissions we don't want to change
344
+ def preserved(type, permission)
345
+ case permission
346
+ when :edit
347
+ g = {}
348
+ when :read
349
+ Hash[rightsMetadata.quick_search_by_type(type).select {|k, v| v == 'edit'}]
350
+ when :discover
351
+ Hash[rightsMetadata.quick_search_by_type(type).select {|k, v| v == 'discover'}]
352
+ end
353
+ end
354
+
355
+ end
356
+ end
357
+ end
@@ -19,7 +19,7 @@ module Hydra
19
19
 
20
20
  # Returns a human readable filesize appropriate for the given number of bytes (ie. automatically chooses 'bytes','KB','MB','GB','TB')
21
21
  # Based on a bit of python code posted here: http://blogmag.net/blog/read/38/Print_human_readable_file_size
22
- # @param [Numeric] file size in bits
22
+ # @param [Numeric] num file size in bits
23
23
  def bits_to_human_readable(num)
24
24
  ['bytes','KB','MB','GB','TB'].each do |x|
25
25
  if num < 1024.0
@@ -1,14 +1,17 @@
1
1
  # @deprecated -- this will be removed in 5.x release
2
2
  require "uva/mods_index_methods"
3
+ require 'deprecation'
3
4
  module Hydra
5
+ extend Deprecation
6
+
7
+ self.deprecation_horizon = 'hydra-head 5.x'
4
8
 
5
9
  class ModsDataset < ActiveFedora::NokogiriDatastream
6
10
  include Hydra::CommonModsIndexMethods
7
11
 
8
12
  def initialize(digital_object, dsid, options={})
9
- ActiveSupport::Deprecation.warn("Hydra::ModsDataset has been deprecated. Use Hydra::Datastream::ModsDataset instead")
13
+ Deprecation.warn("Hydra::ModsDataset has been deprecated. Use Hydra::Datastream::ModsDataset instead")
10
14
  super
11
-
12
15
  end
13
16
 
14
17
  set_terminology do |t|
@@ -126,14 +126,14 @@ class RightsMetadata < ActiveFedora::NokogiriDatastream
126
126
  end
127
127
 
128
128
  # Updates permissions for all of the persons and groups in a hash
129
- # @param ex. {"group"=>{"group1"=>"discover","group2"=>"edit"}, "person"=>{"person1"=>"read","person2"=>"discover"}}
129
+ # @param params ex. {"group"=>{"group1"=>"discover","group2"=>"edit"}, "person"=>{"person1"=>"read","person2"=>"discover"}}
130
130
  # Currently restricts actor type to group or person. Any others will be ignored
131
131
  def update_permissions(params)
132
132
  params.fetch("group", {}).each_pair {|group_id, access_level| self.permissions({"group"=>group_id}, access_level)}
133
133
  params.fetch("person", {}).each_pair {|group_id, access_level| self.permissions({"person"=>group_id}, access_level)}
134
134
  end
135
135
 
136
- # @param [Symbol] symbol (either :group or :person)
136
+ # @param [Symbol] type (either :group or :person)
137
137
  # @return
138
138
  # This method limits the response to known access levels. Probably runs a bit faster than .permissions().
139
139
  def quick_search_by_type(type)
@@ -1,18 +1,19 @@
1
1
  # @deprecated no longer doing permissions this way. Will be removed no later than release 6.x
2
+ require 'deprecation'
2
3
  module Hydra::SuperuserAttributes
4
+ extend Deprecation
3
5
 
4
- def self.included(base)
5
- ActiveSupport::Deprecation.warn("Hydra::SuperuserAttributes has been deprecated and will be removed no later than release 6. Use devise or similar.")
6
- super
7
- end
6
+ self.deprecation_horizon = 'hydra-head 5.x'
8
7
 
9
8
  def can_be_superuser?
10
9
  Superuser.find_by_user_id(self.id) ? true : false
11
10
  end
11
+ deprecation_deprecate :can_be_superuser?
12
12
 
13
13
  def is_being_superuser?(session=nil)
14
14
  return false if session.nil?
15
15
  session[:superuser_mode] ? true : false
16
16
  end
17
+ deprecation_deprecate :is_being_superuser?
17
18
 
18
- end
19
+ end