Merge pull request #677 from AyuntamientoMadrid/comments-info
adds info about deleted items on comments activity
This commit is contained in:
@@ -1,12 +0,0 @@
|
|||||||
module UserHelper
|
|
||||||
def humanize_document_type(document_type)
|
|
||||||
case document_type
|
|
||||||
when "1"
|
|
||||||
t "verification.residence.new.document_type.spanish_id"
|
|
||||||
when "2"
|
|
||||||
t "verification.residence.new.document_type.passport"
|
|
||||||
when "3"
|
|
||||||
t "verification.residence.new.document_type.residence_card"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
38
app/helpers/users_helper.rb
Normal file
38
app/helpers/users_helper.rb
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
module UsersHelper
|
||||||
|
|
||||||
|
def humanize_document_type(document_type)
|
||||||
|
case document_type
|
||||||
|
when "1"
|
||||||
|
t "verification.residence.new.document_type.spanish_id"
|
||||||
|
when "2"
|
||||||
|
t "verification.residence.new.document_type.passport"
|
||||||
|
when "3"
|
||||||
|
t "verification.residence.new.document_type.residence_card"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def comment_commentable_title(comment)
|
||||||
|
commentable = comment.commentable
|
||||||
|
if commentable.nil?
|
||||||
|
deleted_commentable_text(comment)
|
||||||
|
elsif commentable.hidden?
|
||||||
|
"<abbr title='#{deleted_commentable_text(comment)}'>".html_safe +
|
||||||
|
commentable.title +
|
||||||
|
"</abbr>".html_safe
|
||||||
|
else
|
||||||
|
link_to(commentable.title, commentable)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def deleted_commentable_text(comment)
|
||||||
|
case comment.commentable_type
|
||||||
|
when "Proposal"
|
||||||
|
t("users.show.deleted_proposal")
|
||||||
|
when "Debate"
|
||||||
|
t("users.show.deleted_debate")
|
||||||
|
else
|
||||||
|
t("users.show.deleted")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
class Mailer < ApplicationMailer
|
class Mailer < ApplicationMailer
|
||||||
helper :text_with_links
|
helper :text_with_links
|
||||||
helper :mailer
|
helper :mailer
|
||||||
helper :user
|
helper :users
|
||||||
|
|
||||||
def comment(comment)
|
def comment(comment)
|
||||||
@comment = comment
|
@comment = comment
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<% @comments.each do |comment| %>
|
<% @comments.each do |comment| %>
|
||||||
<tr id="debate_<%= comment.id %>">
|
<tr id="debate_<%= comment.id %>">
|
||||||
<td>
|
<td>
|
||||||
<%= comment.commentable.hidden? ? comment.commentable.title : link_to(comment.commentable.title, comment.commentable) %>
|
<%= comment_commentable_title(comment) %>
|
||||||
<br>
|
<br>
|
||||||
<%= comment.body %>
|
<%= comment.body %>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -340,6 +340,9 @@ en:
|
|||||||
other: "%{count} Comments"
|
other: "%{count} Comments"
|
||||||
no_activity: "User has no public activity"
|
no_activity: "User has no public activity"
|
||||||
private_activity: "This user decided to keep the activity list private"
|
private_activity: "This user decided to keep the activity list private"
|
||||||
|
deleted: "Deleted"
|
||||||
|
deleted_debate: "This debate has been deleted"
|
||||||
|
deleted_proposal: "This proposal has been deleted"
|
||||||
unauthorized:
|
unauthorized:
|
||||||
default: "You do not have permission to access this page."
|
default: "You do not have permission to access this page."
|
||||||
manage:
|
manage:
|
||||||
|
|||||||
@@ -340,6 +340,9 @@ es:
|
|||||||
other: "%{count} Comentarios"
|
other: "%{count} Comentarios"
|
||||||
no_activity: "Usuario sin actividad pública"
|
no_activity: "Usuario sin actividad pública"
|
||||||
private_activity: "Este usuario ha decidido mantener en privado su lista de actividades"
|
private_activity: "Este usuario ha decidido mantener en privado su lista de actividades"
|
||||||
|
deleted: "Eliminado"
|
||||||
|
deleted_debate: "Este debate ha sido eliminado"
|
||||||
|
deleted_proposal: "Este propuesta ha sido eliminada"
|
||||||
unauthorized:
|
unauthorized:
|
||||||
default: "No tienes permiso para acceder a esta página."
|
default: "No tienes permiso para acceder a esta página."
|
||||||
manage:
|
manage:
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
require 'rails_helper'
|
|
||||||
|
|
||||||
describe UserHelper do
|
|
||||||
|
|
||||||
describe '#humanize_document_type' do
|
|
||||||
it "should return a humanized document type" do
|
|
||||||
expect(humanize_document_type("1")).to eq "DNI"
|
|
||||||
expect(humanize_document_type("2")).to eq "Passport"
|
|
||||||
expect(humanize_document_type("3")).to eq "Residence card"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
46
spec/helpers/users_helper_spec.rb
Normal file
46
spec/helpers/users_helper_spec.rb
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
describe UsersHelper do
|
||||||
|
|
||||||
|
describe '#humanize_document_type' do
|
||||||
|
it "should return a humanized document type" do
|
||||||
|
expect(humanize_document_type("1")).to eq "DNI"
|
||||||
|
expect(humanize_document_type("2")).to eq "Passport"
|
||||||
|
expect(humanize_document_type("3")).to eq "Residence card"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#deleted_commentable_text' do
|
||||||
|
it "should return the appropriate message for deleted debates" do
|
||||||
|
debate = create(:debate)
|
||||||
|
comment = create(:comment, commentable: debate)
|
||||||
|
|
||||||
|
debate.hide
|
||||||
|
|
||||||
|
expect(comment_commentable_title(comment)).to eq "<abbr title='This debate has been deleted'>#{comment.commentable.title}</abbr>"
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should return the appropriate message for deleted proposals" do
|
||||||
|
proposal = create(:proposal)
|
||||||
|
comment = create(:comment, commentable: proposal)
|
||||||
|
|
||||||
|
proposal.hide
|
||||||
|
|
||||||
|
expect(comment_commentable_title(comment)).to eq "<abbr title='This proposal has been deleted'>#{comment.commentable.title}</abbr>"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#comment_commentable_title' do
|
||||||
|
it "should return a link to the commentable" do
|
||||||
|
comment = create(:comment)
|
||||||
|
expect(comment_commentable_title(comment)).to eq link_to comment.commentable.title, comment.commentable
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should return a hint if the commentable has been deleted" do
|
||||||
|
comment = create(:comment)
|
||||||
|
comment.commentable.hide
|
||||||
|
expect(comment_commentable_title(comment)).to eq "<abbr title='This debate has been deleted'>#{comment.commentable.title}</abbr>"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user