sufia 4.0.0.beta3 → 4.0.0.beta4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/SUFIA_VERSION +1 -1
- data/app/assets/javascripts/sufia/search.js +4 -6
- data/app/assets/stylesheets/dashboard.css.scss +26 -0
- data/app/assets/stylesheets/header.css.scss +21 -12
- data/app/controllers/batch_controller.rb +0 -1
- data/app/controllers/collections_controller.rb +0 -1
- data/app/controllers/concerns/sufia/catalog.rb +0 -9
- data/app/controllers/concerns/sufia/controller.rb +4 -0
- data/app/controllers/concerns/sufia/dashboard_controller_behavior.rb +24 -74
- data/app/controllers/concerns/sufia/downloads_controller_behavior.rb +0 -3
- data/app/controllers/concerns/sufia/files_controller_behavior.rb +4 -13
- data/app/controllers/concerns/sufia/my_controller_behavior.rb +87 -0
- data/app/controllers/{dashboard → my}/collections_controller.rb +3 -2
- data/app/controllers/{dashboard → my}/files_controller.rb +3 -2
- data/app/controllers/{dashboard → my}/highlights_controller.rb +3 -2
- data/app/controllers/{dashboard → my}/shares_controller.rb +3 -2
- data/app/controllers/my_controller.rb +3 -0
- data/app/controllers/single_use_links_controller.rb +0 -2
- data/app/helpers/dashboard_helper.rb +3 -0
- data/app/helpers/generic_file_helper.rb +4 -4
- data/app/helpers/sufia/dashboard_helper_behavior.rb +25 -0
- data/app/helpers/sufia/sufia_helper_behavior.rb +44 -0
- data/app/jobs/content_delete_event_job.rb +2 -2
- data/app/models/concerns/sufia/solr_document_behavior.rb +5 -0
- data/app/views/_user_util_links.html.erb +5 -5
- data/app/views/catalog/_results_pagination.html.erb +1 -1
- data/app/views/catalog/_search_form.html.erb +56 -28
- data/app/views/collections/_dashboard_document_list.html.erb +1 -1
- data/app/views/collections/_document_list.html.erb +1 -1
- data/app/views/collections/edit.html.erb +8 -11
- data/app/views/collections/show.html.erb +2 -2
- data/app/views/collections/show_fields/_creator.html.erb +11 -0
- data/app/views/collections/show_fields/_description.html.erb +8 -0
- data/app/views/collections/show_fields/_title.html.erb +8 -0
- data/app/views/dashboard/_index_partials/_stats.html.erb +16 -0
- data/app/views/dashboard/_index_partials/_user_info.html.erb +18 -0
- data/app/views/dashboard/index.html.erb +51 -19
- data/app/views/generic_files/_show_descriptions.html.erb +11 -10
- data/app/views/generic_files/show.html.erb +1 -1
- data/app/views/generic_files/show_fields/_based_near.html.erb +7 -0
- data/app/views/generic_files/show_fields/_contributor.html.erb +7 -0
- data/app/views/generic_files/show_fields/_creator.html.erb +7 -0
- data/app/views/generic_files/show_fields/_date_created.html.erb +7 -0
- data/app/views/generic_files/show_fields/_default.html.erb +6 -12
- data/app/views/generic_files/show_fields/_description.html.erb +7 -0
- data/app/views/generic_files/show_fields/_identifier.html.erb +4 -0
- data/app/views/generic_files/show_fields/_language.html.erb +4 -0
- data/app/views/generic_files/show_fields/_publisher.html.erb +7 -0
- data/app/views/generic_files/show_fields/_related_url.html.erb +6 -0
- data/app/views/generic_files/show_fields/_resource_type.html.erb +4 -0
- data/app/views/generic_files/show_fields/_rights.html.erb +4 -0
- data/app/views/generic_files/show_fields/_subject.html.erb +7 -0
- data/app/views/generic_files/show_fields/_tag.html.erb +4 -0
- data/app/views/generic_files/show_fields/_title.html.erb +7 -0
- data/app/views/generic_files/upload/_form_fields.html.erb +4 -5
- data/app/views/generic_files/upload/_script_templates.html.erb +1 -2
- data/app/views/layouts/sufia-dashboard.html.erb +16 -30
- data/app/views/mailbox/_notifications.html.erb +21 -0
- data/app/views/mailbox/index.html.erb +2 -23
- data/app/views/{dashboard → my}/_action_menu.html.erb +0 -0
- data/app/views/{dashboard → my}/_batch_edits_actions.html.erb +0 -0
- data/app/views/{dashboard → my}/_collection_action_menu.html.erb +0 -0
- data/app/views/{dashboard → my}/_did_you_mean.html.erb +0 -0
- data/app/views/my/_document_list.html.erb +4 -0
- data/app/views/{dashboard → my}/_facet_layout.html.erb +0 -0
- data/app/views/{dashboard → my}/_facet_limit.html.erb +0 -0
- data/app/views/{dashboard → my}/_facet_pagination.html.erb +0 -0
- data/app/views/{dashboard → my}/_facet_selected.html.erb +0 -0
- data/app/views/{dashboard → my}/_facets.html.erb +0 -0
- data/app/views/{dashboard → my}/_index_partials/_default_group.html.erb +2 -2
- data/app/views/{dashboard → my}/_index_partials/_list_collections.html.erb +0 -0
- data/app/views/{dashboard → my}/_index_partials/_list_files.html.erb +0 -0
- data/app/views/{dashboard → my}/_results_pagination.html.erb +0 -0
- data/app/views/my/_scripts.js.erb +11 -0
- data/app/views/{dashboard → my}/_sort_and_per_page.html.erb +0 -0
- data/app/views/{dashboard → my}/facet.html.erb +0 -0
- data/app/views/{dashboard/lists → my}/index.html.erb +4 -20
- data/app/views/users/_user_info.html.erb +1 -1
- data/config/initializers/sufia_events.rb +19 -2
- data/config/locales/sufia.en.yml +27 -2
- data/config/routes.rb +7 -11
- data/lib/generators/sufia/sufia_generator.rb +15 -0
- data/lib/generators/sufia/templates/catalog_controller.rb +14 -14
- data/lib/sufia.rb +1 -0
- data/lib/sufia/version.rb +1 -1
- data/spec/controllers/catalog_controller_spec.rb +7 -16
- data/spec/controllers/dashboard_controller_spec.rb +63 -30
- data/spec/controllers/generic_files_controller_spec.rb +1 -1
- data/spec/controllers/{dashboard → my}/collections_controller_spec.rb +1 -15
- data/spec/controllers/my/files_controller_spec.rb +68 -0
- data/spec/controllers/{dashboard → my}/highlights_controller_spec.rb +1 -15
- data/spec/controllers/{dashboard → my}/shares_controller_spec.rb +1 -15
- data/spec/controllers/my_controller_spec.rb +9 -0
- data/spec/features/browse_dashboard_files_spec.rb +72 -26
- data/spec/features/collection_spec.rb +2 -4
- data/spec/features/display_dashboard_spec.rb +20 -26
- data/spec/features/search_spec.rb +25 -13
- data/spec/helpers/dashboard_helper_spec.rb +41 -0
- data/spec/helpers/sufia_helper_spec.rb +104 -3
- data/spec/jobs/event_jobs_spec.rb +1 -1
- data/spec/models/generic_file/web_form_spec.rb +3 -4
- data/spec/models/generic_file_spec.rb +47 -43
- data/spec/routing/route_spec.rb +10 -14
- data/spec/views/batch_edits/check_all_spec.rb +4 -4
- data/spec/views/catalog/sort_and_per_pange.html.erb_spec.rb +27 -0
- data/spec/views/dashboard/index_spec.rb +105 -0
- data/spec/views/{dashboard → my}/facet_limit.html.erb_spec.rb +2 -2
- data/sufia-models/app/actors/sufia/generic_file/actor.rb +23 -3
- data/sufia-models/app/models/concerns/sufia/generic_file.rb +0 -5
- data/sufia-models/app/models/concerns/sufia/generic_file/metadata.rb +9 -2
- data/sufia-models/app/models/concerns/sufia/generic_file/web_form.rb +2 -2
- data/sufia-models/app/models/datastreams/generic_file_rdf_datastream.rb +1 -1
- data/sufia-models/app/services/sufia/noid.rb +21 -16
- data/sufia-models/lib/generators/sufia/models/install_generator.rb +2 -16
- data/sufia-models/lib/generators/sufia/models/templates/config/sufia.rb +23 -0
- data/sufia-models/lib/sufia/models/version.rb +1 -1
- data/sufia-models/sufia-models.gemspec +1 -1
- data/vendor/assets/javascripts/fileupload/jquery.fileupload-ui.js +18 -10
- metadata +68 -45
- data/app/assets/images/glyphicons-halflings-white.png +0 -0
- data/app/assets/images/glyphicons-halflings.png +0 -0
- data/app/controllers/dashboard/lists_controller.rb +0 -13
- data/app/views/dashboard/_constraints.html.erb +0 -6
- data/app/views/dashboard/_document_list.html.erb +0 -4
- data/app/views/dashboard/_heading.html.erb +0 -1
- data/app/views/dashboard/_search_form.html.erb +0 -14
- data/app/views/dashboard/_show_partials/_default.html.erb +0 -20
- data/app/views/dashboard/_show_partials/_default_details.html.erb +0 -15
- data/app/views/dashboard/_show_partials/_facets.html.erb +0 -87
- data/app/views/generic_files/_field_display.html.erb +0 -12
- data/spec/controllers/dashboard/files_controller_spec.rb +0 -71
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8143524ee97650ca264d7daf37e8daf09d3cb7d
|
4
|
+
data.tar.gz: b4714ff53d0ea22cb0f73df735e3133072daca9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aca36c15faed0587db40c7f4b528033b971d3083c14846eda85e1fd45478dd58daef919d688d322ba10eb3d3c9483f4dde6bbb3054010bf22027197525f75fd1
|
7
|
+
data.tar.gz: 7a76f154841c3cc1b464f9723bd12370a4836ef4ad7c297eae1c73156a84c23193a5299096f437abf90644afa9883abe80bcaf82995928d8e82221e2a637ee61
|
data/README.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# Sufia [![Version](https://badge.fury.io/rb/sufia.png)](http://badge.fury.io/rb/sufia) [![Build Status](https://travis-ci.org/projecthydra/sufia.png?branch=master)](https://travis-ci.org/projecthydra/sufia) [![Dependency Status](https://gemnasium.com/projecthydra/sufia.png)](https://gemnasium.com/projecthydra/sufia)
|
2
2
|
|
3
|
+
# Please Note!
|
4
|
+
Sufia is currently in transition to a new 4.0 release scheduled for late summer 2014. If wish to use Sufia now,
|
5
|
+
please ensure you using version 3.7.2, available from RubyGems.org. For documentation specific to this version,
|
6
|
+
please consult the [Sufia 3.7.2 documentation](http://rubydoc.info/gems/sufia/3.7.2/frames).
|
7
|
+
|
8
|
+
If you have questions or need help, please email `hydra-tech@googlegroups.com`
|
9
|
+
|
3
10
|
## What is Sufia?
|
4
11
|
Sufia is a component that adds self-deposit institutional repository features to a Rails app.
|
5
12
|
Sufia is created with Ruby on Rails and builds on the Hydra Framework.
|
data/SUFIA_VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
4.0.0.
|
1
|
+
4.0.0.beta4
|
@@ -5,7 +5,6 @@
|
|
5
5
|
this.init = function() {
|
6
6
|
this.$label = this.$element.find('[data-search-element="label"]');
|
7
7
|
this.$items = this.$element.find('[data-search-option]');
|
8
|
-
this.$hidden = this.$element.find('input#owner[type="hidden"]');
|
9
8
|
this.setDefault();
|
10
9
|
}
|
11
10
|
|
@@ -26,12 +25,11 @@
|
|
26
25
|
|
27
26
|
clicked: function($anchor) {
|
28
27
|
this.setLabel($anchor.data('search-label'));
|
29
|
-
this
|
28
|
+
this.setFormAction($anchor.data('search-option'));
|
30
29
|
},
|
31
30
|
|
32
|
-
|
33
|
-
|
34
|
-
return this.$hidden.val();
|
31
|
+
setFormAction: function(path) {
|
32
|
+
this.$element.attr('action', path);
|
35
33
|
},
|
36
34
|
|
37
35
|
getLabelForValue: function(value) {
|
@@ -40,7 +38,7 @@
|
|
40
38
|
},
|
41
39
|
|
42
40
|
setDefault: function() {
|
43
|
-
this.setLabel(this.getLabelForValue(this.
|
41
|
+
this.setLabel(this.getLabelForValue(this.$element.attr('action')));
|
44
42
|
},
|
45
43
|
|
46
44
|
setLabel: function(label) {
|
@@ -91,6 +91,32 @@ $gray-lighter: #eee;
|
|
91
91
|
text-decoration: none;
|
92
92
|
}
|
93
93
|
|
94
|
+
.portal {
|
95
|
+
border: 1px solid $gray-lightish;
|
96
|
+
margin: 5px;
|
97
|
+
padding: 5px;
|
98
|
+
h3 {
|
99
|
+
margin-top: 10px;
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
.heading-tile {
|
104
|
+
border-right: 1px solid $gray-lightish;
|
105
|
+
margin-top: 10px;
|
106
|
+
margin-bottom: 10px;
|
107
|
+
text-align: center;
|
108
|
+
font-size: x-large;
|
109
|
+
font-weight: normal;
|
110
|
+
span {
|
111
|
+
display: block;
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
.heading-row {
|
116
|
+
border-bottom: 1px solid $gray-lightish;
|
117
|
+
//margin-left: 10px;
|
118
|
+
}
|
119
|
+
|
94
120
|
#collection-list-container {
|
95
121
|
.collection-list {
|
96
122
|
li {
|
@@ -17,6 +17,24 @@ $gray-lighter: #eee;
|
|
17
17
|
background-image: linear-gradient(to bottom, #0071BC 0%, #003457 100%);
|
18
18
|
min-height: 4em;
|
19
19
|
|
20
|
+
#logo span.glyphicon {
|
21
|
+
color: #FFF;
|
22
|
+
font-size: 4em;
|
23
|
+
margin: .25em 0 0 .25em;
|
24
|
+
}
|
25
|
+
|
26
|
+
.institution_name {
|
27
|
+
font-family: 'Lato', Verdana, Arial, Helvetica;
|
28
|
+
font-size: 4em;
|
29
|
+
font-weight: 300;
|
30
|
+
margin: 0 0 0 .25em;
|
31
|
+
}
|
32
|
+
|
33
|
+
.institution_name, .institution_name a:link, .institution_name a:visited {
|
34
|
+
color: #FFF;
|
35
|
+
text-decoration: none;
|
36
|
+
}
|
37
|
+
|
20
38
|
.navbar {
|
21
39
|
min-height: 0px;
|
22
40
|
margin-bottom: 0.8em;
|
@@ -71,18 +89,6 @@ $gray-lighter: #eee;
|
|
71
89
|
}
|
72
90
|
}
|
73
91
|
|
74
|
-
#logo span.glyphicon {
|
75
|
-
color: #FFF;
|
76
|
-
font-size: 4em;
|
77
|
-
margin: .25em 0 0 .25em;
|
78
|
-
}
|
79
|
-
.institution_name {
|
80
|
-
color: #FFF;
|
81
|
-
font-family: 'Lato', Verdana, Arial, Helvetica;
|
82
|
-
font-size: 4em;
|
83
|
-
font-weight: 300;
|
84
|
-
margin: 0 0 0 .25em;
|
85
|
-
}
|
86
92
|
|
87
93
|
.login_button {
|
88
94
|
margin: 1.75em 3em 0 0;
|
@@ -90,4 +96,7 @@ $gray-lighter: #eee;
|
|
90
96
|
|
91
97
|
#search-form-header {
|
92
98
|
margin-top: 7px;
|
99
|
+
}
|
100
|
+
#search-submit-header {
|
101
|
+
margin-left: -15px;
|
93
102
|
}
|
@@ -4,7 +4,6 @@ class CollectionsController < ApplicationController
|
|
4
4
|
include Blacklight::Catalog::SearchContext
|
5
5
|
include BlacklightAdvancedSearch::ParseBasicQ
|
6
6
|
include BlacklightAdvancedSearch::Controller
|
7
|
-
include Sufia::Noid # for normalize_identifier method
|
8
7
|
prepend_before_filter :normalize_identifier, except: [:index, :create, :new]
|
9
8
|
before_filter :filter_docs_with_read_access!, except: :show
|
10
9
|
before_filter :has_access?, except: :show
|
@@ -15,14 +15,5 @@ module Sufia
|
|
15
15
|
solr_parameters[:fq] << "#{Solrizer.solr_name("has_model", :symbol)}:\"info:fedora/afmodel:GenericFile\""
|
16
16
|
end
|
17
17
|
|
18
|
-
# If they've selected "owner=mine" then restrict to files I have edit access to
|
19
|
-
def discovery_permissions
|
20
|
-
if params['owner'] == 'mine'
|
21
|
-
["edit"]
|
22
|
-
else
|
23
|
-
super
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
18
|
end
|
28
19
|
end
|
@@ -12,6 +12,10 @@ module Sufia::Controller
|
|
12
12
|
user_signed_in? ? current_user.ability : super
|
13
13
|
end
|
14
14
|
|
15
|
+
def normalize_identifier
|
16
|
+
params[:id] = Sufia::Noid.namespaceize(params[:id])
|
17
|
+
end
|
18
|
+
|
15
19
|
def render_404(exception)
|
16
20
|
logger.error("Rendering 404 page due to exception: #{exception.inspect} - #{exception.backtrace if exception.respond_to? :backtrace}")
|
17
21
|
render template: '/error/404', layout: "error", formats: [:html], status: 404
|
@@ -1,103 +1,53 @@
|
|
1
|
-
require 'blacklight/catalog'
|
2
|
-
|
3
1
|
module Sufia
|
4
2
|
module DashboardControllerBehavior
|
5
3
|
extend ActiveSupport::Concern
|
6
|
-
|
7
|
-
include Blacklight::Catalog
|
8
|
-
|
9
|
-
include Hydra::Collections::SelectsCollections
|
10
|
-
|
4
|
+
|
11
5
|
included do
|
12
|
-
include Blacklight::Configurable
|
13
6
|
include ActionView::Helpers::DateHelper
|
14
7
|
|
15
|
-
self.copy_blacklight_config_from(CatalogController)
|
16
|
-
|
17
|
-
include BlacklightAdvancedSearch::ParseBasicQ
|
18
|
-
include BlacklightAdvancedSearch::Controller
|
19
|
-
|
20
8
|
before_filter :authenticate_user!
|
21
|
-
before_filter :enforce_show_permissions, only: :show
|
22
|
-
before_filter :enforce_viewing_context_for_show_requests, only: :show
|
23
|
-
|
24
|
-
# not filtering further with a specific access level since the catalog controller already gets the colections with edit access
|
25
|
-
# if we include other access levels in this controller we will need to modify this.
|
26
|
-
before_filter :find_collections, only: :index
|
27
9
|
|
28
|
-
|
29
|
-
self.solr_search_params_logic += [:add_access_controls_to_solr_params]
|
30
|
-
|
31
|
-
layout 'sufia-dashboard'
|
10
|
+
layout "sufia-dashboard"
|
32
11
|
end
|
33
12
|
|
13
|
+
# Render our dashboard page
|
34
14
|
def index
|
35
|
-
|
36
|
-
@user = current_user
|
37
|
-
@events = @user.events(100)
|
38
|
-
@last_event_timestamp = @user.events.first[:timestamp].to_i || 0 rescue 0
|
39
|
-
@filters = params[:f] || []
|
40
|
-
|
15
|
+
gather_dashboard_information
|
41
16
|
respond_to do |format|
|
42
17
|
format.html { }
|
43
18
|
format.rss { render layout: false }
|
44
19
|
format.atom { render layout: false }
|
45
20
|
end
|
46
|
-
|
47
|
-
# set up some parameters for allowing the batch controls to show appropiately
|
48
|
-
@max_batch_size = 80
|
49
|
-
count_on_page = @document_list.count {|doc| batch.index(doc.id)}
|
50
|
-
@disable_select_all = @document_list.count > @max_batch_size
|
51
|
-
batch_size = batch.uniq.size
|
52
|
-
@result_set_size = @response.response["numFound"]
|
53
|
-
@empty_batch = batch.empty?
|
54
|
-
@all_checked = (count_on_page == @document_list.count)
|
55
|
-
@entire_result_set_selected = @response.response["numFound"] == batch_size
|
56
|
-
@batch_size_on_other_page = batch_size - count_on_page
|
57
|
-
@batch_part_on_other_page = (@batch_size_on_other_page) > 0
|
58
21
|
end
|
59
22
|
|
23
|
+
# Returns a formated list of recent events in JSON for use with AJAX.
|
60
24
|
def activity
|
61
|
-
|
62
|
-
events = current_user.events.reverse
|
63
|
-
# filter events to include only those that have occurred since params[:since]
|
64
|
-
events.select! { |event| event[:timestamp].to_i > params[:since].to_i } if params[:since]
|
65
|
-
# return the event, a formatted date string, and a numerical timestamp
|
66
|
-
render json: events.map { |event| [event[:action], "#{time_ago_in_words(Time.at(event[:timestamp].to_i))} ago", event[:timestamp].to_i] }
|
67
|
-
rescue
|
68
|
-
render json: []
|
69
|
-
end
|
70
|
-
|
71
|
-
# TODO: This can be removed after we upgrade to hydra-collections 2.0.1 or greater
|
72
|
-
def add_collection_filter(solr_parameters, user_parameters)
|
73
|
-
super(solr_parameters, user_parameters)
|
74
|
-
solr_parameters[:rows] = 100
|
75
|
-
end
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
def search_action_url *args
|
80
|
-
sufia.dashboard_index_path *args
|
25
|
+
render json: human_readable_user_activity
|
81
26
|
end
|
82
27
|
|
83
28
|
protected
|
84
|
-
|
85
|
-
|
86
|
-
|
29
|
+
|
30
|
+
# Gathers all the information that we'll display in the user's dashboard.
|
31
|
+
# Override this method if you want to exclude or gather additional data elements
|
32
|
+
# in your dashboard view. You'll need to alter dashboard/index.html.erb accordingly.
|
33
|
+
def gather_dashboard_information
|
34
|
+
@user = current_user
|
35
|
+
@activity = get_user_activity
|
36
|
+
@notifications = current_user.mailbox.inbox
|
87
37
|
end
|
88
38
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
]
|
39
|
+
# Returns the most recent activity in the last 24 hours, or since a given timestamp
|
40
|
+
# specified by params[:since]
|
41
|
+
def get_user_activity
|
42
|
+
since = params[:since] ? params[:since].to_i : (DateTime.now.to_i - 86400)
|
43
|
+
current_user.events.reverse.collect { |event| event if event[:timestamp].to_i > since }.compact
|
94
44
|
end
|
95
45
|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
46
|
+
# Formats the user's activities into human-readable strings used for rendering JSON
|
47
|
+
def human_readable_user_activity
|
48
|
+
get_user_activity.map do |event|
|
49
|
+
[event[:action], "#{time_ago_in_words(Time.at(event[:timestamp].to_i))} ago", event[:timestamp].to_i]
|
50
|
+
end
|
101
51
|
end
|
102
52
|
|
103
53
|
end
|
@@ -4,9 +4,6 @@ module Sufia
|
|
4
4
|
include Hydra::Controller::DownloadBehavior
|
5
5
|
|
6
6
|
included do
|
7
|
-
# module mixes in normalize_identifier method
|
8
|
-
include Sufia::Noid
|
9
|
-
|
10
7
|
# moved check into the routine so we can handle the user with no access
|
11
8
|
prepend_before_filter :normalize_identifier
|
12
9
|
end
|
@@ -12,7 +12,6 @@ module Sufia
|
|
12
12
|
included do
|
13
13
|
include Hydra::Controller::ControllerBehavior
|
14
14
|
include Blacklight::Configurable
|
15
|
-
include Sufia::Noid # for normalize_identifier method
|
16
15
|
include Sufia::FilesController::BrowseEverything
|
17
16
|
include Sufia::FilesController::LocalIngestBehavior
|
18
17
|
extend Sufia::FilesController::UploadCompleteBehavior
|
@@ -60,9 +59,7 @@ module Sufia
|
|
60
59
|
|
61
60
|
# routed to /files/:id (DELETE)
|
62
61
|
def destroy
|
63
|
-
|
64
|
-
@generic_file.destroy
|
65
|
-
Sufia.queue.push(ContentDeleteEventJob.new(pid, current_user.user_key))
|
62
|
+
actor.destroy
|
66
63
|
redirect_to self.class.destroy_complete_path(params), notice:
|
67
64
|
render_to_string(partial: 'generic_files/asset_deleted_flash', locals: { generic_file: @generic_file })
|
68
65
|
end
|
@@ -142,22 +139,16 @@ module Sufia
|
|
142
139
|
end
|
143
140
|
|
144
141
|
def update_version
|
145
|
-
|
146
|
-
Sufia.queue.push(ContentRestoredVersionEventJob.new(@generic_file.pid, current_user.user_key, params[:revision]))
|
147
|
-
end
|
142
|
+
actor.revert_content(params[:revision], datastream_id)
|
148
143
|
end
|
149
144
|
|
150
145
|
def update_file
|
151
|
-
|
152
|
-
Sufia.queue.push(ContentNewVersionEventJob.new(@generic_file.pid, current_user.user_key))
|
153
|
-
end
|
146
|
+
actor.update_content(params[:filedata], datastream_id)
|
154
147
|
end
|
155
148
|
|
156
149
|
# this is provided so that implementing application can override this behavior and map params to different attributes
|
157
150
|
def update_metadata
|
158
|
-
|
159
|
-
Sufia.queue.push(ContentUpdateEventJob.new(@generic_file.pid, current_user.user_key))
|
160
|
-
end
|
151
|
+
actor.update_metadata(params[:generic_file], params[:visibility])
|
161
152
|
end
|
162
153
|
|
163
154
|
def json_error(error, name=nil, additional_arguments={})
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require 'blacklight/catalog'
|
2
|
+
|
3
|
+
module Sufia
|
4
|
+
module MyControllerBehavior
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
include Blacklight::Catalog
|
7
|
+
include Hydra::BatchEditBehavior
|
8
|
+
include Hydra::Collections::SelectsCollections
|
9
|
+
|
10
|
+
included do
|
11
|
+
include Blacklight::Configurable
|
12
|
+
|
13
|
+
self.copy_blacklight_config_from(CatalogController)
|
14
|
+
|
15
|
+
include BlacklightAdvancedSearch::ParseBasicQ
|
16
|
+
include BlacklightAdvancedSearch::Controller
|
17
|
+
|
18
|
+
before_filter :authenticate_user!
|
19
|
+
before_filter :enforce_show_permissions, only: :show
|
20
|
+
before_filter :enforce_viewing_context_for_show_requests, only: :show
|
21
|
+
before_filter :find_collections, only: :index
|
22
|
+
|
23
|
+
# This applies appropriate access controls to all solr queries (the internal method of this is overidden bellow to only include edit files)
|
24
|
+
self.solr_search_params_logic += [:add_access_controls_to_solr_params]
|
25
|
+
|
26
|
+
layout 'sufia-dashboard'
|
27
|
+
end
|
28
|
+
|
29
|
+
# specify the controller_name here to specify where we should look for
|
30
|
+
# the batch_edit menu options (_batch_edits_actions.html.erb)
|
31
|
+
def controller_name
|
32
|
+
:my
|
33
|
+
end
|
34
|
+
|
35
|
+
def index
|
36
|
+
(@response, @document_list) = get_search_results
|
37
|
+
@user = current_user
|
38
|
+
@events = @user.events(100)
|
39
|
+
@last_event_timestamp = @user.events.first[:timestamp].to_i || 0 rescue 0
|
40
|
+
@filters = params[:f] || []
|
41
|
+
|
42
|
+
# set up some parameters for allowing the batch controls to show appropiately
|
43
|
+
@max_batch_size = 80
|
44
|
+
count_on_page = @document_list.count {|doc| batch.index(doc.id)}
|
45
|
+
@disable_select_all = @document_list.count > @max_batch_size
|
46
|
+
batch_size = batch.uniq.size
|
47
|
+
@result_set_size = @response.response["numFound"]
|
48
|
+
@empty_batch = batch.empty?
|
49
|
+
@all_checked = (count_on_page == @document_list.count)
|
50
|
+
@entire_result_set_selected = @response.response["numFound"] == batch_size
|
51
|
+
@batch_size_on_other_page = batch_size - count_on_page
|
52
|
+
@batch_part_on_other_page = (@batch_size_on_other_page) > 0
|
53
|
+
|
54
|
+
respond_to do |format|
|
55
|
+
format.html { }
|
56
|
+
format.rss { render layout: false }
|
57
|
+
format.atom { render layout: false }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def search_action_url opts={}
|
62
|
+
sufia.url_for(opts)
|
63
|
+
end
|
64
|
+
|
65
|
+
protected
|
66
|
+
|
67
|
+
# show only files with edit permissions in lib/hydra/access_controls_enforcement.rb apply_gated_discovery
|
68
|
+
def discovery_permissions
|
69
|
+
["edit"]
|
70
|
+
end
|
71
|
+
|
72
|
+
def show_only_files_deposited_by_current_user solr_parameters, user_parameters
|
73
|
+
solr_parameters[:fq] ||= []
|
74
|
+
solr_parameters[:fq] += [
|
75
|
+
ActiveFedora::SolrService.construct_query_for_rel(depositor: current_user.user_key)
|
76
|
+
]
|
77
|
+
end
|
78
|
+
|
79
|
+
def show_only_generic_files solr_parameters, user_parameters
|
80
|
+
solr_parameters[:fq] ||= []
|
81
|
+
solr_parameters[:fq] += [
|
82
|
+
ActiveFedora::SolrService.construct_query_for_rel(has_model: ::GenericFile.to_class_uri)
|
83
|
+
]
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|