Skip to content

Commit

Permalink
Allow Abteilungsleitungen to view past members
Browse files Browse the repository at this point in the history
  • Loading branch information
carlobeltrame committed Aug 23, 2021
1 parent 507c346 commit 941e542
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
9 changes: 9 additions & 0 deletions app/abilities/pbs/group_ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ module Pbs::GroupAbility
may(:remind_census, :update_member_counts, :delete_member_counts).
in_same_layer_or_below_if_leader

permission(:layer_and_below_full).
may(:show_past_members).
if_abteilungsleitung_in_layer

permission(:approve_applications).may(:index_pending_approvals).if_layer_and_in_same_group

permission(:any).may(:'index_event/camps').all
Expand All @@ -48,6 +52,11 @@ def if_mitarbeiter_gs
role_type?(Group::Bund::MitarbeiterGs)
end

def if_abteilungsleitung_in_layer
in_same_layer_or_below &&
role_type?(Group::Abteilung::Abteilungsleitung, Group::Abteilung::AbteilungsleitungStv)
end

def if_layer_and_in_same_group
if_layer_group && user.groups_with_permission(permission).map(&:id).include?(group.id)
end
Expand Down
15 changes: 8 additions & 7 deletions app/decorators/pbs/person_decorator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ def roles_grouped

private

def layer_group_ids
@layer_group_ids ||= current_user.layer_group_ids
end
def layer_group_ids
@layer_group_ids ||= current_user.layer_group_ids
end

def visible_roles
@visible_roles ||= roles.select do |role|
layer_group_ids.include?(role.group.layer_group_id) || role.visible_from_above
end
def visible_roles
@visible_roles ||= roles_with_deleted.select do |role|
(layer_group_ids.include?(role.group.layer_group_id) || role.visible_from_above) &&
(!role.deleted? || can?(:show_past_members, role.group))
end
end

end

0 comments on commit 941e542

Please sign in to comment.