From f5d8badeb6e20bb836802acae6be68be72eafe5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Tue, 1 Oct 2019 21:28:38 +0200 Subject: [PATCH] Extract partial to show "login to comment" message --- app/views/comments/_comment_tree.html.erb | 6 +----- app/views/comments/_commentable_tree.html.erb | 9 ++------- app/views/debates/_comments.html.erb | 9 ++------- app/views/legislation/annotations/_form.html.erb | 6 +----- app/views/legislation/proposals/_comments.html.erb | 9 ++------- app/views/polls/_comments.html.erb | 9 ++------- app/views/proposals/_comments.html.erb | 9 ++------- app/views/shared/_login_to_comment.html.erb | 6 ++++++ app/views/topics/_comments.html.erb | 8 +------- 9 files changed, 19 insertions(+), 52 deletions(-) create mode 100644 app/views/shared/_login_to_comment.html.erb diff --git a/app/views/comments/_comment_tree.html.erb b/app/views/comments/_comment_tree.html.erb index a22f78396..0a4c4ddc7 100644 --- a/app/views/comments/_comment_tree.html.erb +++ b/app/views/comments/_comment_tree.html.erb @@ -34,11 +34,7 @@ <% end %> <% else %>
-
- <%= t("users.login_to_comment", - signin: link_to(t("users.signin"), new_user_session_path), - signup: link_to(t("users.signup"), new_user_registration_path)).html_safe %> -
+ <%= render "shared/login_to_comment" %> <% end %> <% comment_tree.root_comments.each do |comment| %> diff --git a/app/views/comments/_commentable_tree.html.erb b/app/views/comments/_commentable_tree.html.erb index ca45f0f80..8ec0fb268 100644 --- a/app/views/comments/_commentable_tree.html.erb +++ b/app/views/comments/_commentable_tree.html.erb @@ -17,13 +17,8 @@ toggeable: false, valuation: valuation } %> <% else %> -
- -
- <%= t("users.login_to_comment", - signin: link_to(t("users.signin"), new_user_session_path), - signup: link_to(t("users.signup"), new_user_registration_path)).html_safe %> -
+
+ <%= render "shared/login_to_comment" %> <% end %> <% @comment_tree.root_comments.each do |comment| %> diff --git a/app/views/debates/_comments.html.erb b/app/views/debates/_comments.html.erb index 15f0d18d2..aec0a1414 100644 --- a/app/views/debates/_comments.html.erb +++ b/app/views/debates/_comments.html.erb @@ -11,13 +11,8 @@ <% if user_signed_in? %> <%= render "comments/form", { commentable: @debate, parent_id: nil, toggeable: false } %> <% else %> -
- -
- <%= t("users.login_to_comment", - signin: link_to(t("users.signin"), new_user_session_path), - signup: link_to(t("users.signup"), new_user_registration_path)).html_safe %> -
+
+ <%= render "shared/login_to_comment" %> <% end %> <% @comment_tree.root_comments.each do |comment| %> diff --git a/app/views/legislation/annotations/_form.html.erb b/app/views/legislation/annotations/_form.html.erb index dd48038ba..c843141f2 100644 --- a/app/views/legislation/annotations/_form.html.erb +++ b/app/views/legislation/annotations/_form.html.erb @@ -23,11 +23,7 @@ <%= f.hidden_field :ranges %> <% end %> <% else %> -
- <%= t("users.login_to_comment", - signin: link_to(t("users.signin"), new_user_session_path), - signup: link_to(t("users.signup"), new_user_registration_path)).html_safe %> -
+ <%= render "shared/login_to_comment" %> <% end %> diff --git a/app/views/legislation/proposals/_comments.html.erb b/app/views/legislation/proposals/_comments.html.erb index 6ff14f477..a3b0c635e 100644 --- a/app/views/legislation/proposals/_comments.html.erb +++ b/app/views/legislation/proposals/_comments.html.erb @@ -6,13 +6,8 @@ <% if user_signed_in? %> <%= render "comments/form", { commentable: @proposal, parent_id: nil, toggeable: false } %> <% else %> -
- -
- <%= t("users.login_to_comment", - signin: link_to(t("users.signin"), new_user_session_path), - signup: link_to(t("users.signup"), new_user_registration_path)).html_safe %> -
+
+ <%= render "shared/login_to_comment" %> <% end %> <% @comment_tree.root_comments.each do |comment| %> diff --git a/app/views/polls/_comments.html.erb b/app/views/polls/_comments.html.erb index 017684b02..5ac2dfb64 100644 --- a/app/views/polls/_comments.html.erb +++ b/app/views/polls/_comments.html.erb @@ -6,13 +6,8 @@ <% if user_signed_in? %> <%= render "comments/form", { commentable: @poll, parent_id: nil, toggeable: false } %> <% else %> -
- -
- <%= t("users.login_to_comment", - signin: link_to(t("users.signin"), new_user_session_path), - signup: link_to(t("users.signup"), new_user_registration_path)).html_safe %> -
+
+ <%= render "shared/login_to_comment" %> <% end %> <% @comment_tree.root_comments.each do |comment| %> diff --git a/app/views/proposals/_comments.html.erb b/app/views/proposals/_comments.html.erb index 6ff14f477..a3b0c635e 100644 --- a/app/views/proposals/_comments.html.erb +++ b/app/views/proposals/_comments.html.erb @@ -6,13 +6,8 @@ <% if user_signed_in? %> <%= render "comments/form", { commentable: @proposal, parent_id: nil, toggeable: false } %> <% else %> -
- -
- <%= t("users.login_to_comment", - signin: link_to(t("users.signin"), new_user_session_path), - signup: link_to(t("users.signup"), new_user_registration_path)).html_safe %> -
+
+ <%= render "shared/login_to_comment" %> <% end %> <% @comment_tree.root_comments.each do |comment| %> diff --git a/app/views/shared/_login_to_comment.html.erb b/app/views/shared/_login_to_comment.html.erb new file mode 100644 index 000000000..aa21f6cdf --- /dev/null +++ b/app/views/shared/_login_to_comment.html.erb @@ -0,0 +1,6 @@ +
+ <%= t("users.login_to_comment", + signin: link_to(t("users.signin"), new_user_session_path), + signup: link_to(t("users.signup"), new_user_registration_path) + ).html_safe %> +
diff --git a/app/views/topics/_comments.html.erb b/app/views/topics/_comments.html.erb index c1e29af2c..a5ca165fe 100644 --- a/app/views/topics/_comments.html.erb +++ b/app/views/topics/_comments.html.erb @@ -13,14 +13,8 @@ <% if user_signed_in? %> <%= render "comments/form", { commentable: @topic, parent_id: nil, toggeable: false } %> <% else %> - -
- <%= t("users.login_to_comment", - signin: link_to(t("users.signin"), new_user_session_path), - signup: link_to(t("users.signup"), new_user_registration_path)).html_safe %> -
+ <%= render "shared/login_to_comment" %> <% end %> - <% end %>