Skip to content

Commit

Permalink
WIP: bcc emails
Browse files Browse the repository at this point in the history
  • Loading branch information
goldpbear committed Apr 20, 2018
1 parent 44e53d5 commit 9899fc3
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 7 deletions.
43 changes: 43 additions & 0 deletions src/sa_api_v2/migrations/0007_auto_20180420_2012.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

dependencies = [
('sa_api_v2', '0006_attachment_type'),
]

operations = [
migrations.RenameField(
model_name='placeemailtemplate',
old_name='bcc_email',
new_name='bcc_email_1',
),
migrations.AddField(
model_name='placeemailtemplate',
name='bcc_email_2',
field=models.EmailField(default=None, max_length=75, blank=True),
preserve_default=True,
),
migrations.AddField(
model_name='placeemailtemplate',
name='bcc_email_3',
field=models.EmailField(default=None, max_length=75, blank=True),
preserve_default=True,
),
migrations.AddField(
model_name='placeemailtemplate',
name='bcc_email_4',
field=models.EmailField(default=None, max_length=75, blank=True),
preserve_default=True,
),
migrations.AddField(
model_name='placeemailtemplate',
name='bcc_email_5',
field=models.EmailField(default=None, max_length=75, blank=True),
preserve_default=True,
),
]
6 changes: 5 additions & 1 deletion src/sa_api_v2/models/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,11 @@ class PlaceEmailTemplate (TimeStampedModel):
event = models.CharField(max_length=128, choices=EVENT_CHOICES, default='add')
recipient_email_field = models.CharField(max_length=128)
from_email = models.EmailField()
bcc_email = models.CharField(max_length=512, blank=True, default=None)
bcc_email_1 = models.EmailField(blank=True, default=None)
bcc_email_2 = models.EmailField(blank=True, default=None)
bcc_email_3 = models.EmailField(blank=True, default=None)
bcc_email_4 = models.EmailField(blank=True, default=None)
bcc_email_5 = models.EmailField(blank=True, default=None)
subject = models.CharField(max_length=512)
body_text = models.TextField()
body_html = models.TextField(blank=True, default=None)
Expand Down
11 changes: 5 additions & 6 deletions src/sa_api_v2/views/base_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,11 @@ 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
bcc_list =[email_template.bcc_email_1,
email_template.bcc_email_2,
email_template.bcc_email_3,
email_template.bcc_email_4,
email_template.bcc_email_5]

logger.debug('[EMAIL] Got from email')

Expand Down Expand Up @@ -1262,11 +1266,6 @@ def trigger_emails(self, email_templates, obj):

logger.debug('[EMAIL] Going ahead, recipient exists')

# Set optional values
bcc_list = email_template.bcc_email.split(',')

logger.debug('[EMAIL] Got bcc email')

# If we didn't find any errors, then render the email and send.
context_data = RequestContext(self.request, {
'place': obj,
Expand Down

0 comments on commit 9899fc3

Please sign in to comment.