comparison gpp/core/functions.py @ 316:767cedc7d12a

Fixing #144; integrate with new Django logging support. Also added unit tests for Donations app.
author Brian Neal <bgneal@gmail.com>
date Sun, 30 Jan 2011 20:02:32 +0000
parents e3958aacd8dd
children 20af29454e83
comparison
equal deleted inserted replaced
315:36373d995611 316:767cedc7d12a
1 """This file houses various core utility functions for GPP""" 1 """This file houses various core utility functions for GPP"""
2 import datetime 2 import datetime
3 import re 3 import re
4 import logging
4 5
5 import django.core.mail 6 import django.core.mail
6 from django.contrib.sites.models import Site 7 from django.contrib.sites.models import Site
7 from django.conf import settings 8 from django.conf import settings
8 9
21 mailer.enqueue_mail(subject, message, from_email, recipient_list) 22 mailer.enqueue_mail(subject, message, from_email, recipient_list)
22 elif settings.GPP_SEND_EMAIL: 23 elif settings.GPP_SEND_EMAIL:
23 django.core.mail.send_mail(subject, message, from_email, recipient_list, 24 django.core.mail.send_mail(subject, message, from_email, recipient_list,
24 fail_silently, auth_user, auth_password) 25 fail_silently, auth_user, auth_password)
25 26
26 import logging 27 logging.debug('EMAIL:\nFrom: %s\nTo: %s\nSubject: %s\nMessage:\n%s',
27 logging.debug('EMAIL:\nFrom: %s\nTo: %s\nSubject: %s\nMessage:\n%s' % 28 from_email, str(recipient_list), subject, message)
28 (from_email, str(recipient_list), subject, message))
29 29
30 30
31 def email_admins(subject, message): 31 def email_admins(subject, message):
32 """Emails the site admins. Goes through the site send_mail function.""" 32 """Emails the site admins. Goes through the site send_mail function."""
33 site = Site.objects.get_current() 33 site = Site.objects.get_current()
34 subject = '[%s] %s' % (site.name, subject) 34 subject = '[%s] %s' % (site.name, subject)
35 send_mail(subject, 35 send_mail(subject,
36 message, 36 message,
37 '%s@%s' % (settings.GPP_NO_REPLY_EMAIL, site.domain), 37 '%s@%s' % (settings.GPP_NO_REPLY_EMAIL, site.domain),
38 [mail_tuple[1] for mail_tuple in settings.ADMINS]) 38 [mail_tuple[1] for mail_tuple in settings.ADMINS])
39 39
40 40
41 def email_managers(subject, message): 41 def email_managers(subject, message):
42 """Emails the site managers. Goes through the site send_mail function.""" 42 """Emails the site managers. Goes through the site send_mail function."""
43 site = Site.objects.get_current() 43 site = Site.objects.get_current()
44 subject = '[%s] %s' % (site.name, subject) 44 subject = '[%s] %s' % (site.name, subject)
45 send_mail(subject, 45 send_mail(subject,
46 msg, 46 msg,
47 '%s@%s' % (settings.GPP_NO_REPLY_EMAIL, site.domain), 47 '%s@%s' % (settings.GPP_NO_REPLY_EMAIL, site.domain),
48 [mail_tuple[1] for mail_tuple in settings.MANAGERS]) 48 [mail_tuple[1] for mail_tuple in settings.MANAGERS])
49 49
50 50
51 def get_full_name(user): 51 def get_full_name(user):