From b865eba1abda3e70a86e65729c56754009a133c8 Mon Sep 17 00:00:00 2001
From: Alberto Garcia Cabeza
Date: Wed, 7 Dec 2016 17:12:45 +0100
Subject: [PATCH] removes links on debates and proposals to unlogged users
---
app/views/debates/_votes.html.erb | 50 ++++++++++++++++++++---------
app/views/proposals/_votes.html.erb | 30 ++++++++++-------
2 files changed, 54 insertions(+), 26 deletions(-)
diff --git a/app/views/debates/_votes.html.erb b/app/views/debates/_votes.html.erb
index cc59a3f3a..9bc3ca555 100644
--- a/app/views/debates/_votes.html.erb
+++ b/app/views/debates/_votes.html.erb
@@ -1,23 +1,41 @@
<% voted_classes = css_classes_for_vote(@debate_votes, debate) %>
- <%= link_to vote_debate_path(debate, value: 'yes'),
- class: "like #{voted_classes[:in_favor]}", title: t('votes.agree'), method: "post", remote: true do %>
-
- <%= t('votes.agree') %>
-
-
<%= votes_percentage('likes', debate) %>
+ <% 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 %>
+
+ <%= t('votes.agree') %>
+
+
<%= votes_percentage('likes', debate) %>
+ <% end %>
+ <% else %>
+
+
+ <%= t('votes.agree') %>
+
+ <%= votes_percentage('likes', debate) %>
+
<% end %>
- <%= link_to vote_debate_path(debate, value: 'no'), class: "unlike #{voted_classes[:against]}", title: t('votes.disagree'), method: "post", remote: true do %>
-
- <%= t('votes.disagree') %>
-
-
<%= votes_percentage('dislikes', debate) %>
+ <% 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 %>
+
+ <%= t('votes.disagree') %>
+
+
<%= votes_percentage('dislikes', debate) %>
+ <% end %>
+ <% else %>
+
+
+ <%= t('votes.disagree') %>
+
+ <%= votes_percentage('dislikes', debate) %>
+
<% end %>
@@ -39,10 +57,12 @@
<% elsif !user_signed_in? %>
-
- <%= 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 %>
+
+
+ <%= 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 %>
+
<% end %>
diff --git a/app/views/proposals/_votes.html.erb b/app/views/proposals/_votes.html.erb
index 4c2a348ca..e1927ec05 100644
--- a/app/views/proposals/_votes.html.erb
+++ b/app/views/proposals/_votes.html.erb
@@ -19,12 +19,16 @@
<%= t("proposals.proposal.already_supported") %>
- <% else %>
+ <% elsif user_signed_in? && 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 %>
<%= t("proposals.proposal.support") %>
<% end %>
+ <% else %>
+
+ <%= t("proposals.proposal.support") %>
+
<% end %>
@@ -34,18 +38,22 @@
<%= t("votes.organizations") %>
-<% elsif user_signed_in? && !proposal.votable_by?(current_user)%>
-
-
- <%= t("votes.verified_only",
- verify_account: link_to(t("votes.verify_account"), verification_path )).html_safe %>
-
+<% elsif user_signed_in? && !proposal.votable_by?(current_user) %>
+
+
+
+ <%= t("votes.verified_only",
+ verify_account: link_to(t("votes.verify_account"), verification_path )).html_safe %>
+
+
<% elsif !user_signed_in? %>
-
- <%= 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 %>
+
+
+ <%= 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 %>
+
<% end %>