Sha256: 9b5d46ae902397677a33188b1f0da4b182536f9a6dc524d470b725f4d0a49aa9
Contents?: true
Size: 1.26 KB
Versions: 13
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true module Decidim class ContextualHelpSection < ApplicationRecord include Decidim::TranslatableResource include Decidim::Traceable translatable_fields :content belongs_to :organization, class_name: "Decidim::Organization" validates :content, presence: true def self.log_presenter_class_for(_log) Decidim::AdminLog::ContextualHelpSectionPresenter end # Public: Finds content given an id # # organization - The Organization to scope the content to # id - A String with the id # # Returns a Hash with the localized content def self.find_content(organization, id) find_by(organization:, section_id: id).try(:content) || {} end # Public: Stores the content. # # organization - The Organization to scope the content to # id - A String with the id # content - A Hash with the content to store # # Returns a Hash with the localized content def self.set_content(organization, id, content) item = find_or_initialize_by( organization:, section_id: id ) if content.present? && content.values.any?(&:present?) item.update!(content:) else item.destroy! end content end end end
Version data entries
13 entries across 13 versions & 1 rubygems