hydra-head 4.0.0.rc6 → 4.0.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 +0 -4
- data/Gemfile.lock +54 -57
- data/README.textile +8 -16
- data/app/assets/stylesheets/hydra/html_refactor.css +3 -9
- data/app/assets/stylesheets/hydra/styles.css +5 -120
- data/app/helpers/facets_helper.rb +4 -0
- data/app/helpers/hydra/blacklight_helper_behavior.rb +9 -41
- data/app/helpers/hydra/facets_helper_behavior.rb +27 -0
- data/app/models/hydra/ability.rb +48 -41
- data/app/models/hydra/role_mapper_behavior.rb +32 -0
- data/app/models/role_mapper.rb +1 -20
- data/config/jetty.yml +6 -0
- data/hydra-head.gemspec +4 -5
- data/lib/generators/hydra/assets_generator.rb +0 -1
- data/lib/hydra-head/version.rb +1 -1
- data/lib/hydra/access_controls_enforcement.rb +4 -64
- data/test_support/etc/Gemfile +1 -0
- data/test_support/features/absent_model_search_result.feature +2 -2
- data/test_support/features/default_partials_search_result.feature +3 -3
- data/test_support/features/generic_content_search_result.feature +3 -3
- data/test_support/features/generic_image_search_result.feature +3 -3
- data/test_support/features/mods_asset_search_result.feature +1 -1
- data/test_support/features/mods_asset_show.feature +1 -1
- data/test_support/features/step_definitions/edit_metadata_steps.rb +1 -1
- data/test_support/features/step_definitions/html_validity_steps.rb +11 -1
- data/test_support/features/view_catalog_index.feature +1 -1
- data/test_support/spec/controllers/catalog_controller_spec.rb +4 -2
- data/test_support/spec/controllers/catalog_controller_viewing_context_spec.rb +2 -4
- data/test_support/spec/controllers/catalog_valid_html_spec.rb +4 -7
- data/test_support/spec/controllers/file_assets_controller_spec.rb +1 -0
- data/test_support/spec/helpers/access_controls_enforcement_spec.rb +0 -59
- data/test_support/spec/helpers/access_controls_evaluation_spec.rb +2 -2
- data/test_support/spec/helpers/blacklight_helper_spec.rb +1 -17
- data/test_support/spec/models/ability_spec.rb +34 -4
- data/vendor/cache/actionmailer-3.2.3.gem +0 -0
- data/vendor/cache/actionpack-3.2.3.gem +0 -0
- data/vendor/cache/{active-fedora-4.0.0.rc20.gem → active-fedora-4.0.0.gem} +0 -0
- data/vendor/cache/activemodel-3.2.3.gem +0 -0
- data/vendor/cache/activerecord-3.2.3.gem +0 -0
- data/vendor/cache/activeresource-3.2.3.gem +0 -0
- data/vendor/cache/activesupport-3.2.3.gem +0 -0
- data/vendor/cache/{blacklight-3.3.1.gem → blacklight-3.3.2.gem} +0 -0
- data/vendor/cache/factory_girl-3.1.1.gem +0 -0
- data/vendor/cache/fssm-0.2.9.gem +0 -0
- data/vendor/cache/libwebsocket-0.1.3.gem +0 -0
- data/vendor/cache/mocha-0.11.0.gem +0 -0
- data/vendor/cache/multi_json-1.3.2.gem +0 -0
- data/vendor/cache/{rails-3.2.2.gem → rails-3.2.3.gem} +0 -0
- data/vendor/cache/railties-3.2.3.gem +0 -0
- data/vendor/cache/rdf-0.3.5.2.gem +0 -0
- data/vendor/cache/rsolr-1.0.8.gem +0 -0
- data/vendor/cache/rspec-expectations-2.9.1.gem +0 -0
- data/vendor/cache/rubydora-0.5.8.gem +0 -0
- data/vendor/cache/rubyzip-0.9.7.gem +0 -0
- data/vendor/cache/sass-3.1.16.gem +0 -0
- data/vendor/cache/selenium-webdriver-2.21.2.gem +0 -0
- data/vendor/cache/solrizer-fedora-2.0.0.gem +0 -0
- data/vendor/cache/sqlite3-1.3.6.gem +0 -0
- data/vendor/cache/tzinfo-0.3.33.gem +0 -0
- metadata +158 -76
- data/Tools.textile +0 -72
- data/app/views/catalog/_search_form.html.erb +0 -12
- data/vendor/cache/actionmailer-3.2.2.gem +0 -0
- data/vendor/cache/actionpack-3.2.2.gem +0 -0
- data/vendor/cache/activemodel-3.2.2.gem +0 -0
- data/vendor/cache/activerecord-3.2.2.gem +0 -0
- data/vendor/cache/activeresource-3.2.2.gem +0 -0
- data/vendor/cache/activesupport-3.2.2.gem +0 -0
- data/vendor/cache/factory_girl-3.0.0.gem +0 -0
- data/vendor/cache/fssm-0.2.8.1.gem +0 -0
- data/vendor/cache/mocha-0.10.5.gem +0 -0
- data/vendor/cache/multi_json-1.2.0.gem +0 -0
- data/vendor/cache/railties-3.2.2.gem +0 -0
- data/vendor/cache/rdf-0.3.5.1.gem +0 -0
- data/vendor/cache/rsolr-1.0.6.gem +0 -0
- data/vendor/cache/rspec-expectations-2.9.0.gem +0 -0
- data/vendor/cache/rubydora-0.5.7.gem +0 -0
- data/vendor/cache/rubyzip-0.9.6.1.gem +0 -0
- data/vendor/cache/sass-3.1.15.gem +0 -0
- data/vendor/cache/selenium-webdriver-2.20.0.gem +0 -0
- data/vendor/cache/solr-ruby-0.0.8.gem +0 -0
- data/vendor/cache/solrizer-fedora-1.2.5.gem +0 -0
- data/vendor/cache/sqlite3-1.3.5.gem +0 -0
- data/vendor/cache/tzinfo-0.3.32.gem +0 -0
@@ -6,11 +6,8 @@ module Hydra
|
|
6
6
|
include Blacklight::BlacklightHelperBehavior
|
7
7
|
include HydraHelper
|
8
8
|
|
9
|
-
def application_name
|
10
|
-
'A Hydra Head'
|
11
|
-
end
|
12
|
-
|
13
9
|
def get_data_with_linked_label(doc, label, field_string, opts={})
|
10
|
+
ActiveSupport::Deprecation.warn("get_data_with_linked_label is deprecated and will be removed in the next release")
|
14
11
|
|
15
12
|
(opts[:default] and !doc[field_string]) ? field = opts[:default] : field = doc[field_string]
|
16
13
|
delim = opts[:delimiter] ? opts[:delimiter] : "<br/>"
|
@@ -29,6 +26,7 @@ module Hydra
|
|
29
26
|
end
|
30
27
|
|
31
28
|
def linked_label(field, field_string)
|
29
|
+
ActiveSupport::Deprecation.warn("linked_label is deprecated and will be removed in the next release")
|
32
30
|
link_to(field, add_facet_params(field_string, field).merge!({"controller" => "catalog", :action=> "index"}))
|
33
31
|
end
|
34
32
|
|
@@ -45,35 +43,20 @@ module Hydra
|
|
45
43
|
["%2$s/%1$s"] + super
|
46
44
|
end
|
47
45
|
|
48
|
-
# Removing the [remove] link from the default selected facet display
|
49
|
-
def render_selected_facet_value(facet_solr_field, item)
|
50
|
-
content_tag(:span, render_facet_value(facet_solr_field, item, :suppress_link => true), :class => "selected label")
|
51
|
-
end
|
52
|
-
|
53
|
-
|
54
|
-
###
|
55
|
-
### Overrides pulled in from Libra
|
56
|
-
###
|
57
|
-
|
58
|
-
def render_facet_value(facet_solr_field, item, options ={})
|
59
|
-
if item.is_a? Array
|
60
|
-
return link_to_unless(options[:suppress_link], item[0], add_facet_params_and_redirect(facet_solr_field, item[0]), :class=>"facet_select") + " (" + format_num(item[1]) + ")"
|
61
|
-
end
|
62
|
-
|
63
|
-
super
|
64
|
-
end
|
65
|
-
|
66
46
|
def render_complex_facet_value(facet_solr_field, item, options ={})
|
47
|
+
ActiveSupport::Deprecation.warn("render_complex_facet_value is deprecated and will be removed in the next release")
|
67
48
|
link_to_unless(options[:suppress_link], format_item_value(item.value), add_facet_params_and_redirect(facet_solr_field, item.value), :class=>"facet_select") + " (" + format_num(item.hits) + ")"
|
68
49
|
end
|
69
50
|
|
70
51
|
def render_journal_facet_value(facet_solr_field, item, options ={})
|
52
|
+
ActiveSupport::Deprecation.warn("render_journal_facet_value is deprecated and will be removed in the next release")
|
71
53
|
|
72
54
|
val = item.value.strip.length > 12 ? item.value.strip[0..12].concat("...") : item.value.strip
|
73
55
|
link_to_unless(options[:suppress_link], val, add_facet_params_and_redirect(facet_solr_field, item.value), :class=>"facet_select") + " (" + format_num(item.hits) + ")"
|
74
56
|
end
|
75
57
|
|
76
58
|
def render_complex_facet_image(facet_solr_field, item, options = {})
|
59
|
+
ActiveSupport::Deprecation.warn("render_complex_facet_image is deprecated and will be removed in the next release")
|
77
60
|
computing_id = extract_computing_id(item.value)
|
78
61
|
if File.exists?("#{Rails.root}/public/images/faculty_images/#{computing_id}.jpg")
|
79
62
|
img = image_tag "/images/faculty_images/#{computing_id}.jpg", :width=> "100", :alt=>"#{item.value}"
|
@@ -84,6 +67,7 @@ module Hydra
|
|
84
67
|
end
|
85
68
|
|
86
69
|
def render_journal_image(facet_solr_field, item, options = {})
|
70
|
+
ActiveSupport::Deprecation.warn("render_journal_image is deprecated and will be removed in the next release")
|
87
71
|
if File.exists?("#{Rails.root}/public/images/journal_images/#{item.value.strip.downcase.gsub(/\s+/,'_')}.jpg")
|
88
72
|
img = image_tag "/images/journal_images/#{item.value.strip.downcase.gsub(/\s+/,'_')}.jpg", :width => "100"
|
89
73
|
else
|
@@ -94,6 +78,7 @@ module Hydra
|
|
94
78
|
end
|
95
79
|
|
96
80
|
def get_randomized_display_items items
|
81
|
+
ActiveSupport::Deprecation.warn("get_randomized_display_items is deprecated and will be removed in the next release")
|
97
82
|
clean_items = items.each.inject([]) do |array, item|
|
98
83
|
array << item unless item.value.strip.blank?
|
99
84
|
array
|
@@ -109,11 +94,13 @@ module Hydra
|
|
109
94
|
end
|
110
95
|
|
111
96
|
def extract_computing_id val
|
97
|
+
ActiveSupport::Deprecation.warn("extract_computing_id is deprecated and will be removed in the next release")
|
112
98
|
cid = val.split(" ")[-1]
|
113
99
|
cid[1..cid.length-2]
|
114
100
|
end
|
115
101
|
|
116
102
|
def format_item_value val
|
103
|
+
ActiveSupport::Deprecation.warn("format_item_value is deprecated and will be removed in the next release")
|
117
104
|
begin
|
118
105
|
last, f_c = val.split(", ")
|
119
106
|
first = f_c.split(" (")[0]
|
@@ -123,25 +110,6 @@ module Hydra
|
|
123
110
|
[last, "#{first[0..0]}."].join(", ")
|
124
111
|
end
|
125
112
|
|
126
|
-
def render_head_content
|
127
|
-
render_stylesheet_includes +
|
128
|
-
render_js_includes +
|
129
|
-
render_extra_head_content_without_unapi +
|
130
|
-
content_for(:head)
|
131
|
-
end
|
132
|
-
|
133
|
-
def render_extra_head_content_without_unapi
|
134
|
-
remove_unapi!
|
135
|
-
render_extra_head_content
|
136
|
-
end
|
137
|
-
|
138
|
-
# rel="unapi-server" is not HTML5 valid. Need to see if there is a way to do that properly while still validating.
|
139
|
-
def remove_unapi!
|
140
|
-
extra_head_content.delete_if do |ehc|
|
141
|
-
ehc.include?("unapi-server")
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
113
|
# COPIED from vendor/plugins/blacklight/app/helpers/application_helper.rb
|
146
114
|
# Used in catalog/facet action, facets.rb view, for a click
|
147
115
|
# on a facet value. Add on the facet params to existing
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Hydra
|
2
|
+
module FacetsHelperBehavior
|
3
|
+
include Blacklight::FacetsHelperBehavior
|
4
|
+
|
5
|
+
# Removing the [remove] link and label class from the default selected facet display
|
6
|
+
def render_selected_facet_value(facet_solr_field, item)
|
7
|
+
content_tag(:span, render_facet_value(facet_solr_field, item, :suppress_link => true), :class => "selected")
|
8
|
+
end
|
9
|
+
|
10
|
+
# @override to remove the label class (easier integration with bootstrap)
|
11
|
+
# and handles arrays
|
12
|
+
def render_facet_value(facet_solr_field, item, options ={})
|
13
|
+
if item.is_a? Array
|
14
|
+
render_array_facet_value(facet_solr_field, item, options)
|
15
|
+
end
|
16
|
+
|
17
|
+
(link_to_unless(options[:suppress_link], item.value, add_facet_params_and_redirect(facet_solr_field, item.value), :class=>"facet_select") + " " + render_facet_count(item.hits)).html_safe
|
18
|
+
end
|
19
|
+
|
20
|
+
def render_array_facet_value(facet_solr_field, item, options)
|
21
|
+
ActiveSupport::Deprecation.warn("render_array_facet_value is deprecated and will be removed in the next release")
|
22
|
+
|
23
|
+
(link_to_unless(options[:suppress_link], item[0], add_facet_params_and_redirect(facet_solr_field, item[0]), :class=>"facet_select") + " (" + format_num(item[1]) + ")").html_safe
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
data/app/models/hydra/ability.rb
CHANGED
@@ -1,67 +1,64 @@
|
|
1
1
|
module Hydra::Ability
|
2
2
|
include Hydra::AccessControlsEnforcement
|
3
3
|
|
4
|
-
attr_reader :user, :user_groups
|
5
|
-
|
6
4
|
def initialize(user, session=nil)
|
7
5
|
user ||= User.new # guest user (not logged in)
|
8
|
-
|
9
|
-
|
6
|
+
hydra_default_permissions(user, session)
|
7
|
+
end
|
8
|
+
|
9
|
+
## You can override this method if you are using a different AuthZ (such as LDAP)
|
10
|
+
def user_groups(user, session)
|
11
|
+
return @user_groups if @user_groups
|
12
|
+
@user_groups = RoleMapper.roles(user_key(user)) + default_user_groups
|
13
|
+
@user_groups << 'registered' unless user.new_record?
|
14
|
+
@user_groups
|
15
|
+
end
|
16
|
+
|
17
|
+
def default_user_groups
|
10
18
|
# # everyone is automatically a member of the group 'public'
|
11
|
-
|
12
|
-
# # logged-in users are automatically members of the group "registered"
|
13
|
-
# @user_groups.push 'registered' unless (@user.email == '' || @user == "public" || @user_groups.include?('registered') )
|
14
|
-
|
15
|
-
logger.debug("Usergroups is " + @user_groups.inspect)
|
16
|
-
|
17
|
-
if @user.is_being_superuser?(session)
|
18
|
-
can :manage, :all
|
19
|
-
else
|
20
|
-
hydra_default_permissions(user, session)
|
21
|
-
end
|
19
|
+
['public']
|
22
20
|
end
|
21
|
+
|
23
22
|
|
24
23
|
def hydra_default_permissions(user, session)
|
25
|
-
|
26
|
-
|
27
|
-
|
24
|
+
logger.debug("Usergroups are " + user_groups(user, session).inspect)
|
25
|
+
if user.is_being_superuser?(session)
|
26
|
+
can :manage, :all
|
27
|
+
else
|
28
|
+
edit_permissions(user, session)
|
29
|
+
read_permissions(user, session)
|
30
|
+
custom_permissions(user, session)
|
31
|
+
end
|
28
32
|
end
|
29
33
|
|
30
34
|
def edit_permissions(user, session)
|
31
35
|
can :edit, String do |pid|
|
32
|
-
|
33
|
-
test_edit
|
36
|
+
test_edit(pid, user, session)
|
34
37
|
end
|
35
38
|
|
36
39
|
can :edit, ActiveFedora::Base do |obj|
|
37
|
-
|
38
|
-
test_edit
|
40
|
+
test_edit(obj.pid, user, session)
|
39
41
|
end
|
40
42
|
|
41
43
|
can :edit, SolrDocument do |obj|
|
42
44
|
@permissions_solr_document = obj
|
43
|
-
test_edit
|
45
|
+
test_edit(obj.id, user, session)
|
44
46
|
end
|
45
47
|
|
46
|
-
can :edit, SolrDocument do |obj|
|
47
|
-
test_edit
|
48
|
-
end
|
49
48
|
end
|
50
49
|
|
51
50
|
def read_permissions(user, session)
|
52
51
|
can :read, String do |pid|
|
53
|
-
|
54
|
-
test_read
|
52
|
+
test_read(pid, user, session)
|
55
53
|
end
|
56
54
|
|
57
55
|
can :read, ActiveFedora::Base do |obj|
|
58
|
-
|
59
|
-
test_read
|
56
|
+
test_read(obj.pid, user, session)
|
60
57
|
end
|
61
58
|
|
62
59
|
can :read, SolrDocument do |obj|
|
63
60
|
@permissions_solr_document = obj
|
64
|
-
test_read
|
61
|
+
test_read(obj.id, user, session)
|
65
62
|
end
|
66
63
|
end
|
67
64
|
|
@@ -71,18 +68,28 @@ module Hydra::Ability
|
|
71
68
|
end
|
72
69
|
|
73
70
|
protected
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
71
|
+
|
72
|
+
def permissions_doc(pid)
|
73
|
+
return @permissions_solr_document if @permissions_solr_document
|
74
|
+
response, @permissions_solr_document = get_permissions_solr_response_for_doc_id(pid)
|
75
|
+
@permissions_solr_document
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
def test_edit(pid, user, session)
|
80
|
+
permissions_doc(pid)
|
81
|
+
logger.debug("CANCAN Checking edit permissions for user: #{user}")
|
82
|
+
group_intersection = user_groups(user, session) & edit_groups
|
83
|
+
result = !group_intersection.empty? || edit_persons.include?(user_key(user))
|
78
84
|
logger.debug("CANCAN decision: #{result}")
|
79
85
|
result
|
80
86
|
end
|
81
87
|
|
82
|
-
def test_read
|
83
|
-
|
84
|
-
|
85
|
-
|
88
|
+
def test_read(pid, user, session)
|
89
|
+
permissions_doc(pid)
|
90
|
+
logger.debug("CANCAN Checking edit permissions for user: #{user}")
|
91
|
+
group_intersection = user_groups(user, session) & read_groups
|
92
|
+
result = !group_intersection.empty? || read_persons.include?(user_key(user))
|
86
93
|
logger.debug("CANCAN decision: #{result}")
|
87
94
|
result
|
88
95
|
end
|
@@ -120,8 +127,8 @@ module Hydra::Ability
|
|
120
127
|
|
121
128
|
# get the currently configured user identifier. Can be overridden to return whatever (ie. login, email, etc)
|
122
129
|
# defaults to using whatever you have set as the Devise authentication_key
|
123
|
-
def user_key
|
124
|
-
|
130
|
+
def user_key(user)
|
131
|
+
user.send(Devise.authentication_keys.first)
|
125
132
|
end
|
126
133
|
|
127
134
|
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
module Hydra::RoleMapperBehavior
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def role_names
|
7
|
+
map.keys
|
8
|
+
end
|
9
|
+
def roles(username)
|
10
|
+
byname[username]||[]
|
11
|
+
end
|
12
|
+
|
13
|
+
def whois(r)
|
14
|
+
map[r]||[]
|
15
|
+
end
|
16
|
+
|
17
|
+
def map
|
18
|
+
@map ||= YAML.load(File.open(File.join(Rails.root, "config/role_map_#{Rails.env}.yml")))
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def byname
|
23
|
+
return @byname if @byname
|
24
|
+
m = Hash.new{|h,k| h[k]=[]}
|
25
|
+
@byname = map.inject(m) do|memo, (role,usernames)|
|
26
|
+
((usernames if usernames.respond_to?(:each)) || [usernames]).each { |x| memo[x]<<role}
|
27
|
+
memo
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
data/app/models/role_mapper.rb
CHANGED
@@ -1,22 +1,3 @@
|
|
1
|
-
require 'yaml'
|
2
1
|
class RoleMapper
|
3
|
-
|
4
|
-
m = Hash.new{|h,k| h[k]=[]}
|
5
|
-
@@byname = @@map.inject(m) do|memo, (role,usernames)|
|
6
|
-
((usernames if usernames.respond_to?(:each)) || [usernames]).each { |x| memo[x]<<role}
|
7
|
-
memo
|
8
|
-
end
|
9
|
-
class << self
|
10
|
-
def role_names
|
11
|
-
@@map.keys
|
12
|
-
end
|
13
|
-
def roles(username)
|
14
|
-
@@byname[username]||[]
|
15
|
-
end
|
16
|
-
|
17
|
-
def whois(r)
|
18
|
-
@@map[r]||[]
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
2
|
+
include Hydra::RoleMapperBehavior
|
22
3
|
end
|
data/config/jetty.yml
ADDED
data/hydra-head.gemspec
CHANGED
@@ -12,24 +12,23 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.summary = %q{Hydra-Head Rails Engine (requires Rails3) }
|
13
13
|
s.description = %q{Hydra-Head is a Rails Engine containing the core code for a Hydra application. The full hydra stack includes: Blacklight, Fedora, Solr, active-fedora, solrizer, and om}
|
14
14
|
|
15
|
-
s.add_dependency "rails", '3.2.
|
16
|
-
s.add_dependency "blacklight", '~>3.3.
|
15
|
+
s.add_dependency "rails", '3.2.3'
|
16
|
+
s.add_dependency "blacklight", '~>3.3.2'
|
17
17
|
s.add_dependency "devise"
|
18
|
-
s.add_dependency "active-fedora", '~>4.0.0
|
18
|
+
s.add_dependency "active-fedora", '~>4.0.0'
|
19
19
|
s.add_dependency 'RedCloth', '=4.2.9'
|
20
|
-
s.add_development_dependency 'solrizer-fedora', '>=1.2.5'
|
21
20
|
s.add_dependency 'block_helpers'
|
22
21
|
s.add_dependency 'sanitize'
|
23
22
|
s.add_dependency 'cancan'
|
24
23
|
|
25
24
|
s.add_development_dependency 'sqlite3'
|
26
|
-
|
27
25
|
s.add_development_dependency 'yard'
|
28
26
|
s.add_development_dependency 'jettywrapper', ">=1.0.4"
|
29
27
|
s.add_development_dependency 'rspec-rails'
|
30
28
|
s.add_development_dependency 'mocha'
|
31
29
|
s.add_development_dependency 'cucumber-rails', '>=1.2.0'
|
32
30
|
s.add_development_dependency 'factory_girl'
|
31
|
+
s.add_development_dependency 'solrizer-fedora', '>=2.0.0'
|
33
32
|
|
34
33
|
|
35
34
|
s.files = `git ls-files`.split("\n")
|
data/lib/hydra-head/version.rb
CHANGED
@@ -103,13 +103,13 @@ module Hydra::AccessControlsEnforcement
|
|
103
103
|
# check for depositor raise "#{@document["depositor_t"].first} --- #{user_key}"
|
104
104
|
### Assuming we're using devise and have only one authentication key
|
105
105
|
unless current_user && user_key == @permissions_solr_document["depositor_t"].first
|
106
|
-
flash[:
|
106
|
+
flash[:alert] = "This item is under embargo. You do not have sufficient access privileges to read this document."
|
107
107
|
redirect_to(:action=>'index', :q=>nil, :f=>nil) and return false
|
108
108
|
end
|
109
109
|
end
|
110
110
|
end
|
111
111
|
unless can? :read, params[:id]
|
112
|
-
flash[:
|
112
|
+
flash[:alert]= "You do not have sufficient access privileges to read this document, which has been marked private."
|
113
113
|
redirect_to(:action => 'index', :q => nil , :f => nil) and return false
|
114
114
|
end
|
115
115
|
end
|
@@ -143,12 +143,8 @@ module Hydra::AccessControlsEnforcement
|
|
143
143
|
# Currently does nothing, instead relies on
|
144
144
|
# @param [Hash] opts (optional, not currently used)
|
145
145
|
def enforce_index_permissions(opts={})
|
146
|
-
return true
|
147
146
|
# Do nothing. Relies on enforce_search_permissions being included in the Controller's solr_search_params_logic
|
148
|
-
|
149
|
-
# if !reader?
|
150
|
-
# solr_parameters[:qt] = Blacklight.config[:public_qt]
|
151
|
-
# end
|
147
|
+
return true
|
152
148
|
end
|
153
149
|
|
154
150
|
#
|
@@ -168,9 +164,6 @@ module Hydra::AccessControlsEnforcement
|
|
168
164
|
# end
|
169
165
|
def add_access_controls_to_solr_params(solr_parameters, user_parameters)
|
170
166
|
apply_gated_discovery(solr_parameters, user_parameters)
|
171
|
-
if !can? :read, params[:id]
|
172
|
-
solr_parameters[:qt] = Blacklight.config[:public_qt]
|
173
|
-
end
|
174
167
|
end
|
175
168
|
|
176
169
|
# Contrller before filter that sets up access-controlled lucene query in order to provide gated discovery behavior
|
@@ -189,7 +182,7 @@ module Hydra::AccessControlsEnforcement
|
|
189
182
|
# Grant access based on user id & role
|
190
183
|
unless current_user.nil?
|
191
184
|
# for roles
|
192
|
-
RoleMapper.roles(user_key).each_with_index do |role, i|
|
185
|
+
::RoleMapper.roles(user_key).each_with_index do |role, i|
|
193
186
|
permission_types.each do |type|
|
194
187
|
user_access_filters << "#{type}_access_group_t:#{role}"
|
195
188
|
end
|
@@ -234,57 +227,4 @@ module Hydra::AccessControlsEnforcement
|
|
234
227
|
solr_parameters[:fq] ||= []
|
235
228
|
solr_parameters[:fq] << "-has_model_s:\"info:fedora/afmodel:FileAsset\""
|
236
229
|
end
|
237
|
-
|
238
|
-
# Build the lucene query that performs gated discovery based on Hydra rightsMetadata information in Solr
|
239
|
-
# @param [String] user_query the user's original query request that will be wrapped in access controls
|
240
|
-
def build_lucene_query(user_query)
|
241
|
-
logger.warn("DEPRECATED: build_lucene_query has been deprecated. Recommended convention is to use blacklight's dismax search requestHandler (not lucene) and filter queries with :fq solr parameters. See Hydra::AccessControlsEnforcement#apply_gated_discovery and Hydra::AccessControlsEnforcement#exclude_unwanted_models")
|
242
|
-
q = ""
|
243
|
-
# start query of with user supplied query term
|
244
|
-
q << "_query_:\"{!dismax qf=$qf_dismax pf=$pf_dismax}#{user_query}\" AND " if user_query
|
245
|
-
|
246
|
-
|
247
|
-
# Append the exclusion of FileAssets
|
248
|
-
q << "NOT _query_:\"info\\\\:fedora/afmodel\\\\:FileAsset\""
|
249
|
-
|
250
|
-
# Append the query responsible for adding the users discovery level
|
251
|
-
permission_types = ["edit","discover","read"]
|
252
|
-
field_queries = []
|
253
|
-
embargo_query = ""
|
254
|
-
permission_types.each do |type|
|
255
|
-
field_queries << "_query_:\"#{type}_access_group_t:public\""
|
256
|
-
end
|
257
|
-
|
258
|
-
unless current_user.nil?
|
259
|
-
# for roles
|
260
|
-
RoleMapper.roles(user_key).each do |role|
|
261
|
-
permission_types.each do |type|
|
262
|
-
field_queries << "_query_:\"#{type}_access_group_t:#{role}\""
|
263
|
-
end
|
264
|
-
end
|
265
|
-
# for individual person access
|
266
|
-
permission_types.each do |type|
|
267
|
-
field_queries << "_query_:\"#{type}_access_person_t:#{user_key}\""
|
268
|
-
end
|
269
|
-
if current_user.is_being_superuser?(session)
|
270
|
-
permission_types.each do |type|
|
271
|
-
field_queries << "_query_:\"#{type}_access_person_t:[* TO *]\""
|
272
|
-
end
|
273
|
-
end
|
274
|
-
|
275
|
-
# if it is the depositor and it is under embargo, that is ok
|
276
|
-
# otherwise if it not the depositor and it is under embargo, don't show it
|
277
|
-
embargo_query = " OR ((_query_:\"embargo_release_date_dt:[NOW TO *]\" AND _query_:\"depositor_t:#{user_key}\") AND NOT (NOT _query_:\"depositor_t:#{user_key}\" AND _query_:\"embargo_release_date_dt:[NOW TO *]\"))"
|
278
|
-
end
|
279
|
-
|
280
|
-
# remove anything with an embargo release date in the future
|
281
|
-
#embargo_query = " AND NOT _query_:\"embargo_release_date_dt:[NOW TO *]\"" if embargo_query.blank?
|
282
|
-
field_queries << " NOT _query_:\"embargo_release_date_dt:[NOW TO *]\"" if embargo_query.blank?
|
283
|
-
|
284
|
-
q << " AND (#{field_queries.join(" OR ")})"
|
285
|
-
q << embargo_query
|
286
|
-
return q
|
287
|
-
end
|
288
|
-
|
289
|
-
|
290
230
|
end
|