diff --git a/app/controllers/admin/education/schools_controller.rb b/app/controllers/admin/education/schools_controller.rb index 7152bbd2748ae5a6622823a90566cf1fea61c082..f4c52f96a99855b7ca9cce5a329dbcaec97a932b 100644 --- a/app/controllers/admin/education/schools_controller.rb +++ b/app/controllers/admin/education/schools_controller.rb @@ -3,7 +3,10 @@ class Admin::Education::SchoolsController < Admin::Education::ApplicationControl through: :current_university, through_association: :education_schools + has_scope :for_search_term + def index + @schools = apply_scopes(@schools).ordered.page(params[:page]) breadcrumb end diff --git a/app/controllers/admin/education/teachers_controller.rb b/app/controllers/admin/education/teachers_controller.rb index fe56c928e71293eeec301b6ad3a7bbfb2acf806b..49e506997ff691bb3a96ce5d2ce4fca561f11242 100644 --- a/app/controllers/admin/education/teachers_controller.rb +++ b/app/controllers/admin/education/teachers_controller.rb @@ -1,8 +1,10 @@ class Admin::Education::TeachersController < Admin::Education::ApplicationController before_action :load_teacher, only: [:show, :edit, :update] + has_scope :for_search_term + def index - @teachers = 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 diff --git a/app/controllers/admin/research/journals_controller.rb b/app/controllers/admin/research/journals_controller.rb index 4cecdb213ef75b6d41f73ea6dbcba6885350be8d..0fb198f42ec13db026963621faf104fb8e9ef777 100644 --- a/app/controllers/admin/research/journals_controller.rb +++ b/app/controllers/admin/research/journals_controller.rb @@ -3,8 +3,10 @@ class Admin::Research::JournalsController < Admin::Research::ApplicationControll through: :current_university, through_association: :research_journals + has_scope :for_search_term + def index - @journals = @journals.ordered.page(params[:page]) + @journals = apply_scopes(@journals).ordered.page(params[:page]) breadcrumb add_breadcrumb Research::Journal.model_name.human(count: 2), admin_research_journals_path end diff --git a/app/controllers/admin/research/laboratories_controller.rb b/app/controllers/admin/research/laboratories_controller.rb index 49cb0d3f3a2b5a590c2f026fe69efeb25128634f..67621fc6420f7fd87216cd0a495d96df3c19f599 100644 --- a/app/controllers/admin/research/laboratories_controller.rb +++ b/app/controllers/admin/research/laboratories_controller.rb @@ -3,8 +3,10 @@ class Admin::Research::LaboratoriesController < Admin::Research::ApplicationCont through: :current_university, through_association: :research_laboratories + has_scope :for_search_term + def index - @laboratories = @laboratories.ordered.page(params[:page]) + @laboratories = apply_scopes(@laboratories).ordered.page(params[:page]) breadcrumb add_breadcrumb Research::Laboratory.model_name.human(count: 2), admin_research_laboratories_path end diff --git a/app/controllers/admin/research/researchers_controller.rb b/app/controllers/admin/research/researchers_controller.rb index ae994e920900f5c34f7bf2bacded2f7ab28928ea..b192fc776306ad92e404022637536d9851b70538 100644 --- a/app/controllers/admin/research/researchers_controller.rb +++ b/app/controllers/admin/research/researchers_controller.rb @@ -1,7 +1,9 @@ class Admin::Research::ResearchersController < Admin::Research::ApplicationController + has_scope :for_search_term + def index - @researchers = current_university.people.researchers.accessible_by(current_ability).ordered.page(params[:page]) + @researchers = apply_scopes(current_university.people.researchers.accessible_by(current_ability)).ordered.page(params[:page]) breadcrumb end diff --git a/app/controllers/admin/research/theses_controller.rb b/app/controllers/admin/research/theses_controller.rb index 114e1238eaa8678df4aad233399a57df836acf4c..b043a530b0f4999b6c85a70d257e3a9a6cfa2278 100644 --- a/app/controllers/admin/research/theses_controller.rb +++ b/app/controllers/admin/research/theses_controller.rb @@ -3,8 +3,10 @@ class Admin::Research::ThesesController < Admin::Research::ApplicationController through: :current_university, through_association: :research_theses + has_scope :for_search_term + def index - @theses = @theses.ordered.page(params[:page]) + @theses = apply_scopes(@theses).ordered.page(params[:page]) breadcrumb end diff --git a/app/controllers/admin/university/person/alumni_controller.rb b/app/controllers/admin/university/person/alumni_controller.rb index f86a16f465887e83060d153fabc10a6d9c35c0f5..80931367b97f1925831afcd2d3ddfae2999d0ecf 100644 --- a/app/controllers/admin/university/person/alumni_controller.rb +++ b/app/controllers/admin/university/person/alumni_controller.rb @@ -2,8 +2,11 @@ class Admin::University::Person::AlumniController < Admin::University::Applicati load_and_authorize_resource class: University::Person::Alumnus, through: :current_university, through_association: :people + + has_scope :for_search_term + def index - @alumni = @alumni.alumni + @alumni = apply_scopes(@alumni).alumni .accessible_by(current_ability) .ordered .page(params[:page]) diff --git a/app/models/education/school.rb b/app/models/education/school.rb index 7149a637cd8a0e01c63cf649c937a507b9114acd..fdfbb5bab8aef23c5b33ac762ff2fce142d75c77 100644 --- a/app/models/education/school.rb +++ b/app/models/education/school.rb @@ -91,6 +91,16 @@ class Education::School < ApplicationRecord validates :name, :address, :city, :zipcode, :country, presence: true scope :ordered, -> { order(:name) } + scope :for_search_term, -> (term) { + where(" + unaccent(education_schools.address) ILIKE unaccent(:term) OR + unaccent(education_schools.city) ILIKE unaccent(:term) OR + unaccent(education_schools.country) ILIKE unaccent(:term) OR + unaccent(education_schools.name) ILIKE unaccent(:term) OR + unaccent(education_schools.phone) ILIKE unaccent(:term) OR + unaccent(education_schools.zipcode) ILIKE unaccent(:term) + ", term: "%#{sanitize_sql_like(term)}%") + } def to_s "#{name}" diff --git a/app/models/research/journal.rb b/app/models/research/journal.rb index 08cbbc495f5179431568c1c47663493c19fa4044..2ed9428145269dc38d87a5fc43d61e8ce9a5c706 100644 --- a/app/models/research/journal.rb +++ b/app/models/research/journal.rb @@ -34,6 +34,14 @@ class Research::Journal < ApplicationRecord has_many :people_through_published_articles, -> { distinct }, through: :published_articles, source: :people scope :ordered, -> { order(:title) } + scope :for_search_term, -> (term) { + where(" + unaccent(research_journals.description) ILIKE unaccent(:term) OR + unaccent(research_journals.issn) ILIKE unaccent(:term) OR + unaccent(research_journals.repository) ILIKE unaccent(:term) OR + unaccent(research_journals.title) ILIKE unaccent(:term) + ", term: "%#{sanitize_sql_like(term)}%") + } def to_s "#{title}" diff --git a/app/models/research/laboratory.rb b/app/models/research/laboratory.rb index 6ec50a9bafb0fc32e3722ab5929faee431181747..2908de92a196b43de0245cceb3cbdbf432572651 100644 --- a/app/models/research/laboratory.rb +++ b/app/models/research/laboratory.rb @@ -34,7 +34,18 @@ class Research::Laboratory < ApplicationRecord foreign_key: :research_laboratory_id, dependent: :destroy + validates :name, :address, :city, :zipcode, :country, presence: true + scope :ordered, -> { order(:name) } + scope :for_search_term, -> (term) { + where(" + unaccent(research_laboratories.address) ILIKE unaccent(:term) OR + unaccent(research_laboratories.city) ILIKE unaccent(:term) OR + unaccent(research_laboratories.country) ILIKE unaccent(:term) OR + unaccent(research_laboratories.name) ILIKE unaccent(:term) OR + unaccent(research_laboratories.zipcode) ILIKE unaccent(:term) + ", term: "%#{sanitize_sql_like(term)}%") + } def to_s "#{name}" diff --git a/app/models/research/thesis.rb b/app/models/research/thesis.rb index e8fea9e2f80a318eb56e2da9b45d2fe429d622cd..361daf38ef27baaa93e0517ea4b302dcea7368bb 100644 --- a/app/models/research/thesis.rb +++ b/app/models/research/thesis.rb @@ -38,6 +38,12 @@ class Research::Thesis < ApplicationRecord belongs_to :director, class_name: 'University::Person' scope :ordered, -> { order(:title) } + scope :for_search_term, -> (term) { + where(" + unaccent(research_theses.abstract) ILIKE unaccent(:term) OR + unaccent(research_theses.title) ILIKE unaccent(:term) + ", term: "%#{sanitize_sql_like(term)}%") + } def to_s "#{title}" diff --git a/app/views/admin/education/schools/index.html.erb b/app/views/admin/education/schools/index.html.erb index 60026b10e5e4bb122924ca5ba9b74f55685e5c26..0e30adb402c92321f1bc27e802fe74bf2039281e 100644 --- a/app/views/admin/education/schools/index.html.erb +++ b/app/views/admin/education/schools/index.html.erb @@ -1,5 +1,7 @@ <% content_for :title, Education::School.model_name.human(count: 2) %> +<%= render 'filters', current_path: admin_education_schools_path, filters: @filters if @filters.any? %> + <table class="table"> <thead> <tr> @@ -28,6 +30,9 @@ </tbody> </table> +<%= paginate @schools, theme: 'bootstrap-5' %> + + <% content_for :action_bar_right do %> <%= create_link Education::School %> <% end %> diff --git a/app/views/admin/education/teachers/index.html.erb b/app/views/admin/education/teachers/index.html.erb index 44222c52bf2466eb72ab05c45c5c5839d06ee498..973534e4e14bca9f1d675fcebe13b0cd6136b2c4 100644 --- a/app/views/admin/education/teachers/index.html.erb +++ b/app/views/admin/education/teachers/index.html.erb @@ -1,10 +1,10 @@ <% content_for :title, "#{t('education.teachers', count: 2)} (#{@teachers.total_count})" %> +<%= render 'filters', current_path: admin_education_teachers_path, filters: @filters if @filters.any? %> + <%= render 'admin/education/teachers/list', teachers: @teachers %> -<% if @teachers.total_pages > 1 %> - <%= paginate @teachers, theme: 'bootstrap-5' %> -<% end %> +<%= paginate @teachers, theme: 'bootstrap-5' %> <% content_for :action_bar_right do %> <%= link_to t('education.manage_teachers'), admin_university_people_path, class: button_classes if can?(:read, University::Person) %> diff --git a/app/views/admin/research/journals/index.html.erb b/app/views/admin/research/journals/index.html.erb index 51577a58d30204cb73231cc9968ffb877bab9a1c..e5fff3497acd3a0d73f1d3842b5f8f9324c4f2e9 100644 --- a/app/views/admin/research/journals/index.html.erb +++ b/app/views/admin/research/journals/index.html.erb @@ -1,5 +1,7 @@ <% content_for :title, Research::Journal.model_name.human(count: 2) %> +<%= render 'filters', current_path: admin_research_journals_path, filters: @filters if @filters.any? %> + <table class="table"> <thead> <tr> diff --git a/app/views/admin/research/laboratories/index.html.erb b/app/views/admin/research/laboratories/index.html.erb index 5f6bfcc14779c869dd3276c0fef8e38965fad7f9..7ee9816c49148cb81ce99f371d5dc9ed7d812214 100644 --- a/app/views/admin/research/laboratories/index.html.erb +++ b/app/views/admin/research/laboratories/index.html.erb @@ -1,5 +1,7 @@ <% content_for :title, Research::Laboratory.model_name.human(count: 2) %> +<%= render 'filters', current_path: admin_research_laboratories_path, filters: @filters if @filters.any? %> + <table class="table"> <thead> <tr> diff --git a/app/views/admin/research/researchers/index.html.erb b/app/views/admin/research/researchers/index.html.erb index 2a56d4f11c5db480619868d0527966e5b3de11b6..d0256588dcffd2d64877dc044571ab30f21803f9 100644 --- a/app/views/admin/research/researchers/index.html.erb +++ b/app/views/admin/research/researchers/index.html.erb @@ -1,5 +1,7 @@ <% content_for :title, t('research.researchers', count: 2) %> +<%= render 'filters', current_path: admin_research_researchers_path, filters: @filters if @filters.any? %> + <table class="table"> <thead> <tr> @@ -19,9 +21,8 @@ <% end %> </tbody> </table> -<% if @researchers.total_pages > 1 %> - <%= paginate @researchers, theme: 'bootstrap-5' %> -<% end %> + +<%= paginate @researchers, theme: 'bootstrap-5' %> <% content_for :action_bar_right do %> diff --git a/app/views/admin/research/theses/index.html.erb b/app/views/admin/research/theses/index.html.erb index bba33c839d94a9d02684d5a30273044b7d3d78ab..7f13d52478e3504a8917217c916b9be820873f95 100644 --- a/app/views/admin/research/theses/index.html.erb +++ b/app/views/admin/research/theses/index.html.erb @@ -1,5 +1,7 @@ <% content_for :title, Research::Thesis.model_name.human(count: 2) %> +<%= render 'filters', current_path: admin_research_theses_path, filters: @filters if @filters.any? %> + <table class="table"> <thead> <tr> diff --git a/app/views/admin/university/person/alumni/index.html.erb b/app/views/admin/university/person/alumni/index.html.erb index 81016b583aa4737abb50cb490c08484eadef5797..fcc1509bdbda12e2dbb7b5aea638b9de124b632a 100644 --- a/app/views/admin/university/person/alumni/index.html.erb +++ b/app/views/admin/university/person/alumni/index.html.erb @@ -1,5 +1,7 @@ <% content_for :title, "#{University::Person::Alumnus.model_name.human(count: 2)} (#{@alumni.total_count})" %> +<%= render 'filters', current_path: admin_university_person_alumni_path, filters: @filters if @filters.any? %> + <%= render 'admin/university/person/alumni/list', alumni: @alumni %> <%= paginate @alumni, theme: 'bootstrap-5' %> diff --git a/app/views/admin/university/person/alumnus/imports/new.html.erb b/app/views/admin/university/person/alumnus/imports/new.html.erb index ca77bb651a0358c7c57c80e8bd689a0071751768..78665920c2eb33f7d34d78359798bf3cbe760137 100644 --- a/app/views/admin/university/person/alumnus/imports/new.html.erb +++ b/app/views/admin/university/person/alumnus/imports/new.html.erb @@ -7,7 +7,7 @@ La première ligne doit être dédiée aux entêtes.<br> Les noms des entêtes sont obligatoires et doivent être respectés strictement.<br> Les champs marqués d'une astérisque sont obligatoires.<br> - Les caractères doivent être encodés en UTF-8. + Les caractères doivent être encodés en UTF-8.<br> Les valeurs pour gender peuvent être m (masculin), f (féminin) et n (non binaire). </p> <%= simple_form_for [:admin, @import] do |f| %>