diff options
author | Magnus Hagander | 2019-04-05 13:58:48 +0000 |
---|---|---|
committer | Magnus Hagander | 2019-04-06 09:09:27 +0000 |
commit | 5bb043c41e1d2ee2d1d026b8ecd5cc81058c59f3 (patch) | |
tree | 5859f34d249df21665042d8c11f3675acf1ab551 /postgresqleu/mailqueue/admin.py | |
parent | 05aedf5fcb4ac85bd84378a468baad2413d552ca (diff) |
Make the mail queue managable through the backend interface
This adds a viewer and editor for the mailqueue to the dashboard,
superuser only.
While at it, expose time and subject directly in the queue to make it
easier to determine what is what.
Most of the time this is not going to matter because emails are
short-lived in the queue. But during development and definitely during
debugging, it can be quite useful.
Move the "parsed mail view" out of django admin and into the backend
view so we don't have to maintain it twice. There is very little use for
the admin view anymore, so it's OK to just show the raw data there.
Diffstat (limited to 'postgresqleu/mailqueue/admin.py')
-rw-r--r-- | postgresqleu/mailqueue/admin.py | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/postgresqleu/mailqueue/admin.py b/postgresqleu/mailqueue/admin.py index 6b89205c..17e0a085 100644 --- a/postgresqleu/mailqueue/admin.py +++ b/postgresqleu/mailqueue/admin.py @@ -1,34 +1,6 @@ from django.contrib import admin -from email.parser import Parser - from .models import QueuedMail -class QueuedMailAdmin(admin.ModelAdmin): - model = QueuedMail - readonly_fields = ('parsed_content', ) - - def parsed_content(self, obj): - # We only try to parse the *first* piece, because we assume - # all our emails are trivial. - try: - parser = Parser() - msg = parser.parsestr(obj.fullmsg) - b = msg.get_payload(decode=True) - if b: - return b - - pl = msg.get_payload() - for p in pl: - b = p.get_payload(decode=True) - if b: - return b - return "Could not find body" - except Exception as e: - return "Failed to get body: %s" % e - - parsed_content.short_description = 'Parsed mail' - - -admin.site.register(QueuedMail, QueuedMailAdmin) +admin.site.register(QueuedMail) |