Skip to content

Commit

Permalink
Correctly show trustees and votings menu (#9192)
Browse files Browse the repository at this point in the history
* Correctly show trustees menu

* Always show votings

* Fix voting permissions

* Refactor conditional logic
  • Loading branch information
josepjaume authored and andreslucena committed May 18, 2022
1 parent 8ad4ad8 commit 617300c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ def permissions
return permission_action unless user
return user_allowed_to_read_admin_dashboard? if read_admin_dashboard_action?
return permission_action unless permission_action.scope == :admin

user_can_enter_space_area?

return permission_action if voting && !voting.is_a?(Decidim::Votings::Voting)

unless user_can_read_votings_admin_dashboard?
disallow!
return permission_action
end

user_can_enter_space_area?
allowed_read_participatory_space?
allowed_voting_action?

Expand Down
5 changes: 4 additions & 1 deletion decidim-elections/lib/decidim/elections/admin_engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ def self.participatory_space_endpoints
next unless component

link = Decidim::EngineRouter.admin_proxy(component).trustees_path(locale: I18n.locale)

has_election_components = current_participatory_space.components.select { |c| c.manifest_name == "elections" }.any?

menu.add_item :trustees,
I18n.t("trustees", scope: "decidim.elections.admin.menu"),
link,
if: has_election_components && (allowed_to?(:manage, :trustees) || current_user.admin?),
position: 100,
if: allowed_to?(:manage, :trustees),
active: is_active_link?(link)
end
end
Expand Down

0 comments on commit 617300c

Please sign in to comment.