diff --git a/app/controllers/admin/education/program/role/people_controller.rb b/app/controllers/admin/education/program/role/people_controller.rb index 8a606f4dc1ca9f1279ead3828c123305edbd8ca3..945c7725983ec1046b5784e3a3fae3979783ad58 100644 --- a/app/controllers/admin/education/program/role/people_controller.rb +++ b/app/controllers/admin/education/program/role/people_controller.rb @@ -2,7 +2,9 @@ class Admin::Education::Program::Role::PeopleController < Admin::Education::Prog load_and_authorize_resource :role, class: University::Role, through: :program, param: :role_id, through_association: :university_roles load_and_authorize_resource :involvement, class: University::Person::Involvement, through: :role, parent: false - before_action :get_available_people, except: :destroy + include Admin::Reorderable + + before_action :get_available_people, except: [:reorder, :destroy] def new breadcrumb @@ -59,4 +61,8 @@ class Admin::Education::Program::Role::PeopleController < Admin::Education::Prog .permit(:description, :position, :person_id) .merge(university_id: @program.university_id, kind: :administrator) end + + def model + University::Person::Involvement + end end diff --git a/app/controllers/admin/education/program/roles_controller.rb b/app/controllers/admin/education/program/roles_controller.rb index 48b07bba4384ca59428331592ba05ec9ead8149b..5827579b898897e50e840e0730087bc05ae6b149 100644 --- a/app/controllers/admin/education/program/roles_controller.rb +++ b/app/controllers/admin/education/program/roles_controller.rb @@ -3,10 +3,6 @@ class Admin::Education::Program::RolesController < Admin::Education::Program::Ap include Admin::Reorderable - def reorder - super { |first_role| first_role.sync_program } - end - def show @involvements = @role.involvements.ordered breadcrumb @@ -61,4 +57,8 @@ class Admin::Education::Program::RolesController < Admin::Education::Program::Ap .permit(:description, :position) .merge(target: @program, university_id: current_university.id) end + + def model + University::Role + end end diff --git a/app/controllers/admin/education/program/teachers_controller.rb b/app/controllers/admin/education/program/teachers_controller.rb index c26bde871c0849f7f36c31df03eea74df56d61c4..43d532c639ec9654c10c2fd4e8e9e6bb533499c7 100644 --- a/app/controllers/admin/education/program/teachers_controller.rb +++ b/app/controllers/admin/education/program/teachers_controller.rb @@ -5,7 +5,9 @@ class Admin::Education::Program::TeachersController < Admin::Education::Program: through_association: :university_person_involvements, parent: false - before_action :get_available_people, except: :destroy + include Admin::Reorderable + + before_action :get_available_people, except: [:reorder, :destroy] def new breadcrumb @@ -61,4 +63,8 @@ class Admin::Education::Program::TeachersController < Admin::Education::Program: .permit(:description, :position, :person_id) .merge(university_id: @program.university_id, kind: :teacher) end + + def model + University::Person::Involvement + end end diff --git a/app/controllers/admin/education/school/role/people_controller.rb b/app/controllers/admin/education/school/role/people_controller.rb index c1747a9dc8d851f71ac4f597c1c8e19f6d85b18c..71358f1dd4e95bf69452383c9b04d1a58cc85bf5 100644 --- a/app/controllers/admin/education/school/role/people_controller.rb +++ b/app/controllers/admin/education/school/role/people_controller.rb @@ -2,7 +2,9 @@ class Admin::Education::School::Role::PeopleController < Admin::Education::Schoo load_and_authorize_resource :role, class: University::Role, through: :school, param: :role_id, through_association: :university_roles load_and_authorize_resource :involvement, class: University::Person::Involvement, through: :role, parent: false - before_action :get_available_people, except: :destroy + include Admin::Reorderable + + before_action :get_available_people, except: [:reorder, :destroy] def new breadcrumb @@ -59,4 +61,8 @@ class Admin::Education::School::Role::PeopleController < Admin::Education::Schoo .permit(:description, :position, :person_id) .merge(university_id: @school.university_id, kind: :administrator) end + + def model + University::Person::Involvement + end end diff --git a/app/controllers/admin/education/school/roles_controller.rb b/app/controllers/admin/education/school/roles_controller.rb index 6e0633b1b626453a6695217d05cd89fd5cdd940e..09d108e7f0cc50dd4441b4438e189cabfe2f1d63 100644 --- a/app/controllers/admin/education/school/roles_controller.rb +++ b/app/controllers/admin/education/school/roles_controller.rb @@ -1,7 +1,10 @@ class Admin::Education::School::RolesController < Admin::Education::School::ApplicationController load_and_authorize_resource class: University::Role, through: :school, through_association: :university_roles + include Admin::Reorderable + def index + @roles = @roles.ordered breadcrumb end @@ -59,4 +62,8 @@ class Admin::Education::School::RolesController < Admin::Education::School::Appl .permit(:description, :position) .merge(target: @school, university_id: @school.university_id) end + + def model + University::Role + end end diff --git a/app/models/university/person/involvement.rb b/app/models/university/person/involvement.rb index d555cccbc012d2f623fa4e27be461cfd32c7dd47..f2c8f6c28cd299ab7643f7b8e16652064e81aa78 100644 --- a/app/models/university/person/involvement.rb +++ b/app/models/university/person/involvement.rb @@ -33,19 +33,19 @@ class University::Person::Involvement < ApplicationRecord belongs_to :person belongs_to :target, polymorphic: true - after_commit :sync_target + after_commit :sync_with_git def to_s "#{person}" end + def sync_with_git + target.sync_with_git if target.respond_to? :sync_with_git + end + protected def last_ordered_element self.class.unscoped.where(university_id: university_id, target: target).ordered.last end - - def sync_target - target.sync_with_git - end end diff --git a/app/models/university/role.rb b/app/models/university/role.rb index 2e4987077a6a12d1636514fb28a83ea95a7fdd3b..a128dbb4f933aec223c5b773dc34eda304b30030 100644 --- a/app/models/university/role.rb +++ b/app/models/university/role.rb @@ -32,7 +32,7 @@ class University::Role < ApplicationRecord end def sync_with_git - target.sync_with_git + target.sync_with_git if target&.respond_to? :sync_with_git end protected