blacklight-spotlight 2.10.0 → 2.11.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.
- checksums.yaml +4 -4
- data/app/controllers/spotlight/admin_users_controller.rb +19 -0
- data/app/presenters/spotlight/iiif_manifest_presenter.rb +2 -1
- data/app/views/spotlight/admin_users/index.html.erb +39 -9
- data/config/locales/spotlight.en.yml +7 -5
- data/config/routes.rb +1 -1
- data/lib/spotlight/version.rb +1 -1
- data/spec/controllers/spotlight/admin_users_controller_spec.rb +10 -0
- data/spec/features/{site_admin_management_spec.rb → site_users_management_spec.rb} +9 -22
- data/spec/presenters/spotlight/iiif_manifest_presenter_spec.rb +2 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 39211a3860e438e3c2e28f6bacc050376b3ab2d27e541050b76a59a17848a553
|
4
|
+
data.tar.gz: 6902e8411a19aa2832a6a839bab19b74782644e35359d54f3151df6e898c1333
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfdcfb3f10e852a74e960f51cf5b360897dac4279bfc8c0cede9a869595e49688ea596a802b0227b11c3459fc30d227de59e3210e9baa14e23a0813804c6a227
|
7
|
+
data.tar.gz: e57d609f2125a8042835d0d78950c67b94992f22ba1e38664301acc05bb9617374b513ce654b9b73b0a883719d2dec5b4e337dfe8908be1e71969dc7ae1b2b11
|
@@ -6,6 +6,8 @@ module Spotlight
|
|
6
6
|
class AdminUsersController < Spotlight::ApplicationController
|
7
7
|
before_action :authenticate_user!
|
8
8
|
before_action :load_site
|
9
|
+
before_action :load_users
|
10
|
+
|
9
11
|
load_and_authorize_resource :site, class: 'Spotlight::Site'
|
10
12
|
|
11
13
|
def index; end
|
@@ -17,6 +19,19 @@ module Spotlight
|
|
17
19
|
else
|
18
20
|
flash[:error] = t('spotlight.admin_users.create.error')
|
19
21
|
end
|
22
|
+
|
23
|
+
redirect_to spotlight.admin_users_path
|
24
|
+
end
|
25
|
+
|
26
|
+
def update
|
27
|
+
user = Spotlight::Engine.user_class.find(params[:id])
|
28
|
+
if user
|
29
|
+
Spotlight::Role.create(user_key: user.email, role: 'admin', resource: @site).save
|
30
|
+
flash[:notice] = t('spotlight.admin_users.create.success')
|
31
|
+
else
|
32
|
+
flash[:error] = t('spotlight.admin_users.create.error')
|
33
|
+
end
|
34
|
+
|
20
35
|
redirect_to spotlight.admin_users_path
|
21
36
|
end
|
22
37
|
|
@@ -32,6 +47,10 @@ module Spotlight
|
|
32
47
|
|
33
48
|
private
|
34
49
|
|
50
|
+
def load_users
|
51
|
+
@users ||= ::User.all.reject(&:guest?)
|
52
|
+
end
|
53
|
+
|
35
54
|
def load_site
|
36
55
|
@site ||= Spotlight::Site.instance
|
37
56
|
end
|
@@ -76,7 +76,8 @@ module Spotlight
|
|
76
76
|
def iiif_url
|
77
77
|
Spotlight::Engine.config.iiif_url_helpers.info_url(
|
78
78
|
uploaded_resource.upload.id,
|
79
|
-
host: controller.request.host_with_port
|
79
|
+
host: controller.request.host_with_port,
|
80
|
+
protocol: controller.request.protocol
|
80
81
|
).sub(%r{/info\.json\Z}, '')
|
81
82
|
end
|
82
83
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<div id="content" class="col-md-9 admin-users">
|
2
2
|
<%= page_title(t('.section'), t('.page_title')) %>
|
3
3
|
<%= bootstrap_form_for Spotlight::Engine.user_class.new, url: spotlight.admin_users_path do |f| %>
|
4
|
-
<
|
4
|
+
<h3 class="instructions"><%= t :'.instructions' %></h3>
|
5
5
|
<table class="table table-striped ">
|
6
6
|
<thead>
|
7
7
|
<tr>
|
@@ -43,20 +43,50 @@
|
|
43
43
|
|
44
44
|
<div class="form-actions">
|
45
45
|
<div class="primary-actions">
|
46
|
-
<%= link_to(t('.
|
46
|
+
<%= link_to(t('.create'), 'javascript:;', class: 'btn btn-default', data: { behavior: 'new-user' }) %>
|
47
47
|
</div>
|
48
48
|
</div>
|
49
|
-
<% end %>
|
50
49
|
|
51
|
-
|
52
|
-
|
50
|
+
<h3 class="instructions"><%= t :'.admins_curators' %></h3>
|
51
|
+
<div id="admins_curators" class="well well-sm">
|
53
52
|
<div class='btn-toolbar pull-right'>
|
54
|
-
|
55
|
-
|
56
|
-
|
53
|
+
<button class="btn btn-xs btn-default copy-email-addresses" data-clipboard-target="#admins_curators">
|
54
|
+
<%= t('.copy') %>
|
55
|
+
</button>
|
57
56
|
</div>
|
58
57
|
<%= Spotlight::Engine.user_class.with_roles.pluck(:email).sort.join(', ') %>
|
59
|
-
|
58
|
+
</div>
|
59
|
+
|
60
|
+
<h3 class="instructions"><%= t :'.all_users' %></h3>
|
61
|
+
<table class="table table-striped ">
|
62
|
+
<thead>
|
63
|
+
<tr>
|
64
|
+
<th><%= Spotlight::Engine.user_class.human_attribute_name(:email) %></th>
|
65
|
+
<th><%= Spotlight::Engine.user_class.human_attribute_name(:role) %></th>
|
66
|
+
</tr>
|
67
|
+
</thead>
|
68
|
+
<tbody class="table">
|
69
|
+
<% @users.each do |user| %>
|
70
|
+
<tr>
|
71
|
+
<td class="<%= 'invite-pending' if user.invite_pending? %>">
|
72
|
+
<%= user.email %>
|
73
|
+
<span class='label label-warning pending-label'><%= t('.pending') %></span>
|
74
|
+
</td>
|
75
|
+
<td class="role">
|
76
|
+
<%= user.roles.map { |r| r.role.titleize }.uniq.join(", ") %>
|
77
|
+
</td>
|
78
|
+
<td>
|
79
|
+
<% if user.superadmin? %>
|
80
|
+
<%= link_to(t('.destroy'), admin_user_path(user), method: :delete, class: 'btn btn-danger pull-right') unless user == current_user %>
|
81
|
+
<% else %>
|
82
|
+
<%= link_to(t('.update'), admin_user_path(user), method: :patch, class: 'btn btn-default pull-right') %>
|
83
|
+
<% end %>
|
84
|
+
</td>
|
85
|
+
</tr>
|
86
|
+
<% end %>
|
87
|
+
</tbody>
|
88
|
+
</table>
|
89
|
+
<% end %>
|
60
90
|
</div>
|
61
91
|
|
62
92
|
<aside class="col-md-3">
|
@@ -172,20 +172,22 @@ en:
|
|
172
172
|
admin_users:
|
173
173
|
create:
|
174
174
|
error: There was a problem adding the user as an exhibits adminstrator
|
175
|
-
success: Added user as an
|
175
|
+
success: Added user as an adminstrator
|
176
176
|
destroy:
|
177
177
|
error: There was a problem removing the user from the site adminstrator role
|
178
178
|
success: User removed from site adminstrator role
|
179
179
|
index:
|
180
|
-
|
181
|
-
all_users:
|
180
|
+
admins_curators: Administrators and curators of all exhibits
|
181
|
+
all_users: All registered users
|
182
182
|
copy: Copy
|
183
|
-
|
183
|
+
create: Add new administrator
|
184
|
+
destroy: Remove from admin role
|
184
185
|
instructions: Existing exhibits administrators
|
185
|
-
page_title: Manage
|
186
|
+
page_title: Manage users
|
186
187
|
pending: pending
|
187
188
|
save: Add role
|
188
189
|
section: Manage exhibits
|
190
|
+
update: Make user an administrator
|
189
191
|
appearances:
|
190
192
|
edit:
|
191
193
|
header: Appearance
|
data/config/routes.rb
CHANGED
@@ -16,7 +16,7 @@ Spotlight::Engine.routes.draw do
|
|
16
16
|
|
17
17
|
get '/exhibits/edit', to: 'sites#edit_exhibits', as: 'edit_site_exhibits'
|
18
18
|
|
19
|
-
resources :admin_users, only: [:index, :create, :destroy]
|
19
|
+
resources :admin_users, only: [:index, :create, :update, :destroy]
|
20
20
|
|
21
21
|
resources :exhibits, path: '/', except: [:show] do
|
22
22
|
member do
|
data/lib/spotlight/version.rb
CHANGED
@@ -35,5 +35,15 @@ RSpec.describe Spotlight::AdminUsersController, type: :controller do
|
|
35
35
|
expect(Spotlight::Site.instance.roles.where(user_id: user.id)).to be_none
|
36
36
|
end
|
37
37
|
end
|
38
|
+
|
39
|
+
describe 'PATCH update' do
|
40
|
+
let(:non_admin) { FactoryBot.create(:exhibit_visitor) }
|
41
|
+
it 'adds the site admin role to the given user' do
|
42
|
+
patch :update, params: { id: non_admin.id }
|
43
|
+
expect(response).to redirect_to(admin_users_path)
|
44
|
+
expect(flash[:notice]).to eq 'Added user as an adminstrator'
|
45
|
+
expect(non_admin.roles.map(&:role)).to eq ['admin']
|
46
|
+
end
|
47
|
+
end
|
38
48
|
end
|
39
49
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
describe 'Site
|
3
|
+
describe 'Site users management', js: true do
|
4
4
|
let(:user) { FactoryBot.create(:site_admin) }
|
5
5
|
let!(:existing_user) { FactoryBot.create(:exhibit_visitor) }
|
6
6
|
let!(:exhibit_admin) { FactoryBot.create(:exhibit_admin) }
|
@@ -17,25 +17,14 @@ describe 'Site admin management', js: true do
|
|
17
17
|
|
18
18
|
describe 'copy email addresses' do
|
19
19
|
it 'displays only email addresses of users w/ roles' do
|
20
|
-
expect(page).to have_css('div#
|
21
|
-
expect(page).to have_css('div#
|
22
|
-
expect(page).to have_css('div#
|
23
|
-
expect(page).not_to have_css('div#
|
20
|
+
expect(page).to have_css('div#admins_curators', text: user.email)
|
21
|
+
expect(page).to have_css('div#admins_curators', text: exhibit_admin.email)
|
22
|
+
expect(page).to have_css('div#admins_curators', text: exhibit_curator.email)
|
23
|
+
expect(page).not_to have_css('div#admins_curators', text: existing_user.email)
|
24
24
|
expect(page).to have_css('button.copy-email-addresses')
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
it 'allows for existing users to be added as site adminstrators' do
|
29
|
-
expect(page).not_to have_css('td', text: existing_user.email)
|
30
|
-
click_link 'Add new administrator'
|
31
|
-
|
32
|
-
fill_in 'user_email', with: existing_user.email
|
33
|
-
click_button 'Add role'
|
34
|
-
|
35
|
-
expect(page).to have_content('Added user as an exhibits adminstrator')
|
36
|
-
expect(page).to have_css('td', text: existing_user.email)
|
37
|
-
end
|
38
|
-
|
39
28
|
it 'allows non-existing users to be invited' do
|
40
29
|
click_link 'Add new administrator'
|
41
30
|
|
@@ -55,15 +44,13 @@ describe 'Site admin management', js: true do
|
|
55
44
|
|
56
45
|
expect(page).to have_css(:td, text: 'not-an-admin@example.com')
|
57
46
|
|
58
|
-
expect(page).to have_css(:a, text: 'Remove from role', count:
|
47
|
+
expect(page).to have_css(:a, text: 'Remove from admin role', count: 4)
|
59
48
|
within(all('table tbody tr').last) do
|
60
|
-
click_link 'Remove from role'
|
49
|
+
click_link 'Remove from admin role'
|
61
50
|
end
|
62
51
|
|
63
52
|
expect(page).to have_content 'User removed from site adminstrator role'
|
64
|
-
expect(page).to have_css(:a, text: 'Remove from role', count:
|
65
|
-
|
66
|
-
expect(page).not_to have_css(:td, text: 'not-an-admin@example.com')
|
53
|
+
expect(page).to have_css(:a, text: 'Remove from admin role', count: 2)
|
67
54
|
end
|
68
55
|
|
69
56
|
it 'sends an invitation email to users who do not exist' do
|
@@ -82,6 +69,6 @@ describe 'Site admin management', js: true do
|
|
82
69
|
|
83
70
|
expect(page).to have_css('td', text: user.email)
|
84
71
|
# There are two users, the original site admin and our admin user so only one button
|
85
|
-
expect(page).to have_css(:a, text: 'Remove from role', count:
|
72
|
+
expect(page).to have_css(:a, text: 'Remove from admin role', count: 2)
|
86
73
|
end
|
87
74
|
end
|
@@ -119,7 +119,8 @@ describe Spotlight::IiifManifestPresenter do
|
|
119
119
|
|
120
120
|
describe '#iiif_url' do
|
121
121
|
it 'returns the info_url from the Riiif engine routes, minus the trailing .json' do
|
122
|
-
|
122
|
+
controller.request.stub(:protocol).and_return('https')
|
123
|
+
expect(subject.send(:iiif_url)).to eq('https://localhost:3000/images/2')
|
123
124
|
end
|
124
125
|
end
|
125
126
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight-spotlight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2019-10-
|
14
|
+
date: 2019-10-23 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -1407,8 +1407,8 @@ files:
|
|
1407
1407
|
- spec/features/main_navigation_spec.rb
|
1408
1408
|
- spec/features/metadata_admin_spec.rb
|
1409
1409
|
- spec/features/report_a_problem_spec.rb
|
1410
|
-
- spec/features/site_admin_management_spec.rb
|
1411
1410
|
- spec/features/site_masthead_spec.rb
|
1411
|
+
- spec/features/site_users_management_spec.rb
|
1412
1412
|
- spec/features/slideshow_spec.rb
|
1413
1413
|
- spec/features/translation_scope_spec.rb
|
1414
1414
|
- spec/fixtures/800x600.png
|
@@ -1643,7 +1643,6 @@ test_files:
|
|
1643
1643
|
- spec/features/exhibit_themes_spec.rb
|
1644
1644
|
- spec/features/exhibits_index_spec.rb
|
1645
1645
|
- spec/features/add_items_spec.rb
|
1646
|
-
- spec/features/site_admin_management_spec.rb
|
1647
1646
|
- spec/features/slideshow_spec.rb
|
1648
1647
|
- spec/features/browse_category_admin_spec.rb
|
1649
1648
|
- spec/features/item_admin_spec.rb
|
@@ -1660,6 +1659,7 @@ test_files:
|
|
1660
1659
|
- spec/features/add_custom_field_metadata_spec.rb
|
1661
1660
|
- spec/features/metadata_admin_spec.rb
|
1662
1661
|
- spec/features/exhibit_masthead_spec.rb
|
1662
|
+
- spec/features/site_users_management_spec.rb
|
1663
1663
|
- spec/features/exhibits/add_tags_spec.rb
|
1664
1664
|
- spec/features/exhibits/administration_spec.rb
|
1665
1665
|
- spec/features/exhibits/custom_metadata_fields_spec.rb
|