Skip to content

Commit b36d7da

Browse files
committed
WIP SacCas::PeopleManagersController, depends on hitobito/hitobito_youth#44
1 parent 00af957 commit b36d7da

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# frozen_string_literal: true
2+
3+
# Copyright (c) 2024, Schweizer Alpen-Club. This file is part of
4+
# hitobito_sac_cas and licensed under the Affero General Public License version 3
5+
# or later. See the COPYING file at the top-level directory or at
6+
# https://github.com/hitobito/hitobito_sac_cas
7+
8+
module SacCas::PeopleManagersController
9+
extend ActiveSupport::Concern
10+
11+
def create
12+
assign_attributes
13+
entry.transaction do
14+
if household.valid? && entry.save && household.persist!
15+
redirect_to redirect_to_path
16+
else
17+
render :new
18+
end
19+
end
20+
end
21+
22+
private
23+
24+
def household
25+
@household ||= build_household
26+
end
27+
28+
def build_household
29+
household_person, new_person = manager.household_key? ? [manager, managed] : [managed, manager]
30+
Person::Household.new(household_person, current_ability, new_person).assign
31+
end
32+
end

lib/hitobito_sac_cas/wagon.rb

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class Wagon < Rails::Engine
5353
Groups::SelfInscriptionController.prepend SacCas::Groups::SelfInscriptionController
5454
Groups::SelfRegistrationController.prepend SacCas::Groups::SelfRegistrationController
5555
PeopleController.prepend SacCas::PeopleController
56+
# TODO: depends on hitobito/hitobito_youth#44 # PeopleManagersController.prepend SacCas::PeopleManagersController
5657
Person::HistoryController.prepend SacCas::Person::HistoryController
5758

5859
Export::PeopleExportJob.prepend SacCas::Export::PeopleExportJob

0 commit comments

Comments
 (0)