Revision: 123
Author: leidel
Date: Wed Oct 21 13:42:05 2009
Log: Added ability to override the default protocol in the site URL that is  
passed to the new message email with the setting DEFAULT_HTTP_PROTOCOL
http://code.google.com/p/django-messages/source/detail?r=123

Modified:
  /trunk/messages/utils.py

=======================================
--- /trunk/messages/utils.py    Wed Jan 21 01:27:18 2009
+++ /trunk/messages/utils.py    Wed Oct 21 13:42:05 2009
@@ -25,20 +25,25 @@

  def new_message_email(sender, instance, signal,
          subject_prefix=_(u'New Message: %(subject)s'),
-        template_name="messages/new_message.html", *args, **kwargs):
+        template_name="messages/new_message.html",
+        default_protocol=None,
+        *args, **kwargs):
      """
      This function sends an email and is called via Django's signal  
framework.
      Optional arguments:
          ``template_name``: the template to use
          ``subject_prefix``: prefix for the email subject.
+        ``default_protocol``: default protocol in site URL passed to  
template
      """
+    if default_protocol is None:
+        default_protocol =  
getattr(settings, 'DEFAULT_HTTP_PROTOCOL', 'http')

      if 'created' in kwargs and kwargs['created']:
          try:
              current_domain = Site.objects.get_current().domain
              subject = subject_prefix % {'subject': instance.subject}
              message = render_to_string(template_name, {
-                'site_url': 'http://%s' % current_domain,
+                'site_url': '%s://%s' % (default_protocol, current_domain),
                  'message': instance,
              })
              if instance.recipient.email != "":

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pinax-updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pinax-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to