sdi/views.py
branchanoop
changeset 56 7dfacad8adee
parent 53 b226923fbf64
child 57 03150449a049
--- a/sdi/views.py	Sun Jun 06 01:31:03 2010 +0530
+++ b/sdi/views.py	Sun Jun 06 17:32:50 2010 +0530
@@ -3,8 +3,8 @@
 
 
 from sage_days.sdi.models import Registrant
-from sage_days.sdi.forms import RegisterForm, SearchForm
-from sage_days.sdi.events import send_reg_complete_mail
+from sage_days.sdi.forms import RegisterForm, SearchForm, EmailForm
+from sage_days.sdi.events import send_reg_complete_mail, mail_invi
 
 def register(request):
     """ The user register page.
@@ -81,6 +81,23 @@
         form = SearchForm()
         return render_to_response("list_stats.html", {"form":form})
 
+def send_invi(request):
+    """ Take a list of csv email addresses and send mails to them.
+    """
+
+    if request.method == "POST":
+        form = EmailForm(request.POST)
+        if form.is_valid():
+            to_emails = form.cleaned_data['emails']
+            mail_invi(to_emails)
+            return render_to_response("send_invi.html", {"emails":to_emails})
+        else:
+            return render_to_response("send_invi.html", {"form":form})
+    else:
+        return render_to_response("send_invi.html", {"form":form})
+
+
+
 def homepage(request):
         return render_to_response("index.html")