Reformat builder method

This commit is contained in:
dormantman 2020-01-13 12:28:30 +03:00 committed by Kuroshini
parent bb7cd98b98
commit 114304b3c9

View File

@ -16,7 +16,9 @@ from notification.models import Subscribe
def send_email_with_news(news_ids): def send_email_with_news(news_ids):
subscribes = Subscribe.objects.all() \ subscribes = Subscribe.objects.all() \
.prefetch_related('subscriber') \ .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) sent_news = models.News.objects.filter(id__in=news_ids)
html_template = get_template(settings.NEWS_EMAIL_TEMPLATE) 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 = list(SiteSettings.objects.with_country().select_related('country'))
socials = dict(zip(map(lambda social: social.country.code, socials), socials)) 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 subscriber = subscribe.subscriber
country = subscribe.subscription_type.country country = subscribe.subscription_type.country