diff --git a/app/models/education/diploma.rb b/app/models/education/diploma.rb index f268217ca99fa031038e4b8bc02a9ad882c251a8..cdbb4aef7261d6a3b0114f81078c919e171d80e2 100644 --- a/app/models/education/diploma.rb +++ b/app/models/education/diploma.rb @@ -49,15 +49,27 @@ class Education::Diploma < ApplicationRecord } end + def published_programs_for_website(website) + website.education_programs.published.where(diploma: self) + end + # We need to send the diplomas only to the websites that need them def for_website?(website) - website.education_programs.published.where(diploma: self).any? + published_programs_for_website(website).any? end def git_path(website) "content/diplomas/#{slug}/_index.html" end + def git_dependencies(website) + published_programs = published_programs_for_website(website) + + dependencies = [self] + dependencies += published_programs + published_programs.map(&:active_storage_blobs).flatten if published_programs.any? + dependencies + end + def to_s "#{name}" end diff --git a/app/models/education/program.rb b/app/models/education/program.rb index 5b7465455a77166f21875d864c3c1b3918735da2..ec001f173341c6854b6033dcdfb165c6ff764bff 100644 --- a/app/models/education/program.rb +++ b/app/models/education/program.rb @@ -210,7 +210,8 @@ class Education::Program < ApplicationRecord university_people_through_role_involvements + university_people_through_role_involvements.map(&:active_storage_blobs).flatten + university_people_through_role_involvements.map(&:administrator) + - website.menus + website.menus + + [diploma] end def git_destroy_dependencies(website)