diff --git a/app/models/pbs/event.rb b/app/models/pbs/event.rb index d9eb60adc..985a4fc0d 100644 --- a/app/models/pbs/event.rb +++ b/app/models/pbs/event.rb @@ -13,6 +13,9 @@ module Pbs::Event included do class_attribute :superior_attributes self.superior_attributes = [] + + # dummy accessors for event_resource (only courses do have advisor) + attr_accessor :advisor_id, :advisor end def camp_submitted? diff --git a/app/resources/pbs/event_resource.rb b/app/resources/pbs/event_resource.rb new file mode 100644 index 000000000..88db798d3 --- /dev/null +++ b/app/resources/pbs/event_resource.rb @@ -0,0 +1,19 @@ +# frozen_string_literal: true + +# Copyright (c) 2024, Pfadibewegung Schweiz. This file is part of +# hitobito_pbs and licensed under the Affero General Public License version 3 +# or later. See the COPYING file at the top-level directory or at +# https://github.com/hitobito/hitobito_pbs. + +module Pbs::EventResource + extend ActiveSupport::Concern + + included do + attribute :advisor_id, :integer, writable: false, sortable: false + belongs_to :advisor, resource: PersonResource, writable: false, foreign_key: :advisor_id do + assign do |_event, _person| + # nothing + end + end + end +end diff --git a/lib/hitobito_pbs/wagon.rb b/lib/hitobito_pbs/wagon.rb index c017dcb6b..bf6e2602a 100644 --- a/lib/hitobito_pbs/wagon.rb +++ b/lib/hitobito_pbs/wagon.rb @@ -147,6 +147,10 @@ class Wagon < Rails::Engine DeviseController.include HostnamedGroups + ### resources + + EventResource.include Pbs::EventResource + ### sheets Sheet::Group.include Pbs::Sheet::Group Sheet::Event.include Pbs::Sheet::Event