diff --git a/app/models/communication/website/with_abouts.rb b/app/models/communication/website/with_abouts.rb index 570c59f6f9fbb1a2c2791ee57269a347a90dbef5..90a8cc6e08ec75df3be688a915e5d2985b3b38a7 100644 --- a/app/models/communication/website/with_abouts.rb +++ b/app/models/communication/website/with_abouts.rb @@ -66,8 +66,8 @@ module Communication::Website::WithAbouts @people ||= begin people = authors if about_school? - people += about.university_people_through_teachers - people += about.university_people_through_administrators + people += about.university_people_through_involvements + people += about.university_people_through_roles elsif about_journal? people += about.people end @@ -79,10 +79,10 @@ module Communication::Website::WithAbouts @people_with_facets ||= begin people = authors + authors.compact.map(&:author) if about_school? - people += about.university_people_through_teachers - people += about.university_people_through_teachers.map(&:teacher) - people += about.university_people_through_administrators - people += about.university_people_through_administrators.map(&:administrator) + people += about.university_people_through_involvements + people += about.university_people_through_involvements.map(&:teacher) + people += about.university_people_through_roles + people += about.university_people_through_roles.map(&:administrator) elsif about_journal? people += about.people people += about.people.map(&:researcher) diff --git a/app/models/education/program.rb b/app/models/education/program.rb index 735de588853b0b9468e43fbc94f2392e17c61358..fcebaba4a12d4c518df1072ab526faef2c2810ac 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -83,13 +83,18 @@ class Education::Program < ApplicationRecord as: :target, dependent: :destroy has_many :involvements_through_roles, - class_name: 'University::Person::Involvement', through: :university_roles, source: :involvements + has_many :university_people_through_role_involvements, + through: :involvements_through_roles, + source: :person has_many :university_person_involvements, class_name: 'University::Person::Involvement', as: :target, dependent: :destroy + has_many :university_people_through_involvements, + through: :university_person_involvements, + source: :person has_many :website_categories, class_name: 'Communication::Website::Category', dependent: :destroy @@ -134,10 +139,12 @@ class Education::Program < ApplicationRecord def git_dependencies(website) [self] + active_storage_blobs + - university_people_through_teachers + - university_people_through_teachers.map(&:teacher) + - university_people_through_roles - # TODO: les administrative via roles + university_people_through_involvements + + university_people_through_involvements.map(&:active_storage_blobs) + + university_people_through_involvements.map(&:teacher) + + university_people_through_role_involvements + + university_people_through_role_involvements.map(&:active_storage_blobs) + + university_people_through_role_involvements.map(&:administrator) end def git_destroy_dependencies(website) diff --git a/app/models/education/school.rb b/app/models/education/school.rb index 03f46b569164c4950e3b96da5f9e6aeef4f9c156..4859bc521b2d5bd25da19ccf6d0ab3c5136fdda6 100644 --- a/app/models/education/school.rb +++ b/app/models/education/school.rb @@ -33,10 +33,6 @@ class Education::School < ApplicationRecord -> { distinct }, through: :administrators, source: :person - has_many :university_roles, class_name: 'University::Role', as: :target, dependent: :destroy - has_many :university_people_through_roles, - through: :university_roles, - source: :person has_and_belongs_to_many :programs, class_name: 'Education::Program', join_table: 'education_programs_schools', @@ -48,6 +44,12 @@ class Education::School < ApplicationRecord through: :teachers, source: :person + 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_involvements, + through: :involvements_through_roles, + source: :person + validates :name, :address, :city, :zipcode, :country, presence: true scope :ordered, -> { order(:name) } @@ -62,7 +64,7 @@ class Education::School < ApplicationRecord def git_dependencies(website) [self] + - university_people_through_administrators + - university_people_through_administrators.map(&:administrator) + university_people_through_involvements + + university_people_through_involvements.map(&:administrator) end end diff --git a/app/models/research/journal.rb b/app/models/research/journal.rb index b7badad3e8771f298b035ad2c24e91ba9a659c74..f4f6fc15f97fa17618ec065c2abfd9d7a57110ff 100644 --- a/app/models/research/journal.rb +++ b/app/models/research/journal.rb @@ -40,7 +40,7 @@ class Research::Journal < ApplicationRecord end def git_dependencies(website) - [self] + articles + volumes + people + people.map(&:researcher) + [self] + articles + volumes + people + people.map(&:active_storage_blobs).flatten + people.map(&:researcher) end def git_destroy_dependencies(website) diff --git a/app/models/research/journal/article.rb b/app/models/research/journal/article.rb index 5617202477cb2a9af6cf8e85dd15d144a276b35b..1d899b51a97105eefebe45a66a5650d1c0273489 100644 --- a/app/models/research/journal/article.rb +++ b/app/models/research/journal/article.rb @@ -66,6 +66,7 @@ class Research::Journal::Article < ApplicationRecord active_storage_blobs + other_articles_in_the_volume + people + + people.map(&:active_storage_blobs).flatten + people.map(&:researcher) end diff --git a/app/models/research/journal/volume.rb b/app/models/research/journal/volume.rb index 80c1fb01f42f15b0b67f75d08389b31b3064f273..2fd9f3340c764a5b79c176647d99386b59a907f4 100644 --- a/app/models/research/journal/volume.rb +++ b/app/models/research/journal/volume.rb @@ -51,7 +51,7 @@ class Research::Journal::Volume < ApplicationRecord end def git_dependencies(website) - [self] + articles + people + people.map(&:researcher) + active_storage_blobs + [self] + articles + people + people.map(&:active_storage_blobs).flatten + people.map(&:researcher) + active_storage_blobs end def git_destroy_dependencies(website) diff --git a/app/models/university/person.rb b/app/models/university/person.rb index 69f326d06be73874fe0b8ed872cc86b11b028f06..3b36941df589c9f4337ec8d7cf8d534539aa0d7b 100644 --- a/app/models/university/person.rb +++ b/app/models/university/person.rb @@ -120,7 +120,7 @@ class University::Person < ApplicationRecord dependencies = [] if for_website?(website) dependencies << self - dependencies << best_picture.blob + dependencies.concat active_storage_blobs end dependencies << administrator if administrator.for_website?(website) dependencies << author if author.for_website?(website) diff --git a/app/models/university/person/involvement.rb b/app/models/university/person/involvement.rb index f2c8f6c28cd299ab7643f7b8e16652064e81aa78..9da1b3c05276d4f79e2288ca667ae7c649da26b8 100644 --- a/app/models/university/person/involvement.rb +++ b/app/models/university/person/involvement.rb @@ -30,7 +30,7 @@ class University::Person::Involvement < ApplicationRecord enum kind: { administrator: 10, researcher: 20, teacher: 30 } belongs_to :university - belongs_to :person + belongs_to :person, class_name: 'University::Person' belongs_to :target, polymorphic: true after_commit :sync_with_git diff --git a/app/models/university/role.rb b/app/models/university/role.rb index a128dbb4f933aec223c5b773dc34eda304b30030..befa1d6c7ef5460c4ff0988a934f32499169ff3b 100644 --- a/app/models/university/role.rb +++ b/app/models/university/role.rb @@ -25,7 +25,8 @@ class University::Role < ApplicationRecord belongs_to :university belongs_to :target, polymorphic: true, optional: true - has_many :involvements, class_name: 'University::Person::Involvement', as: :target + has_many :involvements, class_name: 'University::Person::Involvement', as: :target, dependent: :destroy + has_many :people, through: :involvements def to_s "#{description}" diff --git a/app/views/admin/education/programs/static.html.erb b/app/views/admin/education/programs/static.html.erb index 505c7a206bfa7aefb738391ca926a37e7660a1e7..326cede3db8657ba91847fe51a1c10e993fcea17 100644 --- a/app/views/admin/education/programs/static.html.erb +++ b/app/views/admin/education/programs/static.html.erb @@ -11,21 +11,21 @@ image_alt: "<%= @program.featured_image_alt %>" <% end %> category: "<%= @website.categories.find_by(program_id: @program.id)&.path %>/" teachers: -<% @program.teachers.includes(:person).ordered.each do |teacher| %> - - "<%= teacher.person.slug %>" +<% @program.university_person_involvements.includes(:person).ordered.each do |involvement| %> + - "<%= involvement.person.slug %>" <% end %> teachers_description: -<% @program.teachers.includes(:person).ordered.each do |teacher| %> - "<%= teacher.person.slug %>": > - <%= teacher.best_description %> +<% @program.university_person_involvements.includes(:person).ordered.each do |involvement| %> + "<%= involvement.person.slug %>": > + <%= involvement.description %> <% end %> roles: -<% @program.roles.ordered.each do |role| %> +<% @program.university_roles.ordered.each do |role| %> - title: > <%= role.to_s %> persons: - <% role.people.includes(:person).ordered.each do |role_person| %> - - "<%= role_person.person.slug %>" + <% role.involvements.includes(:person).ordered.each do |involvement| %> + - "<%= involvement.person.slug %>" <% end %> <% end %> continuing: <%= @program.continuing %> diff --git a/app/views/admin/education/schools/static.html.erb b/app/views/admin/education/schools/static.html.erb index 800d8c5b1c974e925f1adff080b1b4a7a612fbbe..f750e28fa8434b1ba45967b28aa2e74a58e9f129 100644 --- a/app/views/admin/education/schools/static.html.erb +++ b/app/views/admin/education/schools/static.html.erb @@ -12,12 +12,12 @@ country: > phone: > <%= @school.phone %> administrators: -<% @school.administrators.includes(:person).ordered.each do |administrator| %> - - "<%= administrator.person.slug %>" +<% @school.involvements_through_roles.includes(:person).ordered.each do |involvement| %> + - "<%= involvement.person.slug %>" <% end %> administrators_description: -<% @school.administrators.includes(:person).ordered.each do |administrator| %> - "<%= administrator.person.slug %>": > - <%= administrator.best_description %> +<% @school.involvements_through_roles.includes(:person).ordered.each do |involvement| %> + "<%= involvement.person.slug %>": > + <%= involvement.best_description %> <% end %> ---