Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Adrián Ribao
Cartero
Commits
03bbb695
Commit
03bbb695
authored
Aug 30, 2016
by
Adrián Ribao
Browse files
fix interval sending
parent
72a5256c
Pipeline
#231
passed with stage
in 45 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
cartero/tasks.py
View file @
03bbb695
# -*- 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
()
cartero/utils/sending.py
View file @
03bbb695
...
...
@@ -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
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment