Don't mark test emails as completed
This commit is contained in:
parent
e9e19c0db5
commit
a59ed8a7b0
|
@ -43,7 +43,7 @@ class SendCampaignThread(Thread):
|
|||
|
||||
|
||||
class SMTPEmailBackend(BaseEmailBackend):
|
||||
def send_campaign(self, request, campaign, contacts):
|
||||
def send_campaign(self, request, campaign, contacts, test_send=False):
|
||||
messages = []
|
||||
|
||||
for contact in contacts:
|
||||
|
@ -58,7 +58,10 @@ class SMTPEmailBackend(BaseEmailBackend):
|
|||
'to': [contact.email],
|
||||
'reply_to': [self.reply_to],
|
||||
})
|
||||
|
||||
campaign_thread = SendCampaignThread(
|
||||
campaign.pk, [c.pk for c in contacts], messages)
|
||||
campaign_thread.start()
|
||||
if test_send:
|
||||
# Don't mark as complete, don't worry about threading
|
||||
send_mass_html_mail(messages)
|
||||
else:
|
||||
campaign_thread = SendCampaignThread(
|
||||
campaign.pk, [c.pk for c in contacts], messages)
|
||||
campaign_thread.start()
|
||||
|
|
|
@ -16,13 +16,14 @@ def send_campaign(backend, request, campaign, contacts):
|
|||
campaign.status = CampaignStatus.SENDING
|
||||
campaign.save()
|
||||
backend.send_campaign(request, campaign, contacts)
|
||||
messages.success(request, f"Campaign sent to {len(contacts)} contacts")
|
||||
|
||||
return redirect_helper(campaign)
|
||||
|
||||
|
||||
def send_test(backend, request, campaign, test_contact):
|
||||
campaign.subject = f"[TEST] {campaign.subject}"
|
||||
backend.send_campaign(request, campaign, [test_contact])
|
||||
backend.send_campaign(request, campaign, [test_contact], test_send=True)
|
||||
messages.success(request, "Test email sent, please check your inbox")
|
||||
|
||||
return redirect_helper(campaign)
|
||||
|
|
Loading…
Reference in New Issue