Class: Decidim::Admin::FakeNewsletter

Inherits:
Object
  • Object
show all
Defined in:
app/models/decidim/admin/fake_newsletter.rb

Overview

This class is used to generate fake newsletters and data to preview newsletter templates.

Instance Method Summary collapse

Constructor Details

#initialize(organization, manifest) ⇒ FakeNewsletter

Returns a new instance of FakeNewsletter.



8
9
10
11
# File 'app/models/decidim/admin/fake_newsletter.rb', line 8

def initialize(organization, manifest)
  @organization = organization
  @manifest = manifest
end

Instance Method Details

#draft?Boolean

Returns:

  • (Boolean)


44
45
46
# File 'app/models/decidim/admin/fake_newsletter.rb', line 44

def draft?
  true
end

#idObject



13
14
15
# File 'app/models/decidim/admin/fake_newsletter.rb', line 13

def id
  1
end

#notifications_settings_url(**_) ⇒ Object



52
53
54
# File 'app/models/decidim/admin/fake_newsletter.rb', line 52

def notifications_settings_url(**_)
  "#"
end

#organization_official_urlObject



60
61
62
# File 'app/models/decidim/admin/fake_newsletter.rb', line 60

def organization_official_url
  "#"
end

#sent_atObject



40
41
42
# File 'app/models/decidim/admin/fake_newsletter.rb', line 40

def sent_at
  nil
end

#subjectObject



34
35
36
37
38
# File 'app/models/decidim/admin/fake_newsletter.rb', line 34

def subject
  organization.available_locales.inject({}) do |acc, locale|
    acc.update(locale => "Lorem ipsum")
  end
end

#templateObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/models/decidim/admin/fake_newsletter.rb', line 17

def template
  @template ||= Decidim::ContentBlock.new(
    in_preview: true,
    manifest_name: manifest.name,
    scope_name: :newsletter_template,
    settings: manifest.settings.attributes.inject({}) do |acc, (name, attrs)|
      value = if attrs.preview.respond_to?(:call)
                attrs.preview.call
              else
                attrs.preview
              end

      acc.update(name => value)
    end
  )
end

#unsubscribe_newsletters_url(**_) ⇒ Object



56
57
58
# File 'app/models/decidim/admin/fake_newsletter.rb', line 56

def unsubscribe_newsletters_url(**_)
  "#"
end

#url(**_) ⇒ Object



48
49
50
# File 'app/models/decidim/admin/fake_newsletter.rb', line 48

def url(**_)
  "#"
end