Permalink
Browse files

Would it have killed Google to preparse email addresses?

  • Loading branch information...
1 parent c470f2b commit 260d36786439405396f9db361dc972ec2d87743d @kushal committed Jan 10, 2011
Showing with 13 additions and 19 deletions.
  1. +1 −0 dateutil.py
  2. +3 −3 emails.py
  3. +2 −10 main.py
  4. +3 −2 model.py
  5. +1 −1 receive_email.py
  6. +2 −2 templates/index.html
  7. +1 −1 templates/user.html
View
@@ -39,6 +39,7 @@ def date_for_new_snippet():
aligned = today + datetime.timedelta(days=(7 - today.weekday()))
return aligned
+
def date_for_retrieval():
"""Always return the most recent Monday."""
today = datetime.datetime.now(Eastern_tzinfo()).date()
View
@@ -25,7 +25,7 @@ def get(self):
all_users = User.all().filter("enabled =", True).fetch(500)
for user in all_users:
# TODO: Check if one has already been submitted for this period.
- self.__send_mail(user.user.email())
+ self.__send_mail(user.email)
class DigestEmail(webapp.RequestHandler):
def __send_mail(self, recipient, body):
@@ -36,7 +36,7 @@ def __send_mail(self, recipient, body):
def __snippet_to_text(self, snippet):
divider = '-' * 30
- return '%s\n%s\n%s' % (snippet.user.user.email(), divider, snippet.text)
+ return '%s\n%s\n%s' % (snippet.user.email, divider, snippet.text)
def get(self):
all_users = User.all().filter("enabled =", True).fetch(500)
@@ -45,4 +45,4 @@ def get(self):
# TODO: Build custom emails
body = '\n\n\n'.join([self.__snippet_to_text(s) for s in all_snippets])
for user in all_users:
- self.__send_mail(user.user.email(), body)
+ self.__send_mail(user.email, body)
View
12 main.py
@@ -34,9 +34,9 @@ def get_user(self):
self.redirect(users.create_login_url(self.request.uri))
return None
- userObj = User.all().filter("user =", user).fetch(1)
+ userObj = User.all().filter("email =", user.email()).fetch(1)
if not userObj:
- userObj = User(user=user)
+ userObj = User(email=user.email())
userObj.put()
else:
userObj = userObj[0]
@@ -72,13 +72,6 @@ def authed_get(self, user):
self.response.out.write(template.render(path, template_values))
-class FollowHandler(BaseHandler):
- """Change acting user's follow relationship with another user."""
-
- def authed_post(self, user):
- pass
-
-
class MainHandler(BaseHandler):
"""Show list of all users and acting user's settings."""
@@ -108,7 +101,6 @@ def main():
application = webapp.WSGIApplication(
[('/', MainHandler),
('/user', UserHandler),
- ('/follow', FollowHandler),
('/reminderemail', ReminderEmail),
('/digestemail', DigestEmail)],
debug=True)
View
@@ -4,7 +4,8 @@
from google.appengine.ext import db
class User(db.Model):
- user = db.UserProperty()
+ # Just store email address, because GAFYD seems to be buggy (omits domain in stored email or something...)
+ email = db.StringProperty()
following = db.ListProperty(db.Key)
enabled = db.BooleanProperty(default=True)
@@ -14,7 +15,7 @@ class Snippet(db.Model):
date = db.DateProperty()
def user_from_email(email):
- return User.all().filter("user =", users.User(email)).fetch(1)[0]
+ return User.all().filter("email =", email).fetch(1)[0]
def create_or_replace_snippet(user, text, date):
# Delete existing (yeah, yeah, should be a transaction)
View
@@ -13,7 +13,7 @@ class ReceiveEmail(InboundMailHandler):
"""Receive a snippet email and create or replace snippet for this week."""
def receive(self, message):
- user = user_from_email(message.sender)
+ user = user_from_email(email.utils.parseaddr(message.sender)[1])
for content_type, body in message.bodies('text/plain'):
create_or_replace_snippet(user, body.decode(), date_for_new_snippet())
View
@@ -1,7 +1,7 @@
{% extends "base.html" %}
{% block body %}
- <h2><a href="/user?email={{ current_user.user.email }}">{{ current_user.user.email }}</a></h2>
+ <h2><a href="/user?email={{ current_user.email }}">{{ current_user.email }}</a></h2>
currently
{% if current_user.enabled %}
<b>enabled</b> <a href="?setenabled=0">disable</a>
@@ -11,7 +11,7 @@
<h3>Users</h3>
{% for user in all_users %}
- <a href="/user?email={{ user.user.email }}">{{ user.user.email }}</a>
+ <a href="/user?email={{ user.email }}">{{ user.email }}</a>
<br/>
{% endfor %}
View
@@ -1,7 +1,7 @@
{% extends "base.html" %}
{% block body %}
- <h2>{{ user.user.email }}</h2>
+ <h2>{{ user.email }}</h2>
{% for snippet in snippets %}
<b>{{ snippet.date }}</b><br/>

0 comments on commit 260d367

Please sign in to comment.