Remove superfluous report existence checks

This commit is contained in:
Andreas Nedbal 2022-07-30 05:12:22 +02:00
parent 08033361f7
commit 19e95d066c
1 changed files with 31 additions and 32 deletions

View File

@ -1,33 +1,32 @@
- unless report.nil? || report.target.nil? || report.user.nil? || report.type.nil? .card.moderationbox{ data: { id: report.id } }
.card.moderationbox{ data: { id: report.id } } .card-header
.card-header %img.avatar-sm{ src: report.user.profile_picture.url(:medium) }
%img.avatar-sm{ src: report.user.profile_picture.url(:medium) } = t(".reported_html",
= t(".reported_html", user: user_screen_name(report.user),
user: user_screen_name(report.user), content: report.type.sub("Reports::", ""),
content: report.type.sub("Reports::", ""), time: time_tooltip(report))
time: time_tooltip(report)) .card-body
.card-body %p
%p - if report.type == "Reports::User"
- if report.type == "Reports::User" = user_screen_name report.target
= user_screen_name report.target - else
= report.target.content
%p
%b= t(".reason.heading")
%br
- if report.reason.nil? || report.reason.strip.blank?
= t(".reason.none")
- else - else
= report.target.content - report.reason.lines.each do |reason|
%p - next if reason.strip.blank?
%b= t(".reason.heading") = reason.strip
%br .row
- if report.reason.nil? || report.reason.strip.blank? .col-md-8.col-sm-8.col-xs-8.text-left
= t(".reason.none") %a.btn.btn-primary{ href: content_url(report) }
- else = t(".view", content: report.type.sub("Reports::", ""))
- report.reason.lines.each do |reason| - if report.target.respond_to?(:user) && report.target.user
- next if reason.strip.blank? %a.btn.btn-primary{ href: user_path(report.target.user) }
= reason.strip = t(".view", content: t("activerecord.models.user.one"))
.row .col-md-4.col-sm-4.col-xs-4.text-right
.col-md-8.col-sm-8.col-xs-8.text-left %button.btn.btn-default.btn-sm{ type: :button, name: "mod-delete-report", data: { id: report.id } }
%a.btn.btn-primary{ href: content_url(report) } %i.fa.fa-trash-o
= t(".view", content: report.type.sub("Reports::", ""))
- if report.target.respond_to?(:user) && report.target.user
%a.btn.btn-primary{ href: user_path(report.target.user) }
= t(".view", content: t("activerecord.models.user.one"))
.col-md-4.col-sm-4.col-xs-4.text-right
%button.btn.btn-default.btn-sm{ type: :button, name: "mod-delete-report", data: { id: report.id } }
%i.fa.fa-trash-o