Module: Decidim::Admin::Moderations::ReportsHelper

Includes:
Messaging::ConversationHelper, ResourceHelper, SanitizeHelper, TranslationsHelper
Defined in:
decidim-admin/app/helpers/decidim/admin/moderations/reports_helper.rb

Overview

This module includes helpers to show moderation reports in admin

Instance Method Summary collapse

Methods included from TranslationsHelper

empty_translatable, ensure_translatable, multi_translation, translated_in_current_locale?

Methods included from TranslatableAttributes

#default_locale?

Methods included from SanitizeHelper

#decidim_html_escape, #decidim_sanitize, #decidim_sanitize_admin, #decidim_sanitize_editor, #decidim_sanitize_editor_admin, #decidim_sanitize_newsletter, #decidim_url_escape, included

Methods included from ResourceHelper

#linked_classes_filter_values_for, #linked_classes_for, #resource_locator, #resource_title

Methods included from Messaging::ConversationHelper

#conversation_between, #conversation_between_multiple, #conversation_label_for, #conversation_name_for, #current_or_new_conversation_path_with, #current_or_new_conversation_path_with_multiple, #current_or_new_profile_conversation_path, #current_or_new_user_conversation_path, #link_to_current_or_new_conversation_with, #text_link_to_current_or_new_conversation_with, #username_list

Instance Method Details

#reportable_author_name(reportable) ⇒ Object

Public: Returns the reportable’s author names separated by commas.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'decidim-admin/app/helpers/decidim/admin/moderations/reports_helper.rb', line 14

def reportable_author_name(reportable)
  reportable_authors = reportable.try(:authors) || [reportable.try(:normalized_author)]
   :ul, class: "reportable-authors" do
    reportable_authors.select(&:present?).map do |author|
      case author
      when User
         :li do
          link_to current_or_new_conversation_path_with(author), target: "_blank", rel: "noopener" do
            "#{author.name} #{icon "envelope-closed"}".html_safe
          end
        end
      when Decidim::Meetings::Meeting
         :li do
          link_to resource_locator(author).path, target: "_blank", rel: "noopener" do
            decidim_sanitize(translated_attribute(author.title))
          end
        end
      else
        (:li, author.name)
      end
    end.join.html_safe
  end
end

#reported_content_for(reportable, options = {}) ⇒ Object

Public: Renders a small preview of the content reported.



39
40
41
# File 'decidim-admin/app/helpers/decidim/admin/moderations/reports_helper.rb', line 39

def reported_content_for(reportable, options = {})
  cell "decidim/reported_content", reportable, options
end

#translatable_resource?(reportable) ⇒ Boolean

Public: Whether the resource has some translated attribute or not.

Returns:

  • (Boolean)


44
45
46
# File 'decidim-admin/app/helpers/decidim/admin/moderations/reports_helper.rb', line 44

def translatable_resource?(reportable)
  reportable.respond_to?(:content_original_language)
end