add personalization settings

This commit is contained in:
Alex Turchyn
2023-08-16 22:57:59 +03:00
parent 545b18086a
commit 187b354605
34 changed files with 244 additions and 60 deletions
+10
View File
@@ -0,0 +1,10 @@
# frozen_string_literal: true
module AccountConfigs
module_function
def find_or_initialize_for_key(account, key)
account.account_configs.find_by(key:) ||
account.account_configs.new(key:, value: AccountConfig::DEFAULT_VALUES[key])
end
end
+21
View File
@@ -0,0 +1,21 @@
# frozen_string_literal: true
module ReplaceEmailVariables
TEMAPLTE_NAME = '{{template.name}}'
SUBMITTER_LINK = '{{submitter.link}}'
ACCOUNT_NAME = '{{account.name}}'
module_function
def call(text, submitter:)
link =
Rails.application.routes.url_helpers.submit_form_url(
slug: submitter.slug, **Docuseal.default_url_options
)
text = text.gsub(TEMAPLTE_NAME, submitter.template.name)
text = text.gsub(SUBMITTER_LINK, link)
text.gsub(ACCOUNT_NAME, submitter.template.account.name)
end
end