Sha256: 3aecdc1181c06413b366fe2e9b6e557ec4fb5040d1b11e406abeb6b8bd03eb02

Contents?: true

Size: 834 Bytes

Versions: 3

Compression:

Stored size: 834 Bytes

Contents

# frozen_string_literal: true

module Decidim
  class ResourceHiddenEvent < Decidim::Events::SimpleEvent
    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
      translated_attribute(@resource[@resource.reported_attributes.first]).truncate(100, separator: " ")
    end

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
decidim-admin-0.28.0 app/events/decidim/resource_hidden_event.rb
decidim-admin-0.28.0.rc5 app/events/decidim/resource_hidden_event.rb
decidim-admin-0.28.0.rc4 app/events/decidim/resource_hidden_event.rb