fix querysets
This commit is contained in:
parent
0578768ebd
commit
fb9e71cbdd
|
|
@ -12,11 +12,10 @@ class NewsTypeAdmin(admin.ModelAdmin):
|
|||
|
||||
|
||||
def send_email_action(modeladmin, request, queryset):
|
||||
news_ids = [n.id for n in queryset]
|
||||
news_ids = list(queryset.values_list("id", flat=True))
|
||||
|
||||
send_email_with_news.delay(news_ids)
|
||||
|
||||
return
|
||||
|
||||
|
||||
send_email_action.short_description = "Send the selected news by email"
|
||||
|
|
|
|||
|
|
@ -11,12 +11,11 @@ from smtplib import SMTPException
|
|||
def send_email_with_news(news_ids):
|
||||
|
||||
subscribers = Subscriber.objects.filter(state=Subscriber.USABLE)
|
||||
sent_news = models.News.objects.filter(id__in=news_ids)
|
||||
|
||||
for s in subscribers:
|
||||
try:
|
||||
for n in news_ids:
|
||||
sent_news = models.News.objects.get(id=n)
|
||||
|
||||
for n in sent_news:
|
||||
send_mail("G&M News", render_to_string(settings.NEWS_EMAIL_TEMPLATE,
|
||||
{"title": sent_news.title.get(s.locale),
|
||||
"subtitle": sent_news.subtitle.get(s.locale),
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user