]> git.openstreetmap.org Git - osqa.git/commitdiff
Preparation for the new mail system.
authorhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Sat, 29 May 2010 22:05:55 +0000 (22:05 +0000)
committerhernani <hernani@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Sat, 29 May 2010 22:05:55 +0000 (22:05 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@343 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/forms.py
forum/templatetags/email_tags.py
forum/tests.py [deleted file]

index 66d78b2f75f3f916c9becc789094c20e1eba56c5..0a5afe39f3ce590124e158af0004ae7e10ea113d 100644 (file)
@@ -252,9 +252,7 @@ class EditUserForm(forms.Form):
         self.user = user
 
     def clean_email(self):
-        """For security reason one unique email in database"""
         if self.user.email != self.cleaned_data['email']:
-            #todo dry it, there is a similar thing in openidauth
             if settings.EMAIL_UNIQUE == True:
                 if 'email' in self.cleaned_data:
                     try:
index 0f62badb4f4d2b4de044fbf1389749171c505d14..35971124cab0c50e63171c528aeee1bed5dd3609 100644 (file)
@@ -1,2 +1,54 @@
 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')
+
+
diff --git a/forum/tests.py b/forum/tests.py
deleted file mode 100644 (file)
index 194262e..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-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)
-        
-
-