From 57dc6f12d831756ce257b9917803bd7301d1eff7 Mon Sep 17 00:00:00 2001 From: Thomas Steen Rasmussen Date: Wed, 29 Jul 2020 21:07:50 +0200 Subject: [PATCH] add admin actions to hold and release emails --- src/utils/admin.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/utils/admin.py b/src/utils/admin.py index 6b710965..0d8bc8fb 100644 --- a/src/utils/admin.py +++ b/src/utils/admin.py @@ -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"