Advertisement
Guest User

Untitled

a guest
Dec 19th, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. def confirmed_email_notification(sender, **kwargs):
  2. """
  3. Sends an email notification to the shop owner when a new order is
  4. completed.
  5. """
  6. print "EMAIL NOTIFICATION "
  7. subject_template_name = 'shop_simplenotifications/confirmed_subject.txt'
  8. body_template_name = 'shop_simplenotifications/confirmed_body.html'
  9. request = kwargs.get('request')
  10. order = kwargs.get('order')
  11. subject = loader.render_to_string(
  12. subject_template_name,
  13. RequestContext(request, {'order': order})
  14. )
  15. subject = subject.join(subject.splitlines())
  16. body = loader.render_to_string(
  17. body_template_name,
  18. RequestContext(request, {'order': order})
  19. )
  20. from_email = getattr(settings, 'SN_FROM_EMAIL',
  21. settings.DEFAULT_FROM_EMAIL)
  22. owners = getattr(settings, 'SN_OWNERS', settings.ADMINS)
  23. send_mail(subject, body, from_email,
  24. [owner[1] for owner in owners], fail_silently=False)
  25. print body
  26. print [owner[1] for owner in owners]
  27. confirmed.connect(confirmed_email_notification)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement