Last active
December 14, 2015 20:19
-
-
Save apneadiving/5142891 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update_discussion_with_client( author, client, document, message ) | |
email_vars = { | |
:locale => client.locale, | |
:job_ref => document.ref, | |
:message => message, | |
:job_link => render_link(review_clients_project_path(id: document.project_id), client.locale) # I cannot find the route to open a document for review from the client's perspective | |
} | |
base_mail( | |
receiver: client, | |
template: "job-discussion-updated", | |
sender: ->(country_code) { "TextMaster #{country_code} <[email protected]>" }, | |
template_vars: email_vars | |
) | |
end | |
def base_mail(options) | |
receiver = options.fetch :receiver | |
template = options.fetch :template | |
template_vars = options.fetch :template_vars | |
sender = options.fetch :sender | |
@locale = receiver.locale | |
country_code = CustomData.get_country_code(@locale).upcase unless @locale.nil? | |
email_from = sender.call(country_code) | |
set_headers(email_from) | |
@title = render_email_title(template, template_vars) | |
@content = render_email_content(template, template_vars) | |
templatize_email | |
set_user_variables(receiver) #set %greetings, %signature, %home_title, etc. variables | |
mail(:from => email_from, | |
:to => receiver.email, | |
:subject => @title) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def update_discussion_with_client( author, client, document, message ) | |
@locale = client.locale | |
country_code = CustomData.get_country_code(@locale).upcase unless @locale.nil? | |
email_from = "TextMaster #{country_code} <[email protected]>" | |
set_headers(email_from) | |
@email_vars = { | |
:locale => @locale, | |
:job_ref => document.ref, | |
:message => message, | |
:job_link => render_link(review_clients_project_path(id: document.project_id), @locale) # I cannot find the route to open a document for review from the client's perspective | |
} | |
@title = render_email_title("job-discussion-updated", @email_vars) | |
@content = render_email_content("job-discussion-updated", @email_vars) | |
templatize_email #use default email template | |
set_user_variables(client) #set %greetings, %signature, %home_title, etc. variables | |
mail(:from => email_from, | |
:to => client.email, | |
:subject => @title) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment