Skip to content

Commit

Permalink
Merge pull request #2101 from hitobito/feature/1969_register_new_managed
Browse files Browse the repository at this point in the history
Allow using different contact data class for inheriting controllers
  • Loading branch information
carlobeltrame committed May 12, 2023
2 parents 6b5f767 + 4e403fa commit e50729a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions app/controllers/event/participation_contact_datas_controller.rb
Expand Up @@ -44,18 +44,26 @@ def entry
end

def build_entry
Event::ParticipationContactData.new(event, person)
contact_data_class.new(event, person)
end

def set_entry
@participation_contact_data =
if params[:event_participation_contact_data]
Event::ParticipationContactData.new(event, person, model_params)
if params[model_identifier]
contact_data_class.new(event, person, model_params)
else
build_entry
end
end

def model_identifier
contact_data_class.to_s.underscore.gsub('/', '_')
end

def contact_data_class
Event::ParticipationContactData
end

def event
@event ||= Event.find(params[:event_id])
end
Expand All @@ -65,7 +73,7 @@ def group
end

def model_params
params.require('event_participation_contact_data').permit(permitted_attrs)
params.require(model_identifier).permit(permitted_attrs)
end

def permitted_attrs
Expand Down

0 comments on commit e50729a

Please sign in to comment.