Skip to content

Commit

Permalink
Render J+S-related fields on participation
Browse files Browse the repository at this point in the history
Fixes #98
  • Loading branch information
carlobeltrame authored and TheWalkingLeek committed Feb 9, 2023
1 parent 4631cbe commit 76240f1
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/decorators/cevi/event/participation_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# frozen_string_literal: true

# Copyright (c) 2023, Pfadibewegung Schweiz. This file is part of
# hitobito_cevi 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_cevi.

module Cevi::Event::ParticipationDecorator
extend ActiveSupport::Concern

included do
delegate :ahv_number, :j_s_number, :nationality_j_s, to: :person
end
end
14 changes: 14 additions & 0 deletions app/views/event/participations/_application_details.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
- # frozen_string_literal: true
- # Copyright (c) 2023, CEVI Schweiz. This file is part of
- # hitobito_cevi 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_cevi.

= render_attrs(entry, :created_at)
- if @event.is_a?(Event::Course) && entry.state == 'canceled'
= render_attrs(entry, :canceled_at)
- if entry.states?
= render_attrs(entry, :state)

- if can?(:application_market, entry.event)
= render_attrs(entry, :ahv_number, :j_s_number, :nationality_j_s)
3 changes: 3 additions & 0 deletions config/locales/models.cevi.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,10 @@ de:
application_contact_id: Anmeldung an

event/participation:
ahv_number: AHV-Nummer
internal_comment: Interne Bemerkung
j_s_number: J+S-Nummer
nationality_j_s: Nationalität gemäss J+S
payed: Bezahlt

event/kind:
Expand Down
1 change: 1 addition & 0 deletions lib/hitobito_cevi/wagon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class Wagon < Rails::Engine
# decorators
PaperTrail::VersionDecorator.include Cevi::PaperTrail::VersionDecorator
PersonDecorator.include Cevi::PersonDecorator
Event::ParticipationDecorator.include Cevi::Event::ParticipationDecorator
end

initializer 'cevi.add_settings' do |_app|
Expand Down
35 changes: 35 additions & 0 deletions spec/decorators/event/participation_decorator_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# frozen_string_literal: true

# Copyright (c) 2023, CEVI Schweiz. This file is part of
# hitobito_cevi 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_cevi.

require 'spec_helper'

describe Event::ParticipationDecorator, :draper_with_helpers do

let(:person) { Fabricate(:person, first_name: 'John', last_name: 'Doe', nickname: nil, ahv_number: '756.1234.5678.97', j_s_number: '1234123', nationality_j_s: 'CH') }
let(:state) { 'applied' }
let(:participation) { Event::Participation.new(state: state, person: person, event: events(:top_course)) }
let(:decorator) { Event::ParticipationDecorator.new(participation) }

describe '#ahv_number' do
it 'delegates to person' do
expect(decorator.ahv_number).to eq(person.ahv_number)
end
end

describe '#j_s_number' do
it 'delegates to person' do
expect(decorator.j_s_number).to eq(person.j_s_number)
end
end

describe '#nationality_j_s' do
it 'delegates to person' do
expect(decorator.nationality_j_s).to eq(person.nationality_j_s)
end
end

end

0 comments on commit 76240f1

Please sign in to comment.