provided an interface for sending out emails anoop
authornishanth
Sun, 06 Jun 2010 17:32:50 +0530
branchanoop
changeset 56 7dfacad8adee
parent 55 1091f42e4a41
child 57 03150449a049
provided an interface for sending out emails
sdi/events.py
sdi/forms.py
sdi/site/urls.py
sdi/views.py
templates/send_invi.html
--- a/sdi/events.py	Sun Jun 06 01:31:03 2010 +0530
+++ b/sdi/events.py	Sun Jun 06 17:32:50 2010 +0530
@@ -29,3 +29,51 @@
 
     send_mail(subject, message, "sagedays@fossee.in", [email])
 
+def mail_invi(to_emails):
+    """ send the invitation email to given email addresses.
+    """
+
+    subject = "Invitation to Sage Days 25, India"
+
+    message = """
+Sage Days 25 - An Invitation
+
+What is 'Sage Days'?
+Sage Days is a confluence of present and prospective SAGE Users and Developers. It is an opportunity to come together to share ideas,
+brainstorm and hack on Sage.
+
+Sage Days 25 is the 25th version of Sage Days, and is being organized in Mumbai, India. In order to cater to an Indian audience and scenario, this version has been tweaked slightly. Sage Days 25 has beginner level tutorials, in addition to the usual talks and sprints, to help new users get started with Sage and help promote the use of Sage in India.
+
+What is Sage?
+Sage is a free, open-source mathematics software system licensed under the GPL. It combines the power of numerous existing open-source packages into a common Python-based interface. It's mission is to create a "viable free open source alternative to Magma, Maple, Mathematica and Matlab".
+
+Sage has tools for a broad range of mathematical areas like Linear Algebra, Calculus, Symbolic Math,  Plotting, Rings & Groups, Graph Theory, Number Theory and Cryptography. Essentially, "it can do anything from mapping a 12-dimensional object to calculating rainfall patterns under global warming" - as Science Daily puts it . Eager to get started? Start here. [#1]
+
+Apart from being feature rich, it's usability is one of it's greatest strengths. Sage Notebook, a web-interface for all the math you'll ever want to do, is really the killer feature! As the Sage Marketing page says, "The SAGE GUI surely works on your computer box, because it just runs in Firefox!".  Try it Now! [#2]
+
+Why should you attend?
+Sage Days 25 is being attended by the creator and lead developer of Sage, Prof. William Stein. It will also be attended by other developers of Sage. This would be a great opportunity to meet and interact with them!
+
+The conference will be attended by a plethora of enthusiastic people from all over the country who use Sage or are interested in doing so. The conference will also see the presence of many mathematicians interested in software. Who knows, you may run into someone you'd want to collaborate with, for your future work!
+
+This event will be a great learning experience, if you are even remotely interested in math and software for it!
+
+When and Where?
+Venue: IIT-Bombay, Mumbai, India
+Dates: August 9-12, 2010
+
+Tentative Schedule: http://fossee.in/sage_days/schedule/
+Register Here: http://fossee.in/sage_days/registration/register/
+
+[#1] http://www.sagemath.org/tour.html
+[#2] http://www.sagenb.org/
+
+--
+Sage Days India Team,
+FOSSEE, IIT Bombay.
+
+"""
+
+    for emails in to_emails:
+        send_mail(subject, message, "sagedays@fossee.in", emails)
+
--- a/sdi/forms.py	Sun Jun 06 01:31:03 2010 +0530
+++ b/sdi/forms.py	Sun Jun 06 17:32:50 2010 +0530
@@ -135,3 +135,15 @@
         else:
             raise forms.ValidationError("Invalid range for Likeliness of attending the workshop")
                    
+class EmailForm(forms.Form):
+    """ Take a list of csv seperated email addresses.
+    """
+
+    emails = forms.CharField(widget=forms.Textarea, required=False)
+
+    def clean_emails(self):
+        emails = self.cleaned_data['emails']
+
+        to_emails = [csv_list.split(',') for csv_list in emails.split()]
+        return to_emails
+
--- a/sdi/site/urls.py	Sun Jun 06 01:31:03 2010 +0530
+++ b/sdi/site/urls.py	Sun Jun 06 17:32:50 2010 +0530
@@ -1,11 +1,12 @@
 from django.conf.urls.defaults import *
 
 from sage_days.settings import ADMIN_URL_PREFIX as aup
-from sage_days.sdi.views import register, reg_complete, list_stats, homepage
+from sage_days.sdi.views import register, reg_complete, list_stats, homepage, mail_users
 
 urlpatterns = patterns('',
 		       (r'^register/$', register),
                        (r'^complete/$', reg_complete),
                        (r'%s/stats/$'%aup, list_stats),
+                       (r'%s/send_invi/$'%aup, send_invi),
                       )
 
--- 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")
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/send_invi.html	Sun Jun 06 17:32:50 2010 +0530
@@ -0,0 +1,15 @@
+{% extends 'base.html' %}
+{% block title %}
+Send Invitations
+{% endblock %}
+{% block content %}
+{% if form %}
+<form action="" method="post">
+{{form.as_p}}
+<input type=submit value="send mails">
+</form>
+{% else %}
+Successfully sent emails to:<br />
+{{ emails|unordered_list}}
+{% endif %}
+{% endblock %}