This way we can make the view code a bit easier to read. We're also changing the order of the conditions a little bit so we only check for the presence of a current user once. To make sure we aren't breaking anything with these changes, we're adding some tests. We're also replacing one system test checking content with a component test, since component tests are much faster.
63 lines
2.1 KiB
Plaintext
63 lines
2.1 KiB
Plaintext
<div class="votes">
|
|
<div class="in-favor inline-block">
|
|
<% if current_user %>
|
|
<%= link_to vote_debate_path(debate, value: "yes"),
|
|
class: "like #{voted_classes[:in_favor]}", title: t("votes.agree"), method: "post", remote: true do %>
|
|
<span class="icon-like">
|
|
<span class="show-for-sr"><%= t("votes.agree") %></span>
|
|
</span>
|
|
<span class="percentage"><%= votes_percentage("likes", debate) %></span>
|
|
<% end %>
|
|
<% else %>
|
|
<div class="like">
|
|
<span class="icon-like">
|
|
<span class="show-for-sr"><%= t("votes.agree") %></span>
|
|
</span>
|
|
<span class="percentage"><%= votes_percentage("likes", debate) %></span>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
|
|
<span class="divider"></span>
|
|
|
|
<div class="against inline-block">
|
|
<% if current_user %>
|
|
<%= link_to vote_debate_path(debate, value: "no"), class: "unlike #{voted_classes[:against]}", title: t("votes.disagree"), method: "post", remote: true do %>
|
|
<span class="icon-unlike">
|
|
<span class="show-for-sr"><%= t("votes.disagree") %></span>
|
|
</span>
|
|
<span class="percentage"><%= votes_percentage("dislikes", debate) %></span>
|
|
<% end %>
|
|
<% else %>
|
|
<div class="unlike">
|
|
<span class="icon-unlike">
|
|
<span class="show-for-sr"><%= t("votes.disagree") %></span>
|
|
</span>
|
|
<span class="percentage"><%= votes_percentage("dislikes", debate) %></span>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
|
|
<span class="total-votes">
|
|
<%= t("debates.debate.votes", count: debate.votes_score) %>
|
|
</span>
|
|
|
|
<% if !current_user %>
|
|
<div tabindex="0">
|
|
<%= render "shared/login_to_vote" %>
|
|
</div>
|
|
<% elsif organization? %>
|
|
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
|
|
<p>
|
|
<%= t("votes.organizations") %>
|
|
</p>
|
|
</div>
|
|
<% elsif !can_vote? %>
|
|
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
|
|
<p>
|
|
<%= sanitize(t("votes.anonymous", verify_account: link_to_verify_account)) %>
|
|
</p>
|
|
</div>
|
|
<% end %>
|
|
</div>
|