Skip to content
This repository was archived by the owner on Jan 5, 2019. It is now read-only.

Commit 69d6368

Browse files
committed
Merge branch 'tag-1.4'
2 parents 21cc603 + 7c9c6ce commit 69d6368

29 files changed

+176
-200
lines changed

Gemfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ gem 'kaminari', github: 'jcoyne/kaminari', branch: 'sufia'
1212
gem 'rdf-turtle', '1.1.7'
1313

1414
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
15-
gem 'rails', '~> 4.2'
15+
gem 'rails', '~> 4.2.7.1'
1616

1717
# Use mysql as the database for Active Record
1818
gem 'mysql2', '~> 0.3.2'

Gemfile.lock

+34-34
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ GEM
1717
remote: https://rubygems.org/
1818
specs:
1919
Ascii85 (1.0.2)
20-
actionmailer (4.2.5.2)
21-
actionpack (= 4.2.5.2)
22-
actionview (= 4.2.5.2)
23-
activejob (= 4.2.5.2)
20+
actionmailer (4.2.7.1)
21+
actionpack (= 4.2.7.1)
22+
actionview (= 4.2.7.1)
23+
activejob (= 4.2.7.1)
2424
mail (~> 2.5, >= 2.5.4)
2525
rails-dom-testing (~> 1.0, >= 1.0.5)
26-
actionpack (4.2.5.2)
27-
actionview (= 4.2.5.2)
28-
activesupport (= 4.2.5.2)
26+
actionpack (4.2.7.1)
27+
actionview (= 4.2.7.1)
28+
activesupport (= 4.2.7.1)
2929
rack (~> 1.6)
3030
rack-test (~> 0.6.2)
3131
rails-dom-testing (~> 1.0, >= 1.0.5)
3232
rails-html-sanitizer (~> 1.0, >= 1.0.2)
33-
actionview (4.2.5.2)
34-
activesupport (= 4.2.5.2)
33+
actionview (4.2.7.1)
34+
activesupport (= 4.2.7.1)
3535
builder (~> 3.1)
3636
erubis (~> 2.7.0)
3737
rails-dom-testing (~> 1.0, >= 1.0.5)
@@ -55,15 +55,15 @@ GEM
5555
active_fedora-noid (0.3.0)
5656
active-fedora (~> 9.0)
5757
noid (~> 0.7)
58-
activejob (4.2.5.2)
59-
activesupport (= 4.2.5.2)
58+
activejob (4.2.7.1)
59+
activesupport (= 4.2.7.1)
6060
globalid (>= 0.3.0)
61-
activemodel (4.2.5.2)
62-
activesupport (= 4.2.5.2)
61+
activemodel (4.2.7.1)
62+
activesupport (= 4.2.7.1)
6363
builder (~> 3.1)
64-
activerecord (4.2.5.2)
65-
activemodel (= 4.2.5.2)
66-
activesupport (= 4.2.5.2)
64+
activerecord (4.2.7.1)
65+
activemodel (= 4.2.7.1)
66+
activesupport (= 4.2.7.1)
6767
arel (~> 6.0)
6868
activerecord-import (0.10.0)
6969
activerecord (>= 3.0)
@@ -75,7 +75,7 @@ GEM
7575
activemodel (~> 4.0)
7676
activesupport (~> 4.0)
7777
rails-observers (~> 0.1.1)
78-
activesupport (4.2.5.2)
78+
activesupport (4.2.7.1)
7979
i18n (~> 0.7)
8080
json (~> 1.7, >= 1.7.7)
8181
minitest (~> 5.1)
@@ -220,7 +220,7 @@ GEM
220220
railties (>= 3.2, < 5.0)
221221
foreigner (1.7.4)
222222
activerecord (>= 3.0.0)
223-
globalid (0.3.6)
223+
globalid (0.3.7)
224224
activesupport (>= 4.1.0)
225225
google-api-client (0.7.1)
226226
addressable (>= 2.3.2)
@@ -346,8 +346,8 @@ GEM
346346
logger (1.2.8)
347347
loofah (2.0.3)
348348
nokogiri (>= 1.5.9)
349-
mail (2.6.3)
350-
mime-types (>= 1.16, < 3)
349+
mail (2.6.4)
350+
mime-types (>= 1.16, < 4)
351351
mail_form (1.5.1)
352352
actionmailer (>= 3.2, < 5)
353353
activemodel (>= 3.2, < 5)
@@ -360,7 +360,7 @@ GEM
360360
mimemagic (0.3.0)
361361
mini_magick (4.3.3)
362362
mini_portile2 (2.1.0)
363-
minitest (5.8.4)
363+
minitest (5.9.0)
364364
mono_logger (1.1.0)
365365
multi_json (1.11.2)
366366
multi_xml (0.5.5)
@@ -427,16 +427,16 @@ GEM
427427
rack
428428
rack-test (0.6.3)
429429
rack (>= 1.0)
430-
rails (4.2.5.2)
431-
actionmailer (= 4.2.5.2)
432-
actionpack (= 4.2.5.2)
433-
actionview (= 4.2.5.2)
434-
activejob (= 4.2.5.2)
435-
activemodel (= 4.2.5.2)
436-
activerecord (= 4.2.5.2)
437-
activesupport (= 4.2.5.2)
430+
rails (4.2.7.1)
431+
actionmailer (= 4.2.7.1)
432+
actionpack (= 4.2.7.1)
433+
actionview (= 4.2.7.1)
434+
activejob (= 4.2.7.1)
435+
activemodel (= 4.2.7.1)
436+
activerecord (= 4.2.7.1)
437+
activesupport (= 4.2.7.1)
438438
bundler (>= 1.3.0, < 2.0)
439-
railties (= 4.2.5.2)
439+
railties (= 4.2.7.1)
440440
sprockets-rails
441441
rails-deprecated_sanitizer (1.0.3)
442442
activesupport (>= 4.2.0.alpha)
@@ -450,9 +450,9 @@ GEM
450450
activemodel (~> 4.0)
451451
rails_autolink (1.1.6)
452452
rails (> 3.1)
453-
railties (4.2.5.2)
454-
actionpack (= 4.2.5.2)
455-
activesupport (= 4.2.5.2)
453+
railties (4.2.7.1)
454+
actionpack (= 4.2.7.1)
455+
activesupport (= 4.2.7.1)
456456
rake (>= 0.8.7)
457457
thor (>= 0.18.1, < 2.0)
458458
rake (10.5.0)
@@ -748,7 +748,7 @@ DEPENDENCIES
748748
pry
749749
pry-byebug
750750
pry-remote
751-
rails (~> 4.2)
751+
rails (~> 4.2.7.1)
752752
rdf-turtle (= 1.1.7)
753753
rest-client
754754
rsolr (~> 1.0.6)

