37 lines
877 B
Python
37 lines
877 B
Python
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)
|
|
class NewsTypeAdmin(admin.ModelAdmin):
|
|
"""News type admin."""
|
|
list_display = ['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)
|
|
class NewsAdmin(admin.ModelAdmin):
|
|
"""News admin."""
|
|
actions = [send_email_action]
|