Do not try to render posts/comments which are not present

refs diaspora/diaspora#4959
This commit is contained in:
Lukas Matt 2014-05-15 17:34:00 -04:00
parent 01381ddf25
commit 6d6ebd297e
4 changed files with 13 additions and 8 deletions

View file

@ -5,6 +5,9 @@
span { span {
display: block; display: block;
} }
span.text {
padding-bottom: 1em;
}
} }
.options { .options {
float: right; float: right;

View file

@ -4,13 +4,14 @@
module ReportHelper module ReportHelper
def report_content(id, type) def report_content(id, type)
raw case type if type == 'post' && !(post = Post.find_by_id(id)).nil?
when 'post' raw t('report.post_label', title: link_to(post_page_title(post), post_path(id)))
t('report.post_label', title: link_to(post_page_title(Post.find_by_id(id)), post_path(id))) elsif type == 'comment' && !(comment = Comment.find_by_id(id)).nil?
when 'comment' # comment_message is not html_safe. To prevent
# comment_message is not html_safe. To prevent # cross-site-scripting we have to escape html
# cross-site-scripting we have to escape html raw t('report.comment_label', data: h(comment_message(comment)))
t('report.comment_label', data: h(comment_message(Comment.find_by_id(id)))) else
raw t('report.not_found')
end end
end end
end end

View file

@ -8,7 +8,7 @@
- @reports.each do |r| - @reports.each do |r|
- username = User.find_by_id(r.user_id).username - username = User.find_by_id(r.user_id).username
%div.content %div.content
%span %span.text
= report_content(r.item_id, r.item_type) = report_content(r.item_id, r.item_type)
%span %span
= raw t('report.reported_label', person: link_to(username, user_profile_path(username))) = raw t('report.reported_label', person: link_to(username, user_profile_path(username)))

View file

@ -894,6 +894,7 @@ en:
review_link: "Mark as reviewed" review_link: "Mark as reviewed"
delete_link: "Delete item" delete_link: "Delete item"
confirm_deletion: "Are you sure to delete the item?" confirm_deletion: "Are you sure to delete the item?"
not_found: "<u>The post/comment was not found. It seams that it was deleted by the user!</u>"
status: status:
marked: "The report was marked as reviewed" marked: "The report was marked as reviewed"
destroyed: "The post was destroyed" destroyed: "The post was destroyed"