From bd3b00da82dfee26e21fb056f744da08123c6de7 Mon Sep 17 00:00:00 2001 From: Arnaud Levy <contact@arnaudlevy.com> Date: Wed, 16 Feb 2022 12:31:12 +0100 Subject: [PATCH] websites for lab --- app/models/education/school.rb | 35 ++++++++++++++++++------------- app/models/research/laboratory.rb | 6 +++++- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/app/models/education/school.rb b/app/models/education/school.rb index 36a5c2924..092cee5da 100644 --- a/app/models/education/school.rb +++ b/app/models/education/school.rb @@ -26,26 +26,33 @@ class Education::School < ApplicationRecord include WithGit - belongs_to :university - has_many :websites, class_name: 'Communication::Website', as: :about, dependent: :nullify + belongs_to :university + has_many :websites, + class_name: 'Communication::Website', + as: :about, + dependent: :nullify + has_many :university_roles, + class_name: 'University::Role', + as: :target, + dependent: :destroy + has_many :involvements_through_roles, + through: :university_roles, + source: :involvements + has_many :university_people_through_role_involvements, + through: :involvements_through_roles, + source: :person + has_many :university_people_through_program_involvements, + through: :programs, + source: :university_people_through_involvements + has_many :university_people_through_program_role_involvements, + through: :programs, + source: :university_people_through_role_involvements has_and_belongs_to_many :programs, class_name: 'Education::Program', join_table: 'education_programs_schools', foreign_key: 'education_school_id', association_foreign_key: 'education_program_id' - has_many :university_roles, class_name: 'University::Role', as: :target, dependent: :destroy - has_many :involvements_through_roles, through: :university_roles, source: :involvements - has_many :university_people_through_role_involvements, - through: :involvements_through_roles, - source: :person - has_many :university_people_through_program_involvements, - through: :programs, - source: :university_people_through_involvements - has_many :university_people_through_program_role_involvements, - through: :programs, - source: :university_people_through_role_involvements - validates :name, :address, :city, :zipcode, :country, presence: true scope :ordered, -> { order(:name) } diff --git a/app/models/research/laboratory.rb b/app/models/research/laboratory.rb index 490f01747..8f64eaed5 100644 --- a/app/models/research/laboratory.rb +++ b/app/models/research/laboratory.rb @@ -24,8 +24,12 @@ class Research::Laboratory < ApplicationRecord include WithGit belongs_to :university + has_many :websites, + class_name: 'Communication::Website', + as: :about, + dependent: :nullify has_many :axes, - class_name: "Research::Laboratory::Axis", + class_name: 'Research::Laboratory::Axis', foreign_key: :research_laboratory_id, dependent: :destroy -- GitLab