Sha256: 0e9a7e4139e07a63a2a7b7898f644b3b05a144177e7b6fdd46e644ec7a23ffdf

Contents?: true

Size: 927 Bytes

Versions: 10

Compression:

Stored size: 927 Bytes

Contents

# frozen_string_literal: true

module Decidim
  class ResourceHiddenEvent < Decidim::Events::SimpleEvent
    include Decidim::ApplicationHelper

    i18n_attributes :resource_path, :report_reasons, :resource_type, :resource_content

    def resource_path
      @resource.reported_content_url
    end

    def resource_url
      @resource.reported_content_url
    end

    def report_reasons
      extra["report_reasons"].map do |reason|
        I18n.t("decidim.admin.moderations.report.reasons.#{reason}").downcase
      end.join(", ")
    end

    def resource_title
      nil
    end

    def resource_content
      text = translated_attribute(@resource[@resource.reported_attributes.first])

      decidim_sanitize(html_truncate(text, length: 100), strip_tags: true)
    end

    def resource_text
      "<i>#{resource_content}</i>"
    end

    def resource_type
      @resource.model_name.human.downcase
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
decidim-admin-0.29.1 app/events/decidim/resource_hidden_event.rb
decidim-admin-0.28.4 app/events/decidim/resource_hidden_event.rb
decidim-admin-0.29.0 app/events/decidim/resource_hidden_event.rb
decidim-admin-0.28.3 app/events/decidim/resource_hidden_event.rb
decidim-admin-0.29.0.rc4 app/events/decidim/resource_hidden_event.rb
decidim-admin-0.29.0.rc3 app/events/decidim/resource_hidden_event.rb
decidim-admin-0.29.0.rc2 app/events/decidim/resource_hidden_event.rb
decidim-admin-0.29.0.rc1 app/events/decidim/resource_hidden_event.rb
decidim-admin-0.28.2 app/events/decidim/resource_hidden_event.rb
decidim-admin-0.28.1 app/events/decidim/resource_hidden_event.rb