Class: Decidim::Proposals::PublishProposalEvent

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

Instance Method Summary collapse

Instance Method Details

#i18n_optionsObject



15
16
17
18
19
20
21
# File '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 '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 'app/events/decidim/proposals/publish_proposal_event.rb', line 11

def resource_text
  resource.body
end

#safe_resource_textObject



31
32
33
34
# File '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 '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 'app/events/decidim/proposals/publish_proposal_event.rb', line 23

def translatable_resource
  resource
end

#translatable_textObject



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

def translatable_text
  resource.body
end