Files
nairobi/app/views/polls/_poll_subnav.html.erb
Javi Martín 864f750d92 Remove duplication in poll permissions
We were checking for `expired?` and `results_enabled?` in views and
helpers, when we've already defined a rule for accessing stats and
results for a poll.

This way we also fix a bug when stats were enabled but the poll wasn't
finished. In this scenario, the link pointed to the stats page, but when
clicking it we'd get a "you don't have permission" message.

Now the link doesn't point to the stats page anymore.
2019-11-09 19:33:02 +01:00

36 lines
1.1 KiB
Plaintext

<% if can?(:stats, @poll) || can?(:results, @poll) %>
<div class="row margin-top">
<div class="small-12 column">
<ul class="menu simple clear">
<% if can?(:results, @poll) %>
<% if results_menu? %>
<li class="is-active">
<h2><%= t("polls.show.results_menu") %></h2>
</li>
<% else %>
<li><%= link_to t("polls.show.results_menu"), results_poll_path(id: @poll.slug || @poll.id) %></li>
<% end %>
<% end %>
<% if can?(:stats, @poll) %>
<% if stats_menu? %>
<li class="is-active">
<h2><%= t("polls.show.stats_menu") %></h2>
</li>
<% else %>
<li><%= link_to t("polls.show.stats_menu"), stats_poll_path(id: @poll.slug || @poll.id) %></li>
<% end %>
<% end %>
<% if info_menu? %>
<li class="is-active">
<h2><%= t("polls.show.info_menu") %></h2>
</li>
<% else %>
<li><%= link_to t("polls.show.info_menu"), poll_path(id: @poll.slug || @poll.id) %></li>
<% end %>
</ul>
</div>
</div>
<% end %>