From 114304b3c92f911b43ff2302bb0dc9d0d3f4cfb5 Mon Sep 17 00:00:00 2001 From: dormantman Date: Mon, 13 Jan 2020 12:28:30 +0300 Subject: [PATCH] Reformat builder method --- apps/news/tasks.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/news/tasks.py b/apps/news/tasks.py index d46d3083..5256c598 100644 --- a/apps/news/tasks.py +++ b/apps/news/tasks.py @@ -16,7 +16,9 @@ from notification.models import Subscribe def send_email_with_news(news_ids): subscribes = Subscribe.objects.all() \ .prefetch_related('subscriber') \ - .prefetch_related('subscription_type') + .prefetch_related('subscription_type') \ + .exclude(unsubscrube_date__isnull=False) + sent_news = models.News.objects.filter(id__in=news_ids) html_template = get_template(settings.NEWS_EMAIL_TEMPLATE) @@ -25,7 +27,7 @@ def send_email_with_news(news_ids): socials = list(SiteSettings.objects.with_country().select_related('country')) socials = dict(zip(map(lambda social: social.country.code, socials), socials)) - for subscribe in subscribes.filter(unsubscribe_date=None): + for subscribe in subscribes: subscriber = subscribe.subscriber country = subscribe.subscription_type.country