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,5 +1,5 @@
|
|||||||
<div class="votes">
|
<div class="votes">
|
||||||
<% if user_signed_in? %>
|
<% if current_user %>
|
||||||
<%= t("comments.comment.votes", count: comment.total_votes) %>
|
<%= t("comments.comment.votes", count: comment.total_votes) %>
|
||||||
|
|
|
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
<%= comment.total_dislikes %>
|
<%= comment.total_dislikes %>
|
||||||
</span>
|
</span>
|
||||||
<% elsif !user_signed_in? %>
|
<% else %>
|
||||||
<div class="participation-allowed">
|
<div class="participation-allowed">
|
||||||
<%= t("comments.comment.votes", count: comment.total_votes) %>
|
<%= t("comments.comment.votes", count: comment.total_votes) %>
|
||||||
|
|
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class Comments::VotesComponent < ApplicationComponent
|
class Comments::VotesComponent < ApplicationComponent
|
||||||
attr_reader :comment
|
attr_reader :comment
|
||||||
delegate :user_signed_in?, :can?, :link_to_signin, :link_to_signup, to: :helpers
|
delegate :current_user, :can?, :link_to_signin, :link_to_signup, to: :helpers
|
||||||
|
|
||||||
def initialize(comment)
|
def initialize(comment)
|
||||||
@comment = comment
|
@comment = comment
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<% voted_classes = css_classes_for_vote(debate) %>
|
<% voted_classes = css_classes_for_vote(debate) %>
|
||||||
<div class="votes">
|
<div class="votes">
|
||||||
<div class="in-favor inline-block">
|
<div class="in-favor inline-block">
|
||||||
<% if user_signed_in? %>
|
<% if current_user %>
|
||||||
<%= link_to vote_debate_path(debate, value: "yes"),
|
<%= link_to vote_debate_path(debate, value: "yes"),
|
||||||
class: "like #{voted_classes[:in_favor]}", title: t("votes.agree"), method: "post", remote: true do %>
|
class: "like #{voted_classes[:in_favor]}", title: t("votes.agree"), method: "post", remote: true do %>
|
||||||
<span class="icon-like">
|
<span class="icon-like">
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
<span class="divider"></span>
|
<span class="divider"></span>
|
||||||
|
|
||||||
<div class="against inline-block">
|
<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 %>
|
<%= 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="icon-unlike">
|
||||||
<span class="show-for-sr"><%= t("votes.disagree") %></span>
|
<span class="show-for-sr"><%= t("votes.disagree") %></span>
|
||||||
@@ -43,19 +43,19 @@
|
|||||||
<%= t("debates.debate.votes", count: debate.votes_score) %>
|
<%= t("debates.debate.votes", count: debate.votes_score) %>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<% if user_signed_in? && current_user.organization? %>
|
<% if current_user&.organization? %>
|
||||||
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
|
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
|
||||||
<p>
|
<p>
|
||||||
<%= t("votes.organizations") %>
|
<%= t("votes.organizations") %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</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">
|
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
|
||||||
<p>
|
<p>
|
||||||
<%= sanitize(t("votes.anonymous", verify_account: link_to_verify_account)) %>
|
<%= sanitize(t("votes.anonymous", verify_account: link_to_verify_account)) %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<% elsif !user_signed_in? %>
|
<% elsif !current_user %>
|
||||||
<div tabindex="0">
|
<div tabindex="0">
|
||||||
<%= render "shared/login_to_vote" %>
|
<%= render "shared/login_to_vote" %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class Debates::VotesComponent < ApplicationComponent
|
class Debates::VotesComponent < ApplicationComponent
|
||||||
attr_reader :debate
|
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)
|
def initialize(debate)
|
||||||
@debate = debate
|
@debate = debate
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<div class="votes">
|
<div class="votes">
|
||||||
<% if proposal.process.proposals_phase.open? %>
|
<% if proposal.process.proposals_phase.open? %>
|
||||||
<div class="in-favor inline-block">
|
<div class="in-favor inline-block">
|
||||||
<% if user_signed_in? %>
|
<% if current_user %>
|
||||||
<%= link_to vote_legislation_process_proposal_path(process_id: proposal.process, id: proposal, value: "yes"),
|
<%= link_to vote_legislation_process_proposal_path(process_id: proposal.process, id: proposal, value: "yes"),
|
||||||
class: "like #{voted_classes[:in_favor]}", title: t("votes.agree"), method: "post", remote: true do %>
|
class: "like #{voted_classes[:in_favor]}", title: t("votes.agree"), method: "post", remote: true do %>
|
||||||
<span class="icon-like">
|
<span class="icon-like">
|
||||||
@@ -23,7 +23,7 @@
|
|||||||
<span class="divider"></span>
|
<span class="divider"></span>
|
||||||
|
|
||||||
<div class="against inline-block">
|
<div class="against inline-block">
|
||||||
<% if user_signed_in? %>
|
<% if current_user %>
|
||||||
<%= link_to vote_legislation_process_proposal_path(process_id: proposal.process, id: proposal, value: "no"), class: "unlike #{voted_classes[:against]}", title: t("votes.disagree"), method: "post", remote: true do %>
|
<%= link_to vote_legislation_process_proposal_path(process_id: proposal.process, id: proposal, value: "no"), class: "unlike #{voted_classes[:against]}", title: t("votes.disagree"), method: "post", remote: true do %>
|
||||||
<span class="icon-unlike">
|
<span class="icon-unlike">
|
||||||
<span class="show-for-sr"><%= t("votes.disagree") %></span>
|
<span class="show-for-sr"><%= t("votes.disagree") %></span>
|
||||||
@@ -45,20 +45,20 @@
|
|||||||
<%= t("proposals.proposal.votes", count: proposal.votes_score) %>
|
<%= t("proposals.proposal.votes", count: proposal.votes_score) %>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<% if user_signed_in? && current_user.organization? %>
|
<% if current_user&.organization? %>
|
||||||
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
|
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
|
||||||
<p>
|
<p>
|
||||||
<%= t("votes.organizations") %>
|
<%= t("votes.organizations") %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<% elsif user_signed_in? && !proposal.votable_by?(current_user) %>
|
<% elsif current_user && !proposal.votable_by?(current_user) %>
|
||||||
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
|
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
|
||||||
<p>
|
<p>
|
||||||
<%= sanitize(t("legislation.proposals.not_verified",
|
<%= sanitize(t("legislation.proposals.not_verified",
|
||||||
verify_account: link_to_verify_account)) %>
|
verify_account: link_to_verify_account)) %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<% elsif !user_signed_in? %>
|
<% elsif !current_user %>
|
||||||
<div tabindex="0">
|
<div tabindex="0">
|
||||||
<%= render "shared/login_to_vote" %>
|
<%= render "shared/login_to_vote" %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class Legislation::Proposals::VotesComponent < ApplicationComponent
|
class Legislation::Proposals::VotesComponent < ApplicationComponent
|
||||||
attr_reader :proposal
|
attr_reader :proposal
|
||||||
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(proposal)
|
def initialize(proposal)
|
||||||
@proposal = proposal
|
@proposal = proposal
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<div class="supported callout success">
|
<div class="supported callout success">
|
||||||
<%= t("proposals.proposal.already_supported") %>
|
<%= t("proposals.proposal.already_supported") %>
|
||||||
</div>
|
</div>
|
||||||
<% elsif user_signed_in? && proposal.votable_by?(current_user) %>
|
<% elsif current_user && proposal.votable_by?(current_user) %>
|
||||||
<%= link_to vote_url,
|
<%= link_to vote_url,
|
||||||
class: "button button-support small expanded",
|
class: "button button-support small expanded",
|
||||||
title: t("proposals.proposal.support_title"), method: "post", remote: true do %>
|
title: t("proposals.proposal.support_title"), method: "post", remote: true do %>
|
||||||
@@ -19,13 +19,13 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<% if user_signed_in? && current_user.organization? %>
|
<% if current_user&.organization? %>
|
||||||
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
|
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
|
||||||
<p>
|
<p>
|
||||||
<%= t("votes.organizations") %>
|
<%= t("votes.organizations") %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<% elsif user_signed_in? && !proposal.votable_by?(current_user) %>
|
<% elsif current_user && !proposal.votable_by?(current_user) %>
|
||||||
<div tabindex="0">
|
<div tabindex="0">
|
||||||
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
|
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
|
||||||
<p>
|
<p>
|
||||||
@@ -33,7 +33,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% elsif !user_signed_in? %>
|
<% elsif !current_user %>
|
||||||
<div tabindex="0">
|
<div tabindex="0">
|
||||||
<%= render "shared/login_to_vote" %>
|
<%= render "shared/login_to_vote" %>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
class Proposals::VotesComponent < ApplicationComponent
|
class Proposals::VotesComponent < ApplicationComponent
|
||||||
attr_reader :proposal
|
attr_reader :proposal
|
||||||
delegate :current_user, :link_to_verify_account, :user_signed_in?, to: :helpers
|
delegate :current_user, :link_to_verify_account, to: :helpers
|
||||||
|
|
||||||
def initialize(proposal, vote_url: nil)
|
def initialize(proposal, vote_url: nil)
|
||||||
@proposal = proposal
|
@proposal = proposal
|
||||||
|
|||||||
Reference in New Issue
Block a user