Commit 03bbb695 authored by Adrián Ribao's avatar Adrián Ribao
Browse files

fix interval sending

parent 72a5256c
Pipeline #231 passed with stage
in 45 seconds
# -*- coding: utf-8 -*-
import itertools
import logging
import time
from celery import task
......@@ -8,6 +9,9 @@ from cartero.models import Campaign
from django.utils import timezone
logger = logging.getLogger(__name__)
@task.task
def check_campaigns():
now = timezone.now()
......@@ -31,8 +35,11 @@ def check_campaigns():
for group in groups:
for contact in group:
if contact is not None:
logger.debug(
"Sending to contact: {contact}".format(contact=contact)
)
cd.send_to_contact(contact)
time.sleep(1)
time.sleep(1)
campaign.status = Campaign.SENT
campaign.save()
......@@ -2,19 +2,21 @@
import json
from StringIO import StringIO
from inlinestyler.utils import inline_css
from lxml import etree
import html2text
from django.conf import settings
from django.conf import settings
from django.contrib.sites.models import Site
from django.contrib.staticfiles.finders import find
from django.core.mail import EmailMultiAlternatives
from django.template import Template, Context
from lxml import etree
#from premailer import Premailer
from inlinestyler.utils import inline_css
from django.conf import settings
from django.core.urlresolvers import reverse
from django.core.signing import Signer
from django.core.urlresolvers import reverse
from django.template import Template, Context
from cartero.models import ShortURL, MailTracks
from django.contrib.sites.models import Site
class CampaignDeliver(object):
def __init__(self, campaign):
......@@ -74,7 +76,8 @@ class CampaignDeliver(object):
def convert_email_to_text(self, html):
h = html2text.HTML2Text()
text = h.handle(html.decode('utf-8'))
# text = h.handle(html.decode('utf-8'))
text = h.handle(html)
return text
def send_to_contact(self, contact):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment