Skip to content
Snippets Groups Projects
Commit fb8307ec authored by pabois's avatar pabois
Browse files

wip #279

parent aac7e53e
No related branches found
No related tags found
No related merge requests found
......@@ -3,8 +3,11 @@ class Admin::University::OrganizationsController < Admin::University::Applicatio
through: :current_university,
through_association: :organizations
has_scope :for_search_term
has_scope :for_kind
def index
@organizations = @organizations.ordered.page(params[:page])
@organizations = apply_scopes(@organizations).ordered.page(params[:page])
breadcrumb
end
......
......@@ -45,6 +45,24 @@ class University::Organization < ApplicationRecord
has_one_attached_deletable :logo
scope :ordered, -> { order(:name) }
scope :for_kind, -> (kind) { where(kind: kind) }
scope :for_search_term, -> (term) {
where("
unaccent(university_organizations.address) ILIKE unaccent(:term) OR
unaccent(university_organizations.city) ILIKE unaccent(:term) OR
unaccent(university_organizations.country) ILIKE unaccent(:term) OR
unaccent(university_organizations.description) ILIKE unaccent(:term) OR
unaccent(university_organizations.email) ILIKE unaccent(:term) OR
unaccent(university_organizations.long_name) ILIKE unaccent(:term) OR
unaccent(university_organizations.name) ILIKE unaccent(:term) OR
unaccent(university_organizations.nic) ILIKE unaccent(:term) OR
unaccent(university_organizations.phone) ILIKE unaccent(:term) OR
unaccent(university_organizations.siren) ILIKE unaccent(:term) OR
unaccent(university_organizations.text) ILIKE unaccent(:term) OR
unaccent(university_organizations.zipcode) ILIKE unaccent(:term) OR
unaccent(university_organizations.url) ILIKE unaccent(:term)
", term: "%#{sanitize_sql_like(term)}%")
}
validates_presence_of :name
......
......@@ -117,7 +117,6 @@ class University::Person < ApplicationRecord
scope :researchers, -> { where(is_researcher: true) }
scope :alumni, -> { where(is_alumnus: true) }
scope :for_role, -> (role) { where("is_#{role}": true) }
scope :for_search_term, -> (term) {
where("
unaccent(concat(university_people.first_name, ' ', university_people.last_name)) ILIKE unaccent(:term) OR
......
module Filters
class Admin::University::Organizations < Filters::Base
def initialize(user)
super
add_search
add :for_kind, ::University::Organization::kinds.keys.map { |r| { to_s: I18n.t("enums.university.organization.kind.#{r}"), id: r } }, I18n.t('filters.attributes.kind')
end
end
end
<% content_for :title, "#{University::Organization.model_name.human(count: 2)} (#{@organizations.total_count})" %>
<%= render 'filters', current_path: admin_university_organizations_path, filters: @filters if @filters.any? %>
<%= render 'admin/university/organizations/list', organizations: @organizations %>
<%= paginate @organizations, theme: 'bootstrap-5' %>
......
......@@ -96,6 +96,7 @@ en:
filters:
attributes:
date: Filter by Date
kind: Filter by Kind
role: Filter by Role
buttons:
expand: Filter table
......
......@@ -96,6 +96,7 @@ fr:
filters:
attributes:
date: Filtrer par Date
kind: Filtrer par Type
role: Filtrer par Rôle
buttons:
expand: Filtrer le tableau
......
......@@ -319,10 +319,10 @@ ActiveRecord::Schema.define(version: 2022_04_27_094234) do
t.uuid "related_category_id"
t.string "featured_image_alt"
t.text "text"
t.text "description_short"
t.string "breadcrumb_title"
t.text "header_text"
t.integer "kind"
t.text "description_short"
t.string "bodyclass"
t.uuid "language_id"
t.index ["communication_website_id"], name: "index_communication_website_pages_on_communication_website_id"
......@@ -502,23 +502,6 @@ ActiveRecord::Schema.define(version: 2022_04_27_094234) do
t.index ["university_id"], name: "index_education_schools_on_university_id"
end
create_table "external_organizations", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.string "title"
t.text "description"
t.string "address"
t.string "zipcode"
t.string "city"
t.string "country"
t.string "website"
t.string "phone"
t.string "mail"
t.boolean "active"
t.string "sirene"
t.integer "kind"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
create_table "languages", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.string "name"
t.string "iso_code"
......@@ -702,8 +685,8 @@ ActiveRecord::Schema.define(version: 2022_04_27_094234) do
t.string "linkedin"
t.boolean "is_alumnus", default: false
t.text "description_short"
t.string "name"
t.boolean "is_author"
t.string "name"
t.index ["university_id"], name: "index_university_people_on_university_id"
t.index ["user_id"], name: "index_university_people_on_user_id"
end
......
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