First commit
This commit is contained in:
parent
94bd07d31d
commit
b1b9ab5ab2
|
|
@ -1,5 +1,9 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
from news import models
|
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)
|
@admin.register(models.NewsType)
|
||||||
|
|
@ -9,6 +13,24 @@ class NewsTypeAdmin(admin.ModelAdmin):
|
||||||
list_display_links = ['id', 'name']
|
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)
|
@admin.register(models.News)
|
||||||
class NewsAdmin(admin.ModelAdmin):
|
class NewsAdmin(admin.ModelAdmin):
|
||||||
"""News admin."""
|
"""News admin."""
|
||||||
|
actions = [send_email_action]
|
||||||
|
|
|
||||||
12
apps/news/tasks.py
Normal file
12
apps/news/tasks.py
Normal 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
|
||||||
Loading…
Reference in New Issue
Block a user