diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index f9d22171..70eee92b 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,8 +5,6 @@ # class ApplicationController < ActionController::Base - MAX_START = 10000 - protect_from_forgery with: :exception helper_method :current_user, :current_user_is_sysadmin?, :logged_in?, :request_context, :to_do_list @@ -217,6 +215,10 @@ def ensure_logged_out redirect_to root_path if logged_in? end + def max_start + 10000 - window_size + end + def rescue_gone respond_to do |format| format.html { render "errors/error410", status: :gone } diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb index 9c653daf..dd18a7e3 100644 --- a/app/controllers/collections_controller.rb +++ b/app/controllers/collections_controller.rb @@ -250,7 +250,7 @@ def index end @permitted_params = params.permit(Search::RESULTS_PARAMS + Search::SIMPLE_SEARCH_PARAMS) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @collections = Collection.search. institution(current_institution). @@ -432,7 +432,7 @@ def show_statistics # def show_submissions_in_progress @permitted_params = params.permit(Search::RESULTS_PARAMS) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @items = submissions_in_progress(@start, @window) @count = @items.count @@ -652,7 +652,7 @@ def redirect_scope def set_item_results_ivars @permitted_params = params.permit(RESULTS_PARAMS + [:collection_id]) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @items = Item.search. institution(@collection.institution). diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 15c9e6b7..a8bf4b64 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb @@ -63,7 +63,7 @@ def setup_index(institution = nil) @permitted_params = params.permit(Search::RESULTS_PARAMS + Search::SIMPLE_SEARCH_PARAMS + [:status_text, :status]) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @events = Event. where.not(event_type: Event::Type::DOWNLOAD). diff --git a/app/controllers/imports_controller.rb b/app/controllers/imports_controller.rb index 5fbd146f..f27c16b1 100644 --- a/app/controllers/imports_controller.rb +++ b/app/controllers/imports_controller.rb @@ -91,7 +91,7 @@ def index authorize Import @permitted_params = params.permit(Search::RESULTS_PARAMS + Search::SIMPLE_SEARCH_PARAMS) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @imports = Import. where(institution: current_institution). diff --git a/app/controllers/index_pages_controller.rb b/app/controllers/index_pages_controller.rb index ccc44c43..a4808466 100644 --- a/app/controllers/index_pages_controller.rb +++ b/app/controllers/index_pages_controller.rb @@ -92,7 +92,7 @@ def new # def show @permitted_params = params.permit(:letter, :q, :start) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = 50 reg_e_ids = @index_page.registered_element_ids if reg_e_ids.any? diff --git a/app/controllers/institutions_controller.rb b/app/controllers/institutions_controller.rb index cb4dfb5f..b4eacf88 100644 --- a/app/controllers/institutions_controller.rb +++ b/app/controllers/institutions_controller.rb @@ -387,7 +387,7 @@ def show_authentication # def show_buried_items @permitted_params = params.permit(RESULTS_PARAMS) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @items = buried_items(@start, @window) @count = @items.count @@ -446,7 +446,7 @@ def show_imports authorize Import @permitted_params = params.permit(Search::RESULTS_PARAMS + Search::SIMPLE_SEARCH_PARAMS) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @imports = Import. where(institution: @institution). @@ -476,7 +476,7 @@ def show_invitees @permitted_params = params.permit(Search::RESULTS_PARAMS + Search::SIMPLE_SEARCH_PARAMS + [:approval_state, :institution_id]) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @invitees = Invitee. where(institution: @institution). @@ -583,7 +583,7 @@ def show_submission_profiles # def show_submissions_in_progress @permitted_params = params.permit(Search::RESULTS_PARAMS) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @items = submissions_in_progress(@start, @window) @count = @items.count @@ -665,7 +665,7 @@ def show_vocabularies @permitted_params = params.permit(Search::RESULTS_PARAMS + Search::SIMPLE_SEARCH_PARAMS + [:institution_id]) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @vocabularies = Vocabulary. where(institution: @institution). @@ -683,7 +683,7 @@ def show_vocabularies # def show_withdrawn_items @permitted_params = params.permit(RESULTS_PARAMS) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @items = withdrawn_items(@start, @window) @count = @items.count diff --git a/app/controllers/invitees_controller.rb b/app/controllers/invitees_controller.rb index 48e34551..ac1eb6c3 100644 --- a/app/controllers/invitees_controller.rb +++ b/app/controllers/invitees_controller.rb @@ -234,7 +234,7 @@ def setup_index(institution) @permitted_params = params.permit(Search::RESULTS_PARAMS + Search::SIMPLE_SEARCH_PARAMS + [:approval_state, :institution_id]) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @invitees = Invitee. where("LOWER(email) LIKE ?", "%#{@permitted_params[:q]&.downcase}%"). diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index 16c099cf..b48e1eda 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -294,7 +294,7 @@ def process_review # def recent @permitted_params = params.permit(:start) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @items = Item.search. institution(current_institution). @@ -327,7 +327,7 @@ def reject def review authorize Item @permitted_params = params.permit(Search::RESULTS_PARAMS) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @items = Item.search. institution(current_institution). diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 76b16170..d56d4fbb 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -13,7 +13,7 @@ class MessagesController < ApplicationController # def index @permitted_params = results_params - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @messages = Message.all.order(updated_at: :desc) if @permitted_params[:key].present? diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index fd438a63..342b86d5 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -16,7 +16,7 @@ def index @permitted_params = params.permit(Search::SIMPLE_SEARCH_PARAMS + Search::advanced_search_params + Search::RESULTS_PARAMS) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @items = EntityRelation.new. aggregations(true). diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb index 799696c6..1d6a3700 100644 --- a/app/controllers/tasks_controller.rb +++ b/app/controllers/tasks_controller.rb @@ -66,7 +66,7 @@ def setup_index(institution = nil) @permitted_params = params.permit(Search::RESULTS_PARAMS + Search::SIMPLE_SEARCH_PARAMS + [:institution_id, :queue, :status, :status_text]) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @tasks = Task.all.order(created_at: :desc) if institution diff --git a/app/controllers/units_controller.rb b/app/controllers/units_controller.rb index 92c2aad5..7fab0543 100644 --- a/app/controllers/units_controller.rb +++ b/app/controllers/units_controller.rb @@ -399,7 +399,7 @@ def show_statistics # def show_submissions_in_progress @permitted_params = params.permit(Search::RESULTS_PARAMS) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @items = submissions_in_progress(@start, @window) @count = @items.count @@ -565,7 +565,7 @@ def review_items(start, limit) def set_item_results_ivars @permitted_params = params.permit(RESULTS_PARAMS + [:unit_id]) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @items = Item.search. institution(@unit.institution). diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index a3bdcd95..ced2a49a 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -195,7 +195,7 @@ def set_submissions_in_progress_ivars end def set_submittable_collections_ivars(apply_window: true) - @start = [params[:collections_start].to_i.abs, MAX_START].min + @start = [params[:collections_start].to_i.abs, max_start].min @window = window_size @permitted_params = params.permit(:collections_start, :items_start, :window) @submittable_collections = @user.effective_institution_admin?(@user.institution, @@ -218,7 +218,7 @@ def set_submittable_collections_ivars(apply_window: true) def set_submitted_items_ivars @permitted_params = params.permit(:direction, :q, :sort, :start) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @items = Item.search. institution(current_institution). @@ -256,7 +256,7 @@ def setup_index(institution) @permitted_params = params.permit(Search::RESULTS_PARAMS + Search::SIMPLE_SEARCH_PARAMS + [:institution_id]) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size q = "%#{@permitted_params[:q]&.downcase}%" @users = User. diff --git a/app/controllers/vocabularies_controller.rb b/app/controllers/vocabularies_controller.rb index 0ecf1bac..19481bfe 100644 --- a/app/controllers/vocabularies_controller.rb +++ b/app/controllers/vocabularies_controller.rb @@ -63,7 +63,7 @@ def index @permitted_params = params.permit(Search::RESULTS_PARAMS + Search::SIMPLE_SEARCH_PARAMS + [:institution_id]) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size @vocabularies = Vocabulary. where(institution: current_institution). @@ -96,7 +96,7 @@ def new def show @permitted_params = params.permit(Search::RESULTS_PARAMS + Search::SIMPLE_SEARCH_PARAMS) - @start = [@permitted_params[:start].to_i.abs, MAX_START].min + @start = [@permitted_params[:start].to_i.abs, max_start].min @window = window_size q = "%#{@permitted_params[:q]&.downcase}%" @terms = @vocabulary.vocabulary_terms.