Skip to content
Snippets Groups Projects
Commit 3d02aed6 authored by Arnaud Levy's avatar Arnaud Levy
Browse files

scope wip #382

parent f69fe7d2
No related branches found
No related tags found
No related merge requests found
......@@ -5,8 +5,10 @@ class Admin::Education::ProgramsController < Admin::Education::ApplicationContro
before_action :load_teacher_people, only: [:new, :edit, :create, :update]
has_scope :for_search_term
def index
@programs = @programs.ordered_by_name
@programs = apply_scopes(@programs).ordered_by_name.page(params[:page])
breadcrumb
end
......
......@@ -5,12 +5,19 @@ class Admin::Education::TeachersController < Admin::Education::ApplicationContro
has_scope :for_program
def index
@teachers = apply_scopes(current_university.people.teachers.accessible_by(current_ability)).ordered.page(params[:page])
@teachers = apply_scopes(
current_university.people
.teachers
.accessible_by(current_ability)
).ordered.page(params[:page])
breadcrumb
end
def show
@involvements = @teacher.involvements_as_teacher.includes(:target).ordered_by_date.page(params[:page])
@involvements = @teacher.involvements_as_teacher
.includes(:target)
.ordered_by_date
.page(params[:page])
breadcrumb
end
......@@ -40,7 +47,10 @@ class Admin::Education::TeachersController < Admin::Education::ApplicationContro
end
def load_teacher
@teacher = current_university.people.teachers.accessible_by(current_ability).find(params[:id])
@teacher = current_university.people
.teachers
.accessible_by(current_ability)
.find(params[:id])
end
def teacher_params
......
......@@ -174,6 +174,11 @@ class Education::Program < ApplicationRecord
scope :published, -> { where(published: true) }
scope :ordered_by_name, -> { order(:name) }
scope :for_search_term, -> (term) {
where("
unaccent(education_programs.name) ILIKE unaccent(:term)
", term: "%#{sanitize_sql_like(term)}%")
}
def to_s
"#{name}"
......
......@@ -5,6 +5,7 @@
filters: @filters if @filters.any? %>
<%= render 'admin/education/programs/list', programs: @programs %>
<%= paginate @programs, theme: 'bootstrap-5' %>
<% content_for :action_bar_left do %>
<%= link_to t('admin.education.programs.view_as_tree'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment