[newmaint-site] Notification on process progress using signals

Marco Bardelli bardelli.marco at gmail.com
Fri Aug 30 21:19:30 UTC 2013


Hi nm.d.o devels,

I worked on an e-mail notification system based on models saving
signals.

I agree with this:
http://www.martin-geber.com/thought/2007/10/29/django-signals-vs-custom-save-method/

so I thought mail sending has to be triggered by a detached thread on
'post_save' Process, to ensure that the database is coherent with
notifications.

In order to compose emails by using the django template system,
I saved the templates under /templates/notification_mails, but
we can surely choose a better place.

For testing purposes I setup in my local_setting.py:
EMAIL_BACKEND = 'django.core.mail.backends.filebased.EmailBackend'
EMAIL_FILE_PATH = '/tmp/nm_notification_mails'
and also a logger 'notification-dbg' with a 'logging.FileHandler',
I left in some places in the patch, something like:
    l = getLogger('notification-dbg')
    l.debug("[Notifier] begin evaluation")
only for testing purpose.

Concerning the email templates I wrote, that are obviously to be
corrected, I am a bit confused on this example:
https://lists.debian.org/debian-newmaint/2009/04/msg00026.html
because in the db there are no AM consideratons (P&P,T&S) that are
instead present in the announcement example.
This could be maybe solved by using a particular Log stored in the db.

So if we really need to inject some arbitrary texts in the announcement
mail without storing them in the database, models' signals are not enough,
I think. Maybe a "view-driven approach" should be followed, but it would be
a bit sad to impose to AM a web tool to compose an email.

I hope that the algorithm implemented in
backend.notifications.maybe_notify_applicant_on_process
is correct, triple check it please.

Attached, you will also find a README.md correction for south and markdown.

Best regards,
Marco

-------------- next part --------------
Signed-off-by: Marco Bardelli <bardelli.marco at gmail.com>
---
 backend/models.py                                  |  92 ++++++++++++++
 backend/notifications.py                           | 141 +++++++++++++++++++++
 .../notification_mails/am_approved_applicant.txt   |  96 ++++++++++++++
 .../am_assigned_to_applicant.txt                   |  11 ++
 .../notification_mails/fd_approved_applicant.txt   |  11 ++
 .../public_am_approved_applicant.txt               | 100 +++++++++++++++
 6 files changed, 451 insertions(+)
 create mode 100644 backend/notifications.py
 create mode 100644 templates/notification_mails/am_approved_applicant.txt
 create mode 100644 templates/notification_mails/am_assigned_to_applicant.txt
 create mode 100644 templates/notification_mails/fd_approved_applicant.txt
 create mode 100644 templates/notification_mails/public_am_approved_applicant.txt

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Notification-on-process-progress-using-signals-to-be.patch
Type: text/x-patch
Size: 20721 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/newmaint-site/attachments/20130830/36b95485/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/x-patch
Size: 462 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/newmaint-site/attachments/20130830/36b95485/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/newmaint-site/attachments/20130830/36b95485/attachment.sig>


More information about the newmaint-site mailing list