Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def create_draft(self, preview_recipients=[]):
CreateSend.api_key = settings.API_KEY
campaign = CSCampaign()
attrs = dict(
client_id=settings.CLIENT_ID,
subject=self.subject,
name=self.name,
from_name=self.from_name,
from_email=self.from_email,
reply_to=self.from_email, # TODO
html_url=self.html_url,
text_url=self.text_url,
list_ids=self.list_ids,
segment_ids=self.segment_ids,
)
try:
campaign_id = campaign.create(**attrs)
self.cm_id = campaign_id
self.status = self.STATUS_DRAFT
def send(self, confirmation_email):
if not self.cm_id:
raise ValueError("No draft created yet")
CreateSend.api_key = settings.API_KEY
campaign = CSCampaign(self.cm_id)
campaign.send(confirmation_email=confirmation_email)
self.status = self.STATUS_SENT
self.save()
from_email=self.from_email,
reply_to=self.from_email, # TODO
html_url=self.html_url,
text_url=self.text_url,
list_ids=self.list_ids,
segment_ids=self.segment_ids,
)
try:
campaign_id = campaign.create(**attrs)
self.cm_id = campaign_id
self.status = self.STATUS_DRAFT
self.save()
except BadRequest, e:
raise
if len(preview_recipients):
campaign = CSCampaign(campaign_id)
campaign.send_preview(preview_recipients)