diff --git a/app/controllers/event/participation_contact_data/managed_controller.rb b/app/controllers/event/participation_contact_data/managed_controller.rb index dd19b6a4..4ba01d83 100644 --- a/app/controllers/event/participation_contact_data/managed_controller.rb +++ b/app/controllers/event/participation_contact_data/managed_controller.rb @@ -8,6 +8,8 @@ class Event::ParticipationContactData::ManagedController < Event::ParticipationContactDatasController + before_action :assert_feature_enabled + def update if any_duplicates? entry.errors.add(:base, :duplicates_present) if any_duplicates? @@ -44,4 +46,8 @@ def person_duplicate_finder def privacy_policy_param params[:event_participation_contact_datas_managed][:privacy_policy_accepted] end + + def assert_feature_enabled + FeatureGate.assert!('people.people_managers.self_service_managed_creation') + end end diff --git a/app/controllers/youth/event/register_controller.rb b/app/controllers/youth/event/register_controller.rb index 3d11c3a8..3d054c84 100644 --- a/app/controllers/youth/event/register_controller.rb +++ b/app/controllers/youth/event/register_controller.rb @@ -31,4 +31,8 @@ def contact_data_class_with_manager Event::ParticipationContactData end end + + def feature_enabled? + FeatureGate.enabled?('people.people_managers.self_service_managed_creation') + end end diff --git a/app/helpers/youth/dropdown/event/participant_add.rb b/app/helpers/youth/dropdown/event/participant_add.rb index a24bc58d..830ed3ce 100644 --- a/app/helpers/youth/dropdown/event/participant_add.rb +++ b/app/helpers/youth/dropdown/event/participant_add.rb @@ -69,7 +69,7 @@ def init_items_with_manageds(url_options) end end - if event.external_applications? + if register_new_managed? opts = url_options.merge(event_role: { type: event.participant_types.first.sti_name }) add_item( translate('.register_new_managed'), @@ -104,6 +104,11 @@ def participant_types_sub_items(opts) ::Dropdown::Item.new(translate(:as, role: type.label), link) end end + + def register_new_managed? + event.external_applications? && + FeatureGate.enabled?('people.people_managers.self_service_managed_creation') + end end end end diff --git a/app/views/event/register/_email_check.html.haml b/app/views/event/register/_email_check.html.haml index 10f93b17..e7ad9f64 100644 --- a/app/views/event/register/_email_check.html.haml +++ b/app/views/event/register/_email_check.html.haml @@ -13,5 +13,5 @@ = f.honeypot(:verification) = f.indented do = submit_button(f, t('.next')) - - FeatureGate.if('people.people_managers') do + - if FeatureGate.enabled?('people.people_managers') && FeatureGate.enabled?('people.people_managers.self_service_managed_creation') = submit_button(f, t('.next_for_manager'), formaction: register_group_event_path(group, event, manager: true)) diff --git a/config/settings.yml b/config/settings.yml index ac17edbe..2467b8d4 100644 --- a/config/settings.yml +++ b/config/settings.yml @@ -6,3 +6,5 @@ people: people_managers: enabled: true + self_service_managed_creation: + enabled: true diff --git a/spec/features/event_register_managed_spec.rb b/spec/features/event_register_managed_spec.rb index 613dc333..0beb93a9 100644 --- a/spec/features/event_register_managed_spec.rb +++ b/spec/features/event_register_managed_spec.rb @@ -34,6 +34,7 @@ before do allow(FeatureGate).to receive(:enabled?).with(:self_registration_reason).and_return(false) allow(FeatureGate).to receive(:enabled?).with('people.people_managers').and_return(false) + allow(FeatureGate).to receive(:enabled?).with('people.people_managers.self_service_managed_creation').and_return(true) end it 'does not show dropdown option for existing managed' do @@ -49,6 +50,7 @@ before do allow(FeatureGate).to receive(:enabled?).with(:self_registration_reason).and_return(false) allow(FeatureGate).to receive(:enabled?).with('people.people_managers').and_return(true) + allow(FeatureGate).to receive(:enabled?).with('people.people_managers.self_service_managed_creation').and_return(true) end it 'shows dropdown option for existing managed' do @@ -106,6 +108,7 @@ context 'with feature toggle disabled' do before do allow(FeatureGate).to receive(:enabled?).with(:self_registration_reason).and_return(false) + allow(FeatureGate).to receive(:enabled?).with('people.people_managers.self_service_managed_creation').and_return(true) allow(FeatureGate).to receive(:enabled?).with('people.people_managers').and_return(false) end @@ -120,6 +123,7 @@ before do allow(FeatureGate).to receive(:enabled?).with(:self_registration_reason).and_return(false) allow(FeatureGate).to receive(:enabled?).with('people.people_managers').and_return(true) + allow(FeatureGate).to receive(:enabled?).with('people.people_managers.self_service_managed_creation').and_return(true) end it 'shows invitation for existing managed' do @@ -159,6 +163,7 @@ before do allow(FeatureGate).to receive(:enabled?).with(:self_registration_reason).and_return(false) allow(FeatureGate).to receive(:enabled?).with('people.people_managers').and_return(false) + allow(FeatureGate).to receive(:enabled?).with('people.people_managers.self_service_managed_creation').and_return(true) end it 'does not show dropdown option for new managed' do @@ -174,6 +179,7 @@ before do allow(FeatureGate).to receive(:enabled?).with(:self_registration_reason).and_return(false) allow(FeatureGate).to receive(:enabled?).with('people.people_managers').and_return(true) + allow(FeatureGate).to receive(:enabled?).with('people.people_managers.self_service_managed_creation').and_return(true) end it 'shows dropdown option for new managed' do @@ -253,7 +259,7 @@ end def attrs_for_event_type(type) - attrs = { application_opening_at: 5.days.ago, groups: [group], globally_visible: false } + attrs = { application_opening_at: 5.days.ago, groups: [group], globally_visible: false, external_applications: true } case type when :course attrs.merge!(state: :application_open) diff --git a/spec/features/external_event_register_manager_spec.rb b/spec/features/external_event_register_manager_spec.rb index 747fbae8..d393199d 100644 --- a/spec/features/external_event_register_manager_spec.rb +++ b/spec/features/external_event_register_manager_spec.rb @@ -18,6 +18,7 @@ before do allow(FeatureGate).to receive(:enabled?).with('groups.self_registration').and_return(false) allow(FeatureGate).to receive(:enabled?).with('people.people_managers').and_return(false) + allow(FeatureGate).to receive(:enabled?).with('people.people_managers.self_service_managed_creation').and_return(true) allow_any_instance_of(FeatureGate).to receive(:enabled?).and_return(false) end @@ -33,6 +34,7 @@ allow(FeatureGate).to receive(:enabled?).with(:self_registration_reason).and_return(false) allow(FeatureGate).to receive(:enabled?).with('groups.self_registration').and_return(false) allow(FeatureGate).to receive(:enabled?).with('people.people_managers').and_return(true) + allow(FeatureGate).to receive(:enabled?).with('people.people_managers.self_service_managed_creation').and_return(true) allow_any_instance_of(FeatureGate).to receive(:enabled?).and_return(true) CustomContent.create!(key: 'views/devise/sessions/info', label: 'foo', body: 'dummy custom content has to be created because the youth wagon does not have built-in custom content fixtures') end