Introduce per_page parameter for custom page size
This commit is contained in:
@ -28,7 +28,7 @@ class ConsumersController < ApplicationController
|
||||
private :consumer_params
|
||||
|
||||
def index
|
||||
@consumers = Consumer.paginate(page: params[:page])
|
||||
@consumers = Consumer.paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -12,7 +12,7 @@ class ErrorTemplateAttributesController < ApplicationController
|
||||
# GET /error_template_attributes.json
|
||||
def index
|
||||
@error_template_attributes = ErrorTemplateAttribute.all.order('important DESC', :key,
|
||||
:id).paginate(page: params[:page])
|
||||
:id).paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -11,7 +11,7 @@ class ErrorTemplatesController < ApplicationController
|
||||
# GET /error_templates
|
||||
# GET /error_templates.json
|
||||
def index
|
||||
@error_templates = ErrorTemplate.all.order(:execution_environment_id, :name).paginate(page: params[:page])
|
||||
@error_templates = ErrorTemplate.all.order(:execution_environment_id, :name).paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -121,7 +121,7 @@ class ExecutionEnvironmentsController < ApplicationController
|
||||
private :execution_environment_params
|
||||
|
||||
def index
|
||||
@execution_environments = ExecutionEnvironment.all.includes(:user).order(:name).paginate(page: params[:page])
|
||||
@execution_environments = ExecutionEnvironment.all.includes(:user).order(:name).paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -6,7 +6,7 @@ class ExerciseCollectionsController < ApplicationController
|
||||
before_action :set_exercise_collection, only: %i[show edit update destroy statistics]
|
||||
|
||||
def index
|
||||
@exercise_collections = ExerciseCollection.all.paginate(page: params[:page])
|
||||
@exercise_collections = ExerciseCollection.all.paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -103,7 +103,7 @@ raise: false
|
||||
|
||||
def feedback
|
||||
authorize!
|
||||
@feedbacks = @exercise.user_exercise_feedbacks.paginate(page: params[:page])
|
||||
@feedbacks = @exercise.user_exercise_feedbacks.paginate(page: params[:page], per_page: per_page_param)
|
||||
@submissions = @feedbacks.map do |feedback|
|
||||
feedback.exercise.final_submission(feedback.user)
|
||||
end
|
||||
@ -410,7 +410,7 @@ working_time_accumulated: working_time_accumulated})
|
||||
|
||||
def index
|
||||
@search = policy_scope(Exercise).ransack(params[:q])
|
||||
@exercises = @search.result.includes(:execution_environment, :user).order(:title).paginate(page: params[:page])
|
||||
@exercises = @search.result.includes(:execution_environment, :user).order(:title).paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -10,7 +10,7 @@ class ExternalUsersController < ApplicationController
|
||||
|
||||
def index
|
||||
@search = ExternalUser.ransack(params[:q])
|
||||
@users = @search.result.in_study_group_of(current_user).includes(:consumer).paginate(page: params[:page])
|
||||
@users = @search.result.in_study_group_of(current_user).includes(:consumer).paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -19,7 +19,7 @@ class FileTemplatesController < ApplicationController
|
||||
# GET /file_templates
|
||||
# GET /file_templates.json
|
||||
def index
|
||||
@file_templates = FileTemplate.all.order(:file_type_id).paginate(page: params[:page])
|
||||
@file_templates = FileTemplate.all.order(:file_type_id).paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -33,7 +33,7 @@ class FileTypesController < ApplicationController
|
||||
private :file_type_params
|
||||
|
||||
def index
|
||||
@file_types = FileType.all.includes(:user).order(:name).paginate(page: params[:page])
|
||||
@file_types = FileType.all.includes(:user).order(:name).paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -63,7 +63,7 @@ class InternalUsersController < ApplicationController
|
||||
|
||||
def index
|
||||
@search = InternalUser.ransack(params[:q])
|
||||
@users = @search.result.includes(:consumer).order(:name).paginate(page: params[:page])
|
||||
@users = @search.result.includes(:consumer).order(:name).paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -51,7 +51,7 @@ class ProxyExercisesController < ApplicationController
|
||||
|
||||
def index
|
||||
@search = policy_scope(ProxyExercise).ransack(params[:q])
|
||||
@proxy_exercises = @search.result.order(:title).paginate(page: params[:page])
|
||||
@proxy_exercises = @search.result.order(:title).paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -23,7 +23,7 @@ class RequestForCommentsController < ApplicationController
|
||||
.where(exercises: {unpublished: false})
|
||||
.includes(submission: [:study_group])
|
||||
.order('created_at DESC')
|
||||
.paginate(page: params[:page], total_entries: @search.result.length)
|
||||
.paginate(page: params[:page], per_page: per_page_param, total_entries: @search.result.length)
|
||||
|
||||
authorize!
|
||||
end
|
||||
@ -36,7 +36,7 @@ class RequestForCommentsController < ApplicationController
|
||||
.ransack(params[:q])
|
||||
@request_for_comments = @search.result
|
||||
.order('created_at DESC')
|
||||
.paginate(page: params[:page])
|
||||
.paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
render 'index'
|
||||
end
|
||||
@ -50,7 +50,7 @@ class RequestForCommentsController < ApplicationController
|
||||
.ransack(params[:q])
|
||||
@request_for_comments = @search.result
|
||||
.order('last_comment DESC')
|
||||
.paginate(page: params[:page])
|
||||
.paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
render 'index'
|
||||
end
|
||||
@ -65,7 +65,7 @@ class RequestForCommentsController < ApplicationController
|
||||
@request_for_comments = @search.result
|
||||
.joins(:exercise)
|
||||
.order('last_comment DESC')
|
||||
.paginate(page: params[:page])
|
||||
.paginate(page: params[:page], per_page: per_page_param)
|
||||
# let the exercise decide, whether its rfcs should be visible
|
||||
authorize(exercise)
|
||||
render 'index'
|
||||
|
@ -7,7 +7,7 @@ class StudyGroupsController < ApplicationController
|
||||
|
||||
def index
|
||||
@search = policy_scope(StudyGroup).ransack(params[:q])
|
||||
@study_groups = @search.result.includes(:consumer).order(:name).paginate(page: params[:page])
|
||||
@study_groups = @search.result.includes(:consumer).order(:name).paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -65,7 +65,7 @@ class SubmissionsController < ApplicationController
|
||||
|
||||
def index
|
||||
@search = Submission.ransack(params[:q])
|
||||
@submissions = @search.result.includes(:exercise, :user).paginate(page: params[:page])
|
||||
@submissions = @search.result.includes(:exercise, :user).paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -28,7 +28,7 @@ class TagsController < ApplicationController
|
||||
private :tag_params
|
||||
|
||||
def index
|
||||
@tags = Tag.all.paginate(page: params[:page])
|
||||
@tags = Tag.all.paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -34,7 +34,7 @@ class TipsController < ApplicationController
|
||||
private :tip_params
|
||||
|
||||
def index
|
||||
@tips = Tip.all.paginate(page: params[:page])
|
||||
@tips = Tip.all.paginate(page: params[:page], per_page: per_page_param)
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -34,6 +34,14 @@ module ApplicationHelper
|
||||
tag.i(nil, class: 'fa fa-times')
|
||||
end
|
||||
|
||||
def per_page_param
|
||||
if params[:per_page]
|
||||
[params[:per_page].to_i, 100].min
|
||||
else
|
||||
WillPaginate.per_page
|
||||
end
|
||||
end
|
||||
|
||||
def progress_bar(value)
|
||||
tag.div(class: value ? 'progress' : 'disabled progress') do
|
||||
tag.div(value ? "#{value}%" : '', 'aria-valuemax': 100, 'aria-valuemin': 0,
|
||||
|
Reference in New Issue
Block a user