diff --git a/tailbone/views/email.py b/tailbone/views/email.py index de700260..111589c5 100644 --- a/tailbone/views/email.py +++ b/tailbone/views/email.py @@ -29,7 +29,7 @@ from __future__ import unicode_literals, absolute_import import six from rattail import mail -from rattail.db import api +from rattail.db import api, model from rattail.config import parse_list import colander @@ -289,7 +289,65 @@ class EmailPreview(View): "Send preview email") +class EmailAttemptView(MasterView): + """ + Master view for email attempts. + """ + model_class = model.EmailAttempt + route_prefix = 'email_attempts' + url_prefix = '/email/attempts' + creatable = False + editable = False + deletable = False + + labels = { + 'status_code': "Status", + } + + grid_columns = [ + 'key', + 'sender', + 'subject', + 'to', + 'sent', + 'status_code', + ] + + form_fields = [ + 'key', + 'sender', + 'subject', + 'to', + 'cc', + 'bcc', + 'sent', + 'status_code', + 'status_text', + ] + + def configure_grid(self, g): + super(EmailAttemptView, self).configure_grid(g) + + # sent + g.set_sort_defaults('sent', 'desc') + + # status_code + g.set_enum('status_code', self.enum.EMAIL_ATTEMPT) + + # links + g.set_link('key') + g.set_link('sender') + g.set_link('subject') + g.set_link('to') + + def configure_form(self, f): + super(EmailAttemptView, self).configure_form(f) + + # status_code + f.set_enum('status_code', self.enum.EMAIL_ATTEMPT) + def includeme(config): ProfilesView.defaults(config) EmailPreview.defaults(config) + EmailAttemptView.defaults(config)