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