Commit df3d00a7 authored by Mario Manno's avatar Mario Manno

return default page for invalid pagination requests

parent 315fd66d
......@@ -7,7 +7,7 @@ class ApplicationController < ActionController::Base
helper_method :current_user
rescue_from CanCan::AccessDenied do |ex|
Rails.logger.info "[ !!! ] Access Denied for #{current_user.email}/#{current_user.id}/#{current_user.role}: #{ex.message}"
Rails.logger.info "[ !!! ] Access Denied for #{current_user.email}/#{current_user.id}/#{current_user.role}: #{ex.message}"
begin
if current_user.is_submitter?
redirect_to cfp_root_path, :notice => t(:"ability.denied")
......@@ -21,6 +21,12 @@ class ApplicationController < ActionController::Base
protected
def page_param
page = params[:page].to_i
return page if page > 0
1
end
def set_locale
if %w{en de}.include?( params[:locale] )
I18n.locale = params[:locale]
......@@ -78,7 +84,7 @@ class ApplicationController < ActionController::Base
end
def not_submitter!
return unless current_user
return unless current_user
redirect_to cfp_root_path, alert: "This action is not allowed" if current_user.is_submitter?
end
......@@ -98,9 +104,9 @@ class ApplicationController < ActionController::Base
def check_cfp_open
if @conference.call_for_papers.nil?
redirect_to cfp_not_existing_path
redirect_to cfp_not_existing_path
elsif @conference.call_for_papers.start_date > Date.today
redirect_to cfp_open_soon_path
redirect_to cfp_open_soon_path
end
end
end
......@@ -15,7 +15,7 @@ class ConferencesController < ApplicationController
else
@search = Conference.search(params[:q])
end
@conferences = @search.result.paginate page: params[:page]
@conferences = @search.result.paginate page: page_param
respond_to do |format|
format.html # index.html.erb
......@@ -90,7 +90,7 @@ class ConferencesController < ApplicationController
def get_previous_nested_form(parameters)
parameters.keys.each { |name|
attribs = name.index("_attributes")
attribs = name.index("_attributes")
next if attribs.nil?
next unless attribs > 0
test = name.gsub("_attributes", '')
......
......@@ -3,7 +3,7 @@ class EventsController < ApplicationController
before_filter :authenticate_user!
before_filter :not_submitter!
after_filter :restrict_events
# GET /events
# GET /events.xml
def index
......@@ -13,7 +13,7 @@ class EventsController < ApplicationController
else
@search = @conference.events.includes(:track).search(params[:q])
end
@events = @search.result.paginate page: params[:page]
@events = @search.result.paginate page: page_param
clean_events_attributes
respond_to do |format|
......@@ -31,7 +31,7 @@ class EventsController < ApplicationController
@search = @conference.events.associated_with(current_user.person).search(params[:q])
end
clean_events_attributes
@events = @search.result.paginate page: params[:page]
@events = @search.result.paginate page: page_param
end
# events as pdf
......@@ -42,7 +42,7 @@ class EventsController < ApplicationController
else
@events = @conference.events
end
respond_to do |format|
format.pdf
end
......@@ -52,7 +52,7 @@ class EventsController < ApplicationController
def ratings
authorize! :create, EventRating
@search = @conference.events.search(params[:q])
@events = @search.result.paginate page: params[:page]
@events = @search.result.paginate page: page_param
clean_events_attributes
# total ratings:
......@@ -69,7 +69,7 @@ class EventsController < ApplicationController
def feedbacks
authorize! :access, :event_feedback
@search = @conference.events.accepted.search(params[:q])
@events = @search.result.paginate page: params[:page]
@events = @search.result.paginate page: page_param
end
# start batch event review
......@@ -104,7 +104,7 @@ class EventsController < ApplicationController
@event = Event.find(params[:id])
authorize! :read, @event
end
# GET /events/new
# GET /events/new.xml
def new
......@@ -189,7 +189,7 @@ class EventsController < ApplicationController
return redirect_to(@event, alert: "Cannot send mails: #{ex}.")
end
redirect_to @event, notice: 'Event was successfully updated.'
redirect_to @event, notice: 'Event was successfully updated.'
end
# DELETE /events/1
......@@ -219,7 +219,7 @@ class EventsController < ApplicationController
@event.clean_event_attributes!
end
unless @events.nil?
@events.map { |event| event.clean_event_attributes! }
@events.map { |event| event.clean_event_attributes! }
end
end
......
......@@ -13,7 +13,7 @@ class PeopleController < ApplicationController
else
@search = Person.involved_in(@conference).search(params[:q])
end
@people = @search.result.paginate page: params[:page]
@people = @search.result.paginate page: page_param
end
def speakers
......@@ -27,7 +27,7 @@ class PeopleController < ApplicationController
else
@search = @people.involved_in(@conference).search(params[:q])
end
@people = @search.result.paginate page: params[:page]
@people = @search.result.paginate page: page_param
end
format.text do
render text: @people.map(&:email).join("\n")
......@@ -42,7 +42,7 @@ class PeopleController < ApplicationController
else
@search = Person.search(params[:q])
end
@people = @search.result.paginate page: params[:page]
@people = @search.result.paginate page: page_param
end
# GET /people/1
......
......@@ -7,7 +7,7 @@ class RecentChangesController < ApplicationController
authorize! :manage, CallForPapers
@all_versions = Version.where(conference_id: @conference.id).order("created_at DESC")
@versions = @all_versions.paginate(
page: params[:page],
page: page_param,
per_page: 25
)
respond_to do |format|
......
......@@ -44,7 +44,7 @@ class ReportsController < ApplicationController
unless r.nil? or r.empty?
@search = r.search(params[:q])
@search_count = r.count
@events = @search.result.paginate page: params[:page]
@events = @search.result.paginate page: page_param
end
render :show
end
......@@ -82,7 +82,7 @@ class ReportsController < ApplicationController
unless r.nil? or r.empty?
@search = r.search(params[:q])
@search_count = r.length
@people = @search.result.paginate page: params[:page]
@people = @search.result.paginate page: page_param
end
render :show
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment