Files
nairobi/app/views/debates/_votes.html.erb
2019-09-10 20:02:15 +02:00

69 lines
2.5 KiB
Plaintext

<% voted_classes = css_classes_for_vote(@debate_votes, debate) %>
<div class="votes">
<div class="in-favor inline-block">
<% if user_signed_in? %>
<%= 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 user_signed_in? %>
<%= 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 user_signed_in? && current_user.organization? %>
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
<p>
<%= t("votes.organizations") %>
</p>
</div>
<% elsif user_signed_in? && !debate.votable_by?(current_user) %>
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
<p>
<%= t("votes.anonymous",
verify_account: link_to(t("votes.verify_account"), verification_path )).html_safe %>
</p>
</div>
<% elsif !user_signed_in? %>
<div tabindex="0">
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
<%= t("votes.unauthenticated",
signin: link_to(t("votes.signin"), new_user_session_path),
signup: link_to(t("votes.signup"), new_user_registration_path)).html_safe %>
</div>
</div>
<% end %>
</div>