diff --git a/app/controllers/consumers_controller.rb b/app/controllers/consumers_controller.rb index e22d4b3e..5c97a58a 100644 --- a/app/controllers/consumers_controller.rb +++ b/app/controllers/consumers_controller.rb @@ -27,7 +27,7 @@ class ConsumersController < ApplicationController private :consumer_params def index - @consumers = Consumer.all + @consumers = Consumer.paginate(page: params[:page]) authorize! end diff --git a/app/controllers/errors_controller.rb b/app/controllers/errors_controller.rb index 096a85ed..e3859507 100644 --- a/app/controllers/errors_controller.rb +++ b/app/controllers/errors_controller.rb @@ -27,7 +27,7 @@ class ErrorsController < ApplicationController private :error_params def index - @errors = Error.for_execution_environment(@execution_environment).grouped_by_message + @errors = Error.for_execution_environment(@execution_environment).grouped_by_message.paginate(page: params[:page]) authorize! end diff --git a/app/controllers/execution_environments_controller.rb b/app/controllers/execution_environments_controller.rb index 9f9a4b92..308425f7 100644 --- a/app/controllers/execution_environments_controller.rb +++ b/app/controllers/execution_environments_controller.rb @@ -34,7 +34,7 @@ class ExecutionEnvironmentsController < ApplicationController private :execution_environment_params def index - @execution_environments = ExecutionEnvironment.all.includes(:user).order(:name) + @execution_environments = ExecutionEnvironment.all.includes(:user).order(:name).paginate(page: params[:page]) authorize! end diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index 8ad4e09d..56378ca1 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -78,7 +78,7 @@ class ExercisesController < ApplicationController def index @search = policy_scope(Exercise).search(params[:q]) - @exercises = @search.result.includes(:execution_environment, :user).order(:title) + @exercises = @search.result.includes(:execution_environment, :user).order(:title).paginate(page: params[:page]) authorize! end diff --git a/app/controllers/external_users_controller.rb b/app/controllers/external_users_controller.rb index cbc2b4f7..1d22dc58 100644 --- a/app/controllers/external_users_controller.rb +++ b/app/controllers/external_users_controller.rb @@ -5,7 +5,7 @@ class ExternalUsersController < ApplicationController private :authorize! def index - @users = ExternalUser.all.includes(:consumer) + @users = ExternalUser.all.includes(:consumer).paginate(page: params[:page]) authorize! end diff --git a/app/controllers/file_types_controller.rb b/app/controllers/file_types_controller.rb index ea813f22..9f16da28 100644 --- a/app/controllers/file_types_controller.rb +++ b/app/controllers/file_types_controller.rb @@ -28,7 +28,7 @@ class FileTypesController < ApplicationController private :file_type_params def index - @file_types = FileType.all.includes(:user).order(:name) + @file_types = FileType.all.includes(:user).order(:name).paginate(page: params[:page]) authorize! end diff --git a/app/controllers/hints_controller.rb b/app/controllers/hints_controller.rb index 19e90e2c..827ba6ce 100644 --- a/app/controllers/hints_controller.rb +++ b/app/controllers/hints_controller.rb @@ -28,7 +28,7 @@ class HintsController < ApplicationController private :hint_params def index - @hints = @execution_environment.hints.order(:name) + @hints = @execution_environment.hints.order(:name).paginate(page: params[:page]) authorize! end diff --git a/app/controllers/internal_users_controller.rb b/app/controllers/internal_users_controller.rb index f17e6078..d2153a7c 100644 --- a/app/controllers/internal_users_controller.rb +++ b/app/controllers/internal_users_controller.rb @@ -62,7 +62,7 @@ class InternalUsersController < ApplicationController def index @search = InternalUser.search(params[:q]) - @users = @search.result.includes(:consumer).order(:name) + @users = @search.result.includes(:consumer).order(:name).paginate(page: params[:page]) authorize! end diff --git a/app/controllers/teams_controller.rb b/app/controllers/teams_controller.rb index 40aea9e1..1ca8f1fe 100644 --- a/app/controllers/teams_controller.rb +++ b/app/controllers/teams_controller.rb @@ -22,7 +22,7 @@ class TeamsController < ApplicationController end def index - @teams = Team.all.includes(:internal_users).order(:name) + @teams = Team.all.includes(:internal_users).order(:name).paginate(page: params[:page]) authorize! end diff --git a/app/views/consumers/index.html.slim b/app/views/consumers/index.html.slim index 6a1fb14d..c05581ed 100644 --- a/app/views/consumers/index.html.slim +++ b/app/views/consumers/index.html.slim @@ -14,4 +14,5 @@ h1 = Consumer.model_name.human(count: 2) td = link_to(t('shared.edit'), edit_consumer_path(consumer)) td = link_to(t('shared.destroy'), consumer, data: {confirm: t('shared.confirm_destroy')}, method: :delete) += render('shared/pagination', collection: @consumers) p = render('shared/new_button', model: Consumer) diff --git a/app/views/errors/index.html.slim b/app/views/errors/index.html.slim index e576f1cf..2db0d9de 100644 --- a/app/views/errors/index.html.slim +++ b/app/views/errors/index.html.slim @@ -15,3 +15,5 @@ h1 = ::Error.model_name.human(count: 2) td = error.message td = l(error.created_at, format: :short) td = link_to(t('shared.show'), execution_environment_error_path(params[:execution_environment_id], error)) + +p = render('shared/pagination', collection: @errors) diff --git a/app/views/execution_environments/index.html.slim b/app/views/execution_environments/index.html.slim index 3745c61e..d5a103ed 100644 --- a/app/views/execution_environments/index.html.slim +++ b/app/views/execution_environments/index.html.slim @@ -20,4 +20,5 @@ h1 = ExecutionEnvironment.model_name.human(count: 2) td = link_to(t('activerecord.models.error.other'), execution_environment_errors_path(execution_environment.id)) td = link_to(t('activerecord.models.hint.other'), execution_environment_hints_path(execution_environment.id)) += render('shared/pagination', collection: @execution_environments) p = render('shared/new_button', model: ExecutionEnvironment) diff --git a/app/views/exercises/index.html.slim b/app/views/exercises/index.html.slim index 1f5c9f81..00d0729f 100644 --- a/app/views/exercises/index.html.slim +++ b/app/views/exercises/index.html.slim @@ -35,4 +35,5 @@ h1 = Exercise.model_name.human(count: 2) td = link_to(t('.implement'), implement_exercise_path(exercise)) td = link_to(t('shared.statistics'), statistics_exercise_path(exercise)) += render('shared/pagination', collection: @exercises) p = render('shared/new_button', model: Exercise) diff --git a/app/views/external_users/index.html.slim b/app/views/external_users/index.html.slim index e62cb01d..34359b2a 100644 --- a/app/views/external_users/index.html.slim +++ b/app/views/external_users/index.html.slim @@ -13,3 +13,5 @@ h1 = ExternalUser.model_name.human(count: 2) td = user.name td = link_to(user.consumer, user.consumer) td = link_to(t('shared.show'), user) + += render('shared/pagination', collection: @users) diff --git a/app/views/file_types/index.html.slim b/app/views/file_types/index.html.slim index 0fc70368..a8a4d294 100644 --- a/app/views/file_types/index.html.slim +++ b/app/views/file_types/index.html.slim @@ -18,4 +18,5 @@ h1 = FileType.model_name.human(count: 2) td = link_to(t('shared.edit'), edit_file_type_path(file_type)) td = link_to(t('shared.destroy'), file_type, data: {confirm: t('shared.confirm_destroy')}, method: :delete) += render('shared/pagination', collection: @file_types) p = render('shared/new_button', model: FileType) diff --git a/app/views/hints/index.html.slim b/app/views/hints/index.html.slim index 9c85d753..6a80bbdb 100644 --- a/app/views/hints/index.html.slim +++ b/app/views/hints/index.html.slim @@ -16,4 +16,5 @@ h1 = Hint.model_name.human(count: 2) td = link_to(t('shared.edit'), edit_execution_environment_hint_path(params[:execution_environment_id], hint.id)) td = link_to(t('shared.destroy'), execution_environment_hint_path(params[:execution_environment_id], hint.id), data: {confirm: t('shared.confirm_destroy')}, method: :delete) += render('shared/pagination', collection: @hints) p = render('shared/new_button', model: Hint, path: new_execution_environment_hint_path(params[:execution_environment_id])) diff --git a/app/views/internal_users/index.html.slim b/app/views/internal_users/index.html.slim index 8abfad5a..c4b6c1a0 100644 --- a/app/views/internal_users/index.html.slim +++ b/app/views/internal_users/index.html.slim @@ -31,4 +31,5 @@ h1 = InternalUser.model_name.human(count: 2) - if policy(user).destroy? = link_to(t('shared.destroy'), user, data: {confirm: t('shared.confirm_destroy')}, method: :delete) += render('shared/pagination', collection: @users) p = render('shared/new_button', model: InternalUser) diff --git a/app/views/shared/_pagination.html.slim b/app/views/shared/_pagination.html.slim new file mode 100644 index 00000000..3089d962 --- /dev/null +++ b/app/views/shared/_pagination.html.slim @@ -0,0 +1,3 @@ +- if (pagination = will_paginate(collection, container: false)).present? + .text-center + ul.pagination = pagination diff --git a/app/views/submissions/index.html.slim b/app/views/submissions/index.html.slim index 885d7949..fb6504ef 100644 --- a/app/views/submissions/index.html.slim +++ b/app/views/submissions/index.html.slim @@ -29,5 +29,4 @@ h1 = Submission.model_name.human(count: 2) td = link_to(t('shared.show'), submission) td = link_to(t('shared.statistics'), statistics_submission_path(submission)) -.text-center - ul.pagination = will_paginate(@submissions, container: false) += render('shared/pagination', collection: @submissions) diff --git a/app/views/teams/index.html.slim b/app/views/teams/index.html.slim index cffa8739..4eb6640b 100644 --- a/app/views/teams/index.html.slim +++ b/app/views/teams/index.html.slim @@ -16,4 +16,5 @@ h1 = Team.model_name.human(count: 2) td = link_to(t('shared.edit'), edit_team_path(team.id)) td = link_to(t('shared.destroy'), team_path(team.id), data: {confirm: t('shared.confirm_destroy')}, method: :delete) += render('shared/pagination', collection: @teams) p = render('shared/new_button', model: Team, path: new_team_path)