Use current user in votes components
Just like we do in most places; we almost never use `user_signed_in?`.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<% voted_classes = css_classes_for_vote(debate) %>
|
||||
<div class="votes">
|
||||
<div class="in-favor inline-block">
|
||||
<% if user_signed_in? %>
|
||||
<% 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">
|
||||
@@ -22,7 +22,7 @@
|
||||
<span class="divider"></span>
|
||||
|
||||
<div class="against inline-block">
|
||||
<% if user_signed_in? %>
|
||||
<% 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>
|
||||
@@ -43,19 +43,19 @@
|
||||
<%= t("debates.debate.votes", count: debate.votes_score) %>
|
||||
</span>
|
||||
|
||||
<% if user_signed_in? && current_user.organization? %>
|
||||
<% if 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) %>
|
||||
<% elsif current_user && !debate.votable_by?(current_user) %>
|
||||
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
|
||||
<p>
|
||||
<%= sanitize(t("votes.anonymous", verify_account: link_to_verify_account)) %>
|
||||
</p>
|
||||
</div>
|
||||
<% elsif !user_signed_in? %>
|
||||
<% elsif !current_user %>
|
||||
<div tabindex="0">
|
||||
<%= render "shared/login_to_vote" %>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class Debates::VotesComponent < ApplicationComponent
|
||||
attr_reader :debate
|
||||
delegate :css_classes_for_vote, :current_user, :link_to_verify_account, :user_signed_in?, :votes_percentage, to: :helpers
|
||||
delegate :css_classes_for_vote, :current_user, :link_to_verify_account, :votes_percentage, to: :helpers
|
||||
|
||||
def initialize(debate)
|
||||
@debate = debate
|
||||
|
||||
Reference in New Issue
Block a user