Sha256: edde32e3f16da737f0f5186b559b8b5ba0bd2b13296505e788c54cc2de5be045

Contents?: true

Size: 1.15 KB

Versions: 18

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

# Templates can be defined from the admin panel to store and use objects
# with given values and use them to create new ones using these values as default
#
# The model class we want to create these templates from must include the Templatable
# concern. A controller should be created to manage templates for the model,
# as well as the routes for the controller actions. The command classes to use in
# these actions should also be created to define the particular data management
# for the model's templates.
module Decidim
  module Templates
    class Template < ApplicationRecord
      include Decidim::Traceable

      belongs_to :organization,
                 foreign_key: "decidim_organization_id",
                 class_name: "Decidim::Organization"

      belongs_to :templatable, foreign_type: "templatable_type", polymorphic: true, optional: true

      validates :name, presence: true

      def resource_name
        [templatable_type.demodulize.tableize.singularize, "templates"].join("_")
      end

      def self.log_presenter_class_for(_log)
        Decidim::Templates::AdminLog::TemplatePresenter
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
decidim-templates-0.30.0.rc3 app/models/decidim/templates/template.rb
decidim-templates-0.30.0.rc2 app/models/decidim/templates/template.rb
decidim-templates-0.30.0.rc1 app/models/decidim/templates/template.rb
decidim-templates-0.29.2 app/models/decidim/templates/template.rb
decidim-templates-0.28.5 app/models/decidim/templates/template.rb
decidim-templates-0.29.1 app/models/decidim/templates/template.rb
decidim-templates-0.28.4 app/models/decidim/templates/template.rb
decidim-templates-0.29.0 app/models/decidim/templates/template.rb
decidim-templates-0.28.3 app/models/decidim/templates/template.rb
decidim-templates-0.29.0.rc4 app/models/decidim/templates/template.rb
decidim-templates-0.29.0.rc3 app/models/decidim/templates/template.rb
decidim-templates-0.29.0.rc2 app/models/decidim/templates/template.rb
decidim-templates-0.29.0.rc1 app/models/decidim/templates/template.rb
decidim-templates-0.28.2 app/models/decidim/templates/template.rb
decidim-templates-0.28.1 app/models/decidim/templates/template.rb
decidim-templates-0.28.0 app/models/decidim/templates/template.rb
decidim-templates-0.28.0.rc5 app/models/decidim/templates/template.rb
decidim-templates-0.28.0.rc4 app/models/decidim/templates/template.rb