|
|
|
|
@ -168,11 +168,12 @@ class NewsLetterSender(object): |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
content_html = self.build_email_content(contact, announce_context) |
|
|
|
|
content_html = content_html.format( |
|
|
|
|
**{ |
|
|
|
|
'name': name or contact.first_name or contact.last_name or _(u'Подписчик') |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
if '{name}' in content_html: |
|
|
|
|
content_html = content_html.format( |
|
|
|
|
**{ |
|
|
|
|
'name': name or contact.first_name or contact.last_name or _(u'Подписчик') |
|
|
|
|
} |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
h = HTMLParser.HTMLParser() |
|
|
|
|
content_html = h.unescape(content_html) |
|
|
|
|
@ -349,7 +350,6 @@ class NewsLetterSender(object): |
|
|
|
|
logo_path = default_storage.path('newsletter/images/no-logo.png') |
|
|
|
|
elif logo and not logo_path: |
|
|
|
|
logo_path = logo.path |
|
|
|
|
print(logo, logo_path, obj) |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
ctype, encoding = mimetypes.guess_type(logo_path) |
|
|
|
|
@ -646,16 +646,18 @@ class Mailer(NewsLetterSender): |
|
|
|
|
|
|
|
|
|
expedition_list = self.expedition_list |
|
|
|
|
|
|
|
|
|
number_of_recipients = len(expedition_list) |
|
|
|
|
if self.verbose: |
|
|
|
|
print '%i emails will be sent' % number_of_recipients |
|
|
|
|
# number_of_recipients = len(expedition_list) |
|
|
|
|
# if self.verbose: |
|
|
|
|
# print '%i emails will be sent' % number_of_recipients |
|
|
|
|
|
|
|
|
|
i = 1 |
|
|
|
|
for contact in expedition_list: |
|
|
|
|
# FIXME: Временно сделана отправка только 1 письма. |
|
|
|
|
# См FIXME в команде send_newsletter |
|
|
|
|
for i, contact in enumerate(expedition_list, 1): |
|
|
|
|
print 'sending to contact id:', contact.pk |
|
|
|
|
send = True |
|
|
|
|
if self.verbose: |
|
|
|
|
print '- Processing %s/%s (%s)' % ( |
|
|
|
|
i, number_of_recipients, contact.pk) |
|
|
|
|
# if self.verbose: |
|
|
|
|
# print '- Processing %s/%s (%s)' % ( |
|
|
|
|
# i, number_of_recipients, contact.pk) |
|
|
|
|
|
|
|
|
|
# |
|
|
|
|
self.build_preheader_ctx(contact) |
|
|
|
|
@ -697,8 +699,6 @@ class Mailer(NewsLetterSender): |
|
|
|
|
self.smtp.quit() |
|
|
|
|
self.smtp_connect() |
|
|
|
|
|
|
|
|
|
i += 1 |
|
|
|
|
|
|
|
|
|
# маркируем оставшиеся контакты на второй этап |
|
|
|
|
self.mark_contacts_for_second_stage() |
|
|
|
|
|
|
|
|
|
@ -720,10 +720,13 @@ class Mailer(NewsLetterSender): |
|
|
|
|
return [] |
|
|
|
|
|
|
|
|
|
if self.newsletter.dailymail and not self.test: |
|
|
|
|
return self.newsletter.get_dailymail_subscribers() |
|
|
|
|
# FIXME: врменно добавил жёсткий срез для отправки 1 письма |
|
|
|
|
return self.newsletter.get_dailymail_subscribers()[:1] |
|
|
|
|
|
|
|
|
|
qs = super(Mailer, self).expedition_list |
|
|
|
|
|
|
|
|
|
# FIXME: врменно добавил жёсткий срез для отправки 1 письма |
|
|
|
|
self.credits = 1 |
|
|
|
|
qs = qs[:self.credits] |
|
|
|
|
|
|
|
|
|
if self.test: |
|
|
|
|
|