add admin actions to hold and release emails

This commit is contained in:
Thomas Steen Rasmussen 2020-07-29 21:07:50 +02:00
parent e011e5d048
commit 57dc6f12d8

View file

@ -8,3 +8,18 @@ class OutgoingEmailAdmin(admin.ModelAdmin):
model = OutgoingEmail
list_display = ["subject", "to_recipients", "processed", "hold", "responsible_team"]
list_filter = ["processed", "hold", "responsible_team"]
actions = ["hold_emails", "release_emails"]
def hold_emails(self, request, queryset):
for email in queryset.filter(hold=False, processed=False):
email.hold = True
email.save()
hold_emails.description = "Mark these emails with hold=True"
def release_emails(self, request, queryset):
for email in queryset.filter(hold=True, processed=False):
email.hold = False
email.save()
release_emails.description = "Mark these emails with hold=False"