Group code for the poll callout together
Some of the code was in its own component, while some of the code remained in the polls/show view. Note that we're re-structuring the code a little bit, so it's clear that the "already voted" messages are only shown when users can vote. Also note that now the `can?` condition involves the existence of a `current_user` and that the poll is not expired, so we can simplify the `voted_in_web` condition.
This commit is contained in:
@@ -1,4 +1,14 @@
|
||||
<% unless can?(:answer, poll) %>
|
||||
<% if can?(:answer, poll) %>
|
||||
<% if poll.voted_in_booth?(current_user) %>
|
||||
<div class="callout warning">
|
||||
<%= t("polls.show.already_voted_in_booth") %>
|
||||
</div>
|
||||
<% elsif poll.voted_in_web?(current_user) %>
|
||||
<div class="callout warning">
|
||||
<%= t("polls.show.already_voted_in_web") %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<% if current_user.nil? %>
|
||||
<div class="callout primary">
|
||||
<%= sanitize(t("polls.show.cant_answer_not_logged_in",
|
||||
|
||||
@@ -17,20 +17,6 @@
|
||||
<div class="row margin">
|
||||
<div class="small-12 medium-9 column">
|
||||
<%= render Polls::CalloutComponent.new(@poll) %>
|
||||
|
||||
<% if @poll.voted_in_booth?(current_user) %>
|
||||
<div class="callout warning">
|
||||
<%= t("polls.show.already_voted_in_booth") %>
|
||||
</div>
|
||||
<% else %>
|
||||
|
||||
<% if current_user && @poll.voted_in_web?(current_user) && !@poll.expired? %>
|
||||
<div class="callout warning">
|
||||
<%= t("polls.show.already_voted_in_web") %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= render Polls::FormComponent.new(@web_vote) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user