Source

article / article / views.py

Diff from to

article/views.py

+from __future__ import unicode_literals
+import re
 from datetime import datetime
 
 from django.conf import settings
                     post[i]
                 except KeyError:
                     continue
-                result = ms.listSubscribe(id=mc_id[i], email_address=post['EMAIL'])
+                if post.get('EMAIL') and re.match("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$", post.get('EMAIL')) != None:
+                    result = ms.listSubscribe(id=mc_id[i], email_address=post.get('EMAIL'))
+                else:
+                    return HttpResponse("Please enter a real email address.")
             return HttpResponse("<div class='alert-message success'><a onclick=\"$('.alert-message').hide();\" class='close'>x</a><p><strong>Well done!</strong> To complete the subscription process, please click the link in the email we just sent you.</p></div>")
         else:
             return HttpResponse("Our email provider is current experience technical difficulties.")
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.