Sha256: 375992c44c5c7e1588fe5045241e3290fa70a7abd4f35d61f810221612f66efa
Contents?: true
Size: 1.27 KB
Versions: 5
Compression:
Stored size: 1.27 KB
Contents
# frozen_string_literal: true module Decidim # This model holds all the data needed to send a newsletter. class Newsletter < ApplicationRecord include Decidim::Traceable include Decidim::Loggable belongs_to :author, class_name: "User" belongs_to :organization validates :subject, :body, presence: true validate :author_belongs_to_organization def self.log_presenter_class_for(_log) Decidim::AdminLog::NewsletterPresenter end # Returns true if this newsletter was already sent. # # Returns a Boolean. def sent? sent_at.present? end def sent_scopes_ids extended_data["scope_ids"] || [] end def sent_scopes @sent_scopes ||= organization.scopes.where(id: sent_scopes_ids) end def sended_to_all_users? extended_data["send_to_all_users"] end def sended_to_followers? extended_data["send_to_followers"] end def sended_to_participants? extended_data["send_to_participants"] end def sended_to_partipatory_spaces extended_data["participatory_space_types"] end private def author_belongs_to_organization return if !author || !organization errors.add(:author, :invalid) unless author.organization == organization end end end
Version data entries
5 entries across 5 versions & 1 rubygems