Skip to content

Commit

Permalink
Add advisor relation
Browse files Browse the repository at this point in the history
  • Loading branch information
simfeld committed Apr 12, 2024
1 parent 964d77e commit 8fa79ff
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/models/pbs/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
19 changes: 19 additions & 0 deletions app/resources/pbs/event_resource.rb
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions lib/hitobito_pbs/wagon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 8fa79ff

Please sign in to comment.