from django import template
+register = template.Library()
+
+class MultiUserMailMessage(template.Node):
+ def __init__(self, nodelist):
+ self.nodelist = nodelist
+
+ def render(self, context):
+ recipients = context['recipients']
+ messages = list()
+
+ for recipient in recipients:
+ context['recipient'] = recipient
+ self.nodelist.render(context)
+ messages.append((recipient, context['subject'], context['html_content'], context['text_content']))
+
+ print messages
+
+@register.tag
+def email(parser, token):
+ nodelist = parser.parse(('endemail',))
+ parser.delete_first_token()
+ return MultiUserMailMessage(nodelist)
+
+
+
+class EmailPartNode(template.Node):
+ def __init__(self, nodelist, varname):
+ self.nodelist = nodelist
+ self.varname = varname
+
+ def render(self, context):
+ context[self.varname] = self.nodelist.render(context).strip()
+
+@register.tag
+def subject(parser, token):
+ nodelist = parser.parse(('endsubject',))
+ parser.delete_first_token()
+ return EmailPartNode(nodelist, 'subject')
+
+@register.tag
+def htmlcontent(parser, token):
+ nodelist = parser.parse(('endhtmlcontent',))
+ parser.delete_first_token()
+ return EmailPartNode(nodelist, 'html_content')
+
+@register.tag
+def textcontent(parser, token):
+ nodelist = parser.parse(('endtextcontent',))
+ parser.delete_first_token()
+ return EmailPartNode(nodelist, 'text_content')
+
+
+++ /dev/null
-import unittest
-from django.test.client import Client
-
-import forum.startup
-
-from forum.models import *
-from forum.actions import *
-
-client = Client()
-
-class SanityTest(unittest.TestCase):
- def testIndex(self):
- self.assertEquals(client.get('/').status_code, 200)
-
-class FirstUsersTest(unittest.TestCase):
- def setUp(self):
- self.response = client.get('/')
-
- def testResponse(self):
- self.assertEquals(self.response.status_code, 200)
-
-
-