added pagination for all resources
This commit is contained in:
@ -27,7 +27,7 @@ class ConsumersController < ApplicationController
|
||||
private :consumer_params
|
||||
|
||||
def index
|
||||
@consumers = Consumer.all
|
||||
@consumers = Consumer.paginate(page: params[:page])
|
||||
authorize!
|
||||
end
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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]))
|
||||
|
@ -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)
|
||||
|
3
app/views/shared/_pagination.html.slim
Normal file
3
app/views/shared/_pagination.html.slim
Normal file
@ -0,0 +1,3 @@
|
||||
- if (pagination = will_paginate(collection, container: false)).present?
|
||||
.text-center
|
||||
ul.pagination = pagination
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Reference in New Issue
Block a user