-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Place email template improvements #120
Merged
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5929470
refactor(place emails): support multiple BCC emails
goldpbear 3478f66
refactor(place emails): send emails to BCC list even when no recipien…
goldpbear 18db98f
refactor(place emails): remove check for email submitter field
goldpbear 4425061
WIP: bcc emails
goldpbear ee3731b
WIP: bcc emails
goldpbear 44e53d5
WIP: bcc emails
goldpbear d696aed
WIP: bcc emails
goldpbear 2ed1923
refactor: address review feedback
goldpbear File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1231,6 +1231,7 @@ def trigger_emails(self, email_templates, obj): | |
logger.info('[EMAIL] Starting email send') | ||
|
||
from_email = email_template.from_email | ||
bcc_email = email_template.bcc_email | ||
|
||
logger.debug('[EMAIL] Got from email') | ||
|
||
|
@@ -1241,9 +1242,7 @@ def trigger_emails(self, email_templates, obj): | |
recipient_email = self.request.DATA[email_field] | ||
logger.debug('[EMAIL] recipient_email: ' + recipient_email) | ||
except KeyError: | ||
errors.append("No '%s' field found on the place. " | ||
"Be sure to configure the 'notifications.submitter_" | ||
"email_field' property if necessary." % (email_field,)) | ||
recipient_email = "" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps we can add a |
||
|
||
logger.debug('[EMAIL] Got to email') | ||
|
||
|
@@ -1256,14 +1255,15 @@ def trigger_emails(self, email_templates, obj): | |
|
||
logger.debug('[EMAIL] Going ahead, no errors') | ||
|
||
# If the user didn't provide an email address, then no need to go further. | ||
if not recipient_email: | ||
# If the user didn't provide an email address, or no BCC emails are provided, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "or" -> "and" |
||
# then no need to go further. | ||
if not recipient_email and not bcc_email: | ||
return | ||
|
||
logger.debug('[EMAIL] Going ahead, recipient exists') | ||
|
||
# Set optional values | ||
bcc_list = [email_template.bcc_email] | ||
bcc_list = email_template.bcc_email.split(',') | ||
|
||
logger.debug('[EMAIL] Got bcc email') | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, can we make this an array of models.EmailField, and rename the field to
bcc_emails
? It would be a bit cleaner and allow us to retain email validation.Note that we will have to migrate the email in the existing
bcc_email
field, if present, and add it to be the first item in the array. We can add this to the migration itself, or we can do this manually, if it is simpler.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess is it will be simpler to do this manually, since I think we only have one email template in use at the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might be missing something, but from what I can tell
ArrayField
is a Django 1.8+ feature: https://docs.djangoproject.com/en/2.0/ref/contrib/postgres/fields/#arrayfield.Is there another way to have arrays of fields? Maybe a simpler approach for the time being would be to just hard-code a fixed number of BCC
EmailField
s, like 5 or so, and we'd just be limited to having 5 BCC emails on our templates.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that's a reasonable idea :-)