Permalink
Browse files

Mail is working, is very hard to test, and it will need to change the…

… from field, but its working
  • Loading branch information...
1 parent 37ee557 commit 48817eb8caede85681c85863d8834feb29ca2265 @DFectuoso DFectuoso committed Apr 28, 2010
Showing with 19 additions and 6 deletions.
  1. +1 −1 app.yaml
  2. +18 −5 main.py
View
@@ -1,4 +1,4 @@
-application: hackerdojo-log
+application: hackerdojo-log-dfect
version: 1
runtime: python
api_version: 1
View
23 main.py
@@ -1,6 +1,7 @@
import logging
import urllib
+from google.appengine.api import mail
from google.appengine.ext import webapp, db
from google.appengine.api import urlfetch, memcache, users
from google.appengine.ext.webapp import util, template
@@ -40,6 +41,21 @@ def fullname(username):
else:
return fullname
+def str_to_bool(str):
+ if str == "true": return True
+ else: return False
+
+def sendNotifyIoNotifications(comment):
+ profile = Profile.all().filter('emailNotification =',True)
+
+def sendEmailNotifications(update):
+ message = mail.EmailMessage(sender="HD-Logs <santiago1717@gmail.com>",subject="New Log")
+ message.body = "Someone just posted on HD-Logs\n Log: " + update.body + "\n Wrote by:" + update.user_fullname()
+ profiles = Profile.all().filter('emailNotification =',True)
+ for profile in profiles:
+ message.to = str(profile.user)
+ message.send()
+
# Worket to handle the fullname queue request.
class UserWorker(webapp.RequestHandler):
def post(self):
@@ -127,6 +143,8 @@ def get(self):
def post(self):
update = Update(body=self.request.get('body'))
+ sendEmailNotifications(update)
+ sendNotifyIoNotifications(update)
update.put()
self.redirect('/')
@@ -142,10 +160,6 @@ def post(self):
user.notifyIoNotification = str_to_bool(self.request.get('enable'))
user.put()
-def str_to_bool(str):
- if str == "true": return True
- else: return False
-
def main():
application = webapp.WSGIApplication([
('/', MainHandler),
@@ -157,6 +171,5 @@ def main():
], debug=True)
util.run_wsgi_app(application)
-
if __name__ == '__main__':
main()

0 comments on commit 48817eb

Please sign in to comment.