Sha256: b6675166873b3a4d9d99c098ae49fb68cc388b775a6c39973862010d6d89817f

Contents?: true

Size: 1.13 KB

Versions: 20

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module Decidim
  module Admin
    # Controller that allows managing newsletters.
    class NewsletterTemplatesController < Decidim::Admin::ApplicationController
      helper_method :templates, :template_manifest

      layout "decidim/admin/newsletters"

      def index
        enforce_permission_to :index, :newsletter
      end

      def show; end

      def preview
        email = NewsletterMailer.newsletter(current_user, fake_newsletter, preview: true)
        Premailer::Rails::Hook.perform(email)
        render html: email.html_part.body.decoded.html_safe
      end

      private

      def templates
        @templates ||= Decidim.content_blocks.for(:newsletter_template)
      end

      def template_manifest
        @template_manifest ||= Decidim
                               .content_blocks
                               .for(:newsletter_template)
                               .find { |manifest| manifest.name.to_s == params[:id] }
      end

      def fake_newsletter
        @fake_newsletter ||= Decidim::Admin::FakeNewsletter.new(current_organization, template_manifest)
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
decidim-admin-0.28.4 app/controllers/decidim/admin/newsletter_templates_controller.rb
decidim-admin-0.27.9 app/controllers/decidim/admin/newsletter_templates_controller.rb
decidim-admin-0.28.3 app/controllers/decidim/admin/newsletter_templates_controller.rb
decidim-admin-0.27.8 app/controllers/decidim/admin/newsletter_templates_controller.rb
decidim-admin-0.28.2 app/controllers/decidim/admin/newsletter_templates_controller.rb
decidim-admin-0.27.7 app/controllers/decidim/admin/newsletter_templates_controller.rb
decidim-admin-0.28.1 app/controllers/decidim/admin/newsletter_templates_controller.rb
decidim-admin-0.27.6 app/controllers/decidim/admin/newsletter_templates_controller.rb
decidim-admin-0.26.10 app/controllers/decidim/admin/newsletter_templates_controller.rb
decidim-admin-0.26.9 app/controllers/decidim/admin/newsletter_templates_controller.rb
decidim-admin-0.28.0 app/controllers/decidim/admin/newsletter_templates_controller.rb
decidim-admin-0.27.5 app/controllers/decidim/admin/newsletter_templates_controller.rb
decidim-admin-0.28.0.rc5 app/controllers/decidim/admin/newsletter_templates_controller.rb
decidim-admin-0.28.0.rc4 app/controllers/decidim/admin/newsletter_templates_controller.rb
decidim-admin-0.26.8 app/controllers/decidim/admin/newsletter_templates_controller.rb
decidim-admin-0.27.4 app/controllers/decidim/admin/newsletter_templates_controller.rb
decidim-admin-0.27.3 app/controllers/decidim/admin/newsletter_templates_controller.rb
decidim-admin-0.26.7 app/controllers/decidim/admin/newsletter_templates_controller.rb
decidim-admin-0.26.5 app/controllers/decidim/admin/newsletter_templates_controller.rb
decidim-admin-0.27.2 app/controllers/decidim/admin/newsletter_templates_controller.rb