diff --git a/app/abilities/cevi/event/application_ability.rb b/app/abilities/cevi/event/application_ability.rb new file mode 100644 index 0000000..4964a15 --- /dev/null +++ b/app/abilities/cevi/event/application_ability.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +# Copyright (c) 2023, CEVI Regionalverband ZH-SH-GL. 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::ApplicationAbility + extend ActiveSupport::Concern + + included do + on(Event::Application) do + permission(:any).may(:approve).if_manage_attendances_in_event + end + end + + def if_manage_attendances_in_event + permission_in_event?(:manage_attendances) + end + +end diff --git a/app/abilities/cevi/event/participation_ability.rb b/app/abilities/cevi/event/participation_ability.rb index 4182d2e..1b69813 100644 --- a/app/abilities/cevi/event/participation_ability.rb +++ b/app/abilities/cevi/event/participation_ability.rb @@ -17,9 +17,17 @@ module Cevi::Event::ParticipationAbility permission(:layer_and_below_read). may(:show). in_same_layer_or_below_if_ausbildungsmitglied + + permission(:any). + may(:create). + if_manage_attendances_in_event_or_her_own_if_application_possible end end + def if_manage_attendances_in_event_or_her_own_if_application_possible + permission_in_event?(:manage_attendances) || her_own_if_application_possible + end + def person_in_same_layer_or_below person.nil? || permission_in_layers?(person.groups_hierarchy_ids) end diff --git a/lib/hitobito_cevi/wagon.rb b/lib/hitobito_cevi/wagon.rb index a825460..425567e 100644 --- a/lib/hitobito_cevi/wagon.rb +++ b/lib/hitobito_cevi/wagon.rb @@ -44,6 +44,7 @@ class Wagon < Rails::Engine RoleAbility.include Cevi::RoleAbility VariousAbility.include Cevi::VariousAbility Event::ParticipationAbility.include Cevi::Event::ParticipationAbility + Event::ApplicationAbility.include Cevi::Event::ApplicationAbility PersonReadables.include Cevi::PersonReadables PersonLayerWritables.include Cevi::PersonLayerWritables AbilityDsl::Base.include Cevi::AbilityDsl::Base