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:
Javi Martín
2021-09-28 23:21:43 +02:00
parent 4b42a68b6a
commit 70f717e564
8 changed files with 20 additions and 20 deletions

View File

@@ -6,7 +6,7 @@
<div class="supported callout success">
<%= t("proposals.proposal.already_supported") %>
</div>
<% elsif user_signed_in? && proposal.votable_by?(current_user) %>
<% elsif current_user && proposal.votable_by?(current_user) %>
<%= link_to vote_url,
class: "button button-support small expanded",
title: t("proposals.proposal.support_title"), method: "post", remote: true do %>
@@ -19,13 +19,13 @@
<% end %>
</div>
<% 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? && !proposal.votable_by?(current_user) %>
<% elsif current_user && !proposal.votable_by?(current_user) %>
<div tabindex="0">
<div class="participation-not-allowed" style="display:none" aria-hidden="false">
<p>
@@ -33,7 +33,7 @@
</p>
</div>
</div>
<% elsif !user_signed_in? %>
<% elsif !current_user %>
<div tabindex="0">
<%= render "shared/login_to_vote" %>
</div>

View File

@@ -1,6 +1,6 @@
class Proposals::VotesComponent < ApplicationComponent
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)
@proposal = proposal