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):
|
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)
|
send_email_with_news.delay(news_ids)
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
send_email_action.short_description = "Send the selected news by email"
|
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):
|
def send_email_with_news(news_ids):
|
||||||
|
|
||||||
subscribers = Subscriber.objects.filter(state=Subscriber.USABLE)
|
subscribers = Subscriber.objects.filter(state=Subscriber.USABLE)
|
||||||
|
sent_news = models.News.objects.filter(id__in=news_ids)
|
||||||
|
|
||||||
for s in subscribers:
|
for s in subscribers:
|
||||||
try:
|
try:
|
||||||
for n in news_ids:
|
for n in sent_news:
|
||||||
sent_news = models.News.objects.get(id=n)
|
|
||||||
|
|
||||||
send_mail("G&M News", render_to_string(settings.NEWS_EMAIL_TEMPLATE,
|
send_mail("G&M News", render_to_string(settings.NEWS_EMAIL_TEMPLATE,
|
||||||
{"title": sent_news.title.get(s.locale),
|
{"title": sent_news.title.get(s.locale),
|
||||||
"subtitle": sent_news.subtitle.get(s.locale),
|
"subtitle": sent_news.subtitle.get(s.locale),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user