app/assets/javascripts/modules/homepage.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ function create_repository_chart() {
99
// hardcoded, out-of-data but reasonable data to use
1010
// if something goes wrong in fetching the real time stats
1111
initialize_chart({
12-
'total_count': '36,675',
12+
'total_count': '40,463',
1313
'facets': [
14-
{indexLabel: "Report", y: 9136},
15-
{indexLabel: "Image", y: 5416},
16-
{indexLabel: "Thesis", y: 17276},
17-
{indexLabel: "Journal Article (Published)", y: 1706},
18-
{indexLabel: "Other", y: 1839}
14+
{indexLabel: "Report", y: 10078},
15+
{indexLabel: "Image", y: 5780},
16+
{indexLabel: "Thesis", y: 18999},
17+
{indexLabel: "Journal Article (Published)", y: 2303},
18+
{indexLabel: "Other", y: 2314}
1919
]
2020
});
2121
});

app/controllers/application_controller.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ def gc_stats
5050

5151
def after_sign_in_path_for(resource)
5252
if current_user.admin?
53-
stored_location_for(resource) || root_path
53+
stored_location_for(resource) || sufia.dashboard_files_path || root_path
5454
else
55-
stored_location_for(resource) || sufia.dashboard_index_path || root_path
55+
stored_location_for(resource) || sufia.dashboard_files_path || root_path
5656
end
5757
end
5858

app/controllers/catalog_controller.rb

+3-6
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ class CatalogController < ApplicationController
55
include Hydra::Catalog
66
# Extend Blacklight::Catalog with Hydra behaviors (primarily editing).
77
include Sufia::Catalog
8-
include Hydranorth::Collections::AdminNestingTargets
98

109
# These before_filters apply the hydra access controls
1110
before_filter :enforce_show_permissions, only: :show
@@ -15,11 +14,6 @@ class CatalogController < ApplicationController
1514

1615
skip_before_filter :default_html_head
1716

18-
def index
19-
@target_collections = admin_target_collections
20-
super
21-
end
22-
2317
def self.uploaded_field
2418
solr_name('date_uploaded', :stored_sortable, type: :date)
2519
end
@@ -156,6 +150,9 @@ def set_solr_search_fields
156150
config.add_show_field solr_name("fedora3uuid", :stored_searchable), label: "UUID"
157151

158152
config.add_sort_field "score desc, #{uploaded_field} desc", label: "Relevance \u25BC"
153+
# TODO: uncomment once a re-index is complete and sortable_title is in Solr
154+
#config.add_sort_field "sortable_title_ssi asc", label: "Title A-Z"
155+
#config.add_sort_field "sortable_title_ssi desc", label: "Title Z-A"
159156
config.add_sort_field "#{date_created_field} desc", label: "Date (newest first)"
160157
config.add_sort_field "#{date_created_field} asc", label: "Date (oldest first)"
161158
config.add_sort_field "#{uploaded_field} desc", label: "New items"

app/controllers/concerns/hydranorth/batch_controller_behavior.rb

+4-6
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,10 @@ module BatchControllerBehavior
33
extend ActiveSupport::Concern
44
include Sufia::BatchControllerBehavior
55
include Hydra::Catalog
6-
include Hydranorth::Collections::SelectsCollections
6+
include Hydranorth::Collections::CollectionSelection
7+
include Hydranorth::Collections::CommunitySelection
78

