diff --git a/app/models/education/program/role.rb b/app/models/education/program/role.rb index d79798d0670750128e13cd299656cdf71e3c0619..1f9113f5e53033a91fa972fe56e24a68580306cc 100644 --- a/app/models/education/program/role.rb +++ b/app/models/education/program/role.rb @@ -28,6 +28,8 @@ class Education::Program::Role < ApplicationRecord has_many :people, class_name: 'Education::Program::Role::Person', dependent: :destroy has_many :university_people, through: :people, source: :person + after_commit :sync_program + def to_s "#{title}" end @@ -37,4 +39,8 @@ class Education::Program::Role < ApplicationRecord def last_ordered_element program.roles.ordered.last end + + def sync_program + program.sync_with_git + end end diff --git a/app/models/education/program/role/person.rb b/app/models/education/program/role/person.rb index f61f1d20ff98b9b25167825d552f6a91768f83a0..648a7ffb600aea8a560540ede4ce6f06280d4f44 100644 --- a/app/models/education/program/role/person.rb +++ b/app/models/education/program/role/person.rb @@ -24,6 +24,9 @@ class Education::Program::Role::Person < ApplicationRecord belongs_to :person, class_name: 'University::Person' belongs_to :role, class_name: 'Education::Program::Role' + delegate :program, to: :role + + after_commit :sync_program def to_s person.to_s @@ -34,4 +37,8 @@ class Education::Program::Role::Person < ApplicationRecord def last_ordered_element role.people.ordered.last end + + def sync_program + program.sync_with_git + end end diff --git a/app/models/education/program/teacher.rb b/app/models/education/program/teacher.rb index 2a85d592810b94c587411e09d6f8374f22b27d56..bed1c1afdc241e79a9162d63a8ad020b85a7a695 100644 --- a/app/models/education/program/teacher.rb +++ b/app/models/education/program/teacher.rb @@ -27,7 +27,15 @@ class Education::Program::Teacher < ApplicationRecord scope :ordered, -> { joins(:person).order('university_people.last_name, university_people.first_name') } + after_commit :sync_program + def to_s person.to_s end + + protected + + def sync_program + program.sync_with_git + end end