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

Wip #431

parent cbdf10ac
No related branches found
No related tags found
No related merge requests found
...@@ -4,18 +4,29 @@ module Education::Program::WithWebsites ...@@ -4,18 +4,29 @@ module Education::Program::WithWebsites
included do included do
attr_accessor :skip_websites_categories_callback attr_accessor :skip_websites_categories_callback
after_save_commit :set_websites_categories, unless: :skip_websites_categories_callback after_save_commit :set_websites_categories,
unless: :skip_websites_categories_callback
# FIXME incorrect, forgets websites about programs
has_many :websites, -> { distinct },
through: :schools
has_many :website_categories, has_many :website_categories,
class_name: 'Communication::Website::Category', class_name: 'Communication::Website::Category',
dependent: :destroy dependent: :destroy
end end
def websites
@websites ||= university.websites.reject do |website|
website_concerned = false
# Site de formation
website_concerned = true if website.about == self
# Site d'école
if website.about&.is_a? Education::School
# Formation dispensée dans l'école
website_concerned = true if self.in? website.about.programs
end
!website_concerned
end
end
def set_websites_categories def set_websites_categories
websites.find_each(&:set_programs_categories!) websites.each { |website| website.set_programs_categories! }
end end
end end
...@@ -504,6 +504,23 @@ ActiveRecord::Schema.define(version: 2022_06_09_085535) do ...@@ -504,6 +504,23 @@ ActiveRecord::Schema.define(version: 2022_06_09_085535) do
t.index ["university_id"], name: "index_education_schools_on_university_id" t.index ["university_id"], name: "index_education_schools_on_university_id"
end 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 "imports", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| create_table "imports", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
t.integer "number_of_lines" t.integer "number_of_lines"
t.jsonb "processing_errors" t.jsonb "processing_errors"
...@@ -698,8 +715,8 @@ ActiveRecord::Schema.define(version: 2022_06_09_085535) do ...@@ -698,8 +715,8 @@ ActiveRecord::Schema.define(version: 2022_06_09_085535) do
t.string "linkedin" t.string "linkedin"
t.boolean "is_alumnus", default: false t.boolean "is_alumnus", default: false
t.text "description_short" t.text "description_short"
t.boolean "is_author"
t.string "name" t.string "name"
t.boolean "is_author"
t.integer "gender" t.integer "gender"
t.date "birthdate" t.date "birthdate"
t.string "phone_professional" t.string "phone_professional"
......
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