89
included do
9-
before_action only: [:edit] do
10-
find_communities_with_edit_access
11-
find_collections_with_edit_access
12-
end
13-
1410
class_attribute :edit_form_class, :cstr_edit_form_class, :ser_edit_form_class
1511
self.edit_form_class = Hydranorth::Forms::BatchEditForm
1612
self.cstr_edit_form_class = Hydranorth::Forms::CstrBatchEditForm
@@ -19,6 +15,8 @@ module BatchControllerBehavior
1915

2016
def edit
2117
@batch = Batch.find_or_create(params[:id])
18+
@user_communities = find_communities(access_levels[:edit])
19+
@user_collections = find_collections(access_levels[:edit])
2220
@form = edit_form
2321
@form[:resource_type] = @batch.generic_files.map(&:resource_type).flatten
2422
end

app/controllers/concerns/hydranorth/batch_edits_controller_behavior.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def redirect_to_return_controller
88
if params[:return_controller]
99
redirect_to url_for(controller: params[:return_controller], only_path: true)
1010
else
11-
redirect_to sufia.dashboard_index_path
11+
redirect_to sufia.dashboard_files_path
1212
end
1313
end
1414

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module Hydranorth::Collections::AdminCollectionSelection
2+
extend ActiveSupport::Concern
3+
include Hydranorth::Collections::BaseQuery
4+
5+
def admin_target_collections
6+
return [] unless current_user && current_user.admin?
7+
perform_collection_query('', nil)
8+
end
9+
end

app/controllers/concerns/hydranorth/collections/admin_nesting_targets.rb

-10
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
module Hydranorth::Collections::BaseQuery
2+
extend ActiveSupport::Concern
3+
include Blacklight::Catalog
4+
include Hydra::Collections::SelectsCollections
5+
include Hydranorth::Permissions
6+
7+
def collections_search_builder_class
8+
::CollectionSearchBuilder
9+
end
10+
11+
def access_levels
12+
{ read: [:read, :edit], edit: [:edit] }
13+
end
14+
15+
def perform_collection_query(query_string, access_level)
16+
authenticate_user! unless access_level.blank?
17+
18+
# run the solr query to find the collections
19+
query = collections_search_builder(access_level).with({q: query_string}).query
20+
response = repository.search(query)
21+
# return the user's collections (or public collections if no access_level is applied)
22+
23+
response.documents
24+
end
25+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
module Hydranorth::Collections::CollectionSelection
2+
extend ActiveSupport::Concern
3+
include Hydranorth::Collections::BaseQuery
4+
5+
def find_collections(access_level = nil)
6+
perform_collection_query("(-#{Solrizer.solr_name('is_community', :stored_searchable, type: :boolean)}:true AND -#{Solrizer.solr_name('is_community')}:true) AND (#{Solrizer.solr_name('is_official', :stored_searchable, type: :boolean)}:true OR #{Solrizer.solr_name('is_official')}:true)", access_level)
7+
end
8+
9+
def find_collections_grouped_by_community(access_level = nil)
10+
collections = find_collections(access_level)
11+
# filter out collections in a community that are nested in a collection
12+
collections.reject! {|c| c[Solrizer.solr_name('hasCollection')].present? || c[Solrizer.solr_name('hasCollectionId')].present?}
13+
grouped_user_collections = collections.group_by { |c| c[Solrizer.solr_name('belongsToCommunity')] }
14+
15+
return collections, grouped_user_collections
16+
end
17+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module Hydranorth::Collections::CommunitySelection
2+
extend ActiveSupport::Concern
3+
include Hydranorth::Collections::BaseQuery
4+
5+
def find_communities(access_level = nil)
6+
if access_level.blank?
7+
perform_collection_query("(#{Solrizer.solr_name('is_community', :stored_searchable, type: :boolean)}:true OR #{Solrizer.solr_name('is_community')}:true) AND (#{Solrizer.solr_name('is_official', :stored_searchable, type: :boolean)}:true OR #{Solrizer.solr_name('is_official')}:true)", access_level)
8+
else
9+
perform_collection_query("(#{Solrizer.solr_name('is_community', :stored_searchable, type: :boolean)}:true OR #{Solrizer.solr_name('is_community')}:true) AND (#{Solrizer.solr_name('is_official', :stored_searchable, type: :boolean)}:true OR #{Solrizer.solr_name('is_official')}:true) AND #{Solrizer.solr_name('is_admin_set', :stored_searchable, type: :boolean)}:false", access_level)
10+
end
11+
end
12+
13+
# Sorting by title implemented in hydra-collections v7.0.0 [projecthydra/hydra-collections@e8e57e5] this is a workaround
14+
def collections_for_community(community_id, access_level = nil)
15+
perform_collection_query("#{Solrizer.solr_name('belongsToCommunity')}:#{community_id}", access_level)
16+
end
17+
18+
end

0 commit comments

Comments
 (0)