Commit iniziale di eminuxCRM: CRM Rails con pipeline, campagne email e Docker.
Include autenticazione, progetti isolati, mail marketing HTML con SMTP, test A/B e editor WYSIWYG. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
class MailTemplate < ApplicationRecord
|
||||
include Auditable
|
||||
include HtmlBlankable
|
||||
|
||||
belongs_to :project, optional: true
|
||||
has_many :mailings, dependent: :nullify
|
||||
has_many :mailings_as_b, class_name: "Mailing", foreign_key: :mail_template_b_id, dependent: :nullify
|
||||
|
||||
clears_blank_html :body_html
|
||||
validates :name, :subject, :body_html, presence: true
|
||||
|
||||
scope :for_project, ->(project) {
|
||||
where(project_id: [nil, project&.id].compact).order(:name)
|
||||
}
|
||||
|
||||
def preview_html(organization: nil, contact: nil, project: nil, opportunity: nil)
|
||||
MailMerge.render(body_html, organization:, contact:, project:, opportunity:)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user