Class: Decidim::Proposals::PublishProposalEvent

Inherits:
Events::SimpleEvent show all
Includes:
ActionView::Helpers::UrlHelper, Events::CoauthorEvent, Events::MachineTranslatedEvent
Defined in:
decidim-proposals/app/events/decidim/proposals/publish_proposal_event.rb

Instance Method Summary collapse

Methods inherited from Events::SimpleEvent

#email_intro, #email_outro, #email_subject, #email_subject_i18n_options, #event_has_roles?, i18n_attributes, #participatory_space_url, #resource_path, #resource_url

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 ComponentPathHelper

#can_be_managed?, #main_component_path, #main_component_url, #manage_component_path

Methods inherited from Events::BaseEvent

#content_in_same_language?, #initialize, #organization, #perform_translation?, #resource_locator, #resource_path, #resource_title, #resource_url, #translation_missing?, type

Methods included from TranslatableAttributes

#default_locale?

Constructor Details

This class inherits a constructor from Decidim::Events::BaseEvent

Instance Method Details

#i18n_optionsObject



15
16
17
18
19
20
21
# File 'decidim-proposals/app/events/decidim/proposals/publish_proposal_event.rb', line 15

def i18n_options
  return super if author.blank?

  author_path = link_to("@#{author.nickname}", profile_path(author.nickname))
  author_string = "#{author.name} #{author_path}"
  super.merge({ author: author_string })
end

#notification_titleObject



40
41
42
43
44
# File 'decidim-proposals/app/events/decidim/proposals/publish_proposal_event.rb', line 40

def notification_title
  i18n_key = resource.official? ? "notification_title_official" : "notification_title"

  I18n.t(i18n_key, **i18n_options).html_safe
end

#resource_textObject



11
12
13
# File 'decidim-proposals/app/events/decidim/proposals/publish_proposal_event.rb', line 11

def resource_text
  resource.body
end

#safe_resource_textObject



31
32
33
34
# File 'decidim-proposals/app/events/decidim/proposals/publish_proposal_event.rb', line 31

def safe_resource_text
  locale = resource.respond_to?(:content_original_language) ? resource.content_original_language : I18n.locale
  I18n.with_locale(locale) { translated_attribute(resource_text).to_s.html_safe }
end

#safe_resource_translated_textObject



36
37
38
# File 'decidim-proposals/app/events/decidim/proposals/publish_proposal_event.rb', line 36

def safe_resource_translated_text
  I18n.with_locale(I18n.locale) { translated_attribute(resource_text, nil, true).to_s.html_safe }
end

#translatable_resourceObject



23
24
25
# File 'decidim-proposals/app/events/decidim/proposals/publish_proposal_event.rb', line 23

def translatable_resource
  resource
end

#translatable_textObject



27
28
29
# File 'decidim-proposals/app/events/decidim/proposals/publish_proposal_event.rb', line 27

def translatable_text
  resource.body
end