First commit

This commit is contained in:
michail 2019-09-27 11:14:18 +05:00
parent 94bd07d31d
commit b1b9ab5ab2
2 changed files with 34 additions and 0 deletions

View File

@ -1,5 +1,9 @@
from django.contrib import admin
from news import models
from notification.models import Subscriber
from .tasks import send_email_with_news
from establishment.tasks import recalculate_price_levels_by_country
@admin.register(models.NewsType)
@ -9,6 +13,24 @@ class NewsTypeAdmin(admin.ModelAdmin):
list_display_links = ['id', 'name']
def send_email_action(modeladmin, request, queryset):
print(queryset)
news_ids = [n.id for n in queryset]
print(news_ids)
# send_email_with_news.delay(news_ids)
recalculate_price_levels_by_country.delay(news_ids)
print("TEST send_email_action IS CALLED!")
return
send_email_action.short_description = "Send the selected news by email"
@admin.register(models.News)
class NewsAdmin(admin.ModelAdmin):
"""News admin."""
actions = [send_email_action]

12
apps/news/tasks.py Normal file
View File

@ -0,0 +1,12 @@
from celery import shared_task
from notification.models import Subscriber
@shared_task
def send_email_with_news(news):
print(news)
print("EMAILS WAS SENT!")
return news