Permalink
Browse files

Ask for twitter

  • Loading branch information...
1 parent 3e79a73 commit 28b9fadc36b4ac38c9d7aa88eb5ee05683ed8336 @dustball dustball committed Jan 3, 2013
Showing with 69 additions and 6 deletions.
  1. +44 −3 main.py
  2. +5 −3 templates/main.html
  3. +2 −0 templates/memberlist.html
  4. +18 −0 templates/twittermail.txt
View
47 main.py
@@ -123,6 +123,7 @@ class Membership(db.Model):
first_name = db.StringProperty(required=True)
last_name = db.StringProperty(required=True)
email = db.StringProperty(required=True)
+ twitter = db.StringProperty(required=False)
plan = db.StringProperty(required=True)
status = db.StringProperty() # None, active, suspended
referrer = db.StringProperty()
@@ -173,12 +174,13 @@ def get(self):
def post(self):
first_name = self.request.get('first_name')
last_name = self.request.get('last_name')
- email = self.request.get('email').lower()
+ twitter = self.request.get('twitter').lower().strip().strip('@')
+ email = self.request.get('email').lower().strip()
plan = self.request.get('plan', 'full')
if not first_name or not last_name or not email:
self.response.out.write(render('templates/main.html', {
- 'plan': plan, 'message': "Sorry, we need all three fields."}))
+ 'plan': plan, 'message': "Sorry, we need name and e-mail address."}))
else:
# this just runs a check twice. (there is no OR in GQL)
@@ -215,7 +217,7 @@ def post(self):
# existing_member.delete()
if membership is None:
membership = Membership(
- first_name=first_name, last_name=last_name, email=email, plan=plan)
+ first_name=first_name, last_name=last_name, email=email, plan=plan, twitter=twitter)
if self.request.get('paypal') == '1':
membership.status = 'paypal'
membership.hash = hashlib.md5(membership.email).hexdigest()
@@ -795,6 +797,42 @@ def get(self):
def post(self):
fetch_usernames(use_cache=False)
+class GetTwitterHandler(webapp.RequestHandler):
+ def get(self):
+ user = users.get_current_user()
+ if not user:
+ self.redirect(users.create_login_url('/api/gettwitter'))
+ if users.is_current_user_admin():
+ need_twitter_users = Membership.all().filter('status =', 'active').fetch(1000)
+ countdown = 0
+ for u in need_twitter_users:
+ if u.username and not u.twitter:
+ self.response.out.write(u.username)
+ taskqueue.add(url='/tasks/twitter_mail', params={'user': u.key().id()}, countdown=countdown)
+ countdown += 1
+ else:
+ self.response.out.write("Need admin access")
+
+
+
+class TwitterMail(webapp.RequestHandler):
+ def post(self):
+ user = Membership.get_by_id(int(self.request.get('user')))
+ subject = "What's your twitter handle?"
+ base = self.request.host
+ body = render('templates/twittermail.txt', locals())
+ to = "%s <%s@hackerdojo.com>" % (user.full_name(), user.username)
+ bcc = "%s <%s>" % ("Brian Klug", "brian.klug@hackerdojo.com")
+ mail.send_mail(sender=EMAIL_FROM_AYST, to=to, subject=subject, body=body, bcc=bcc, html=body)
+
+class SetTwitterHandler(webapp.RequestHandler):
+ def get(self):
+ if self.request.get('user'):
+ m = Membership.get(self.request.get('user'))
+ m.twitter = self.request.get('twitter').lower().strip().strip('@')
+ m.put()
+ self.response.out.write("<p>Thanks! All set now. <p>We'll send out more information in a week or two.")
+
def main():
application = webapp.WSGIApplication([
@@ -821,10 +859,13 @@ def main():
('/areyoustillthere', AreYouStillThereHandler),
('/unsubscribe/(.*)', UnsubscribeHandler),
('/update', UpdateHandler),
+ ('/api/gettwitter', GetTwitterHandler),
+ ('/api/settwitter', SetTwitterHandler),
('/tasks/create_user', CreateUserTask),
('/tasks/clean_row', CleanupTask),
('/cron/cache_users', CacheUsersCron),
('/tasks/areyoustillthere_mail', AreYouStillThereMail),
+ ('/tasks/twitter_mail', TwitterMail),
], debug=True)
View
8 templates/main.html
@@ -11,13 +11,15 @@
<input type="hidden" name="plan" value="{{ plan }}" />
{% if paypal %}<input type="hidden" name="paypal" value="1" />{% endif %}
<table>
- <tr><td class="label">First name:</td><td><input type="text" name="first_name" /></td></tr>
- <tr><td class="label">Last name:</td><td><input type="text" name="last_name" /></td></tr>
- <tr><td class="label">Email:</td><td><input type="text" name="email" /></td></tr>
+ <tr><td class="label">First name:<sup>*</sup></td><td><input type="text" name="first_name" /></td></tr>
+ <tr><td class="label">Last name:<sup>*</sup></td><td><input type="text" name="last_name" /></td></tr>
+ <tr><td class="label">Email:<sup>*</sup></td><td><input type="text" name="email" /></td></tr>
+ <tr><td class="label">Twitter:</td><td><input type="text" name="twitter" /></td></tr>
{% if message %}<tr><td>&nbsp;</td><td style="color: red; font-size: smaller;">{{ message }}</td></tr>{% endif %}
</table>
<div style="font-size: smaller; margin-left: 216px;">How did you hear about us?<br />
<textarea name="referrer"></textarea><br />
+ <sup>*</sup> Required <br />
<input type="submit" value="Next step &rarr;" style="font-size: large; margin-top: 25px;" /><br />
</div>
<div style="background-color: lightyellow; border: 1px solid goldenrod; padding: 10px; margin-top: 40px;">We're so glad you're joining our wonderful non-profit organization to help foster hacker community! Remember, not everything is perfect yet and things move a little slower in a mostly volunteer organization, but we're constantly improving.<br /><br />
View
2 templates/memberlist.html
@@ -19,6 +19,7 @@
<td>Name</td>
<td>Username</td>
<td>Status</td>
+ <td>Twitter</td>
</tr>
{% for u in signup_users %}
@@ -27,6 +28,7 @@
<td>{{ u.last_name }}, {{ u.first_name }}</td>
<td>{{ u.username }}</td>
<td>{% ifequal u.status "active" %}current{% else %}expired{% endifequal %}</td>
+ <td><a href="http://twitter.com/{{u.twitter}}">{{u.twitter}}</a></td>
</tr>
{% endif %}
{% endfor %}
View
18 templates/twittermail.txt
@@ -0,0 +1,18 @@
+<p>Hi {{user.first_name}},</p>
+
+<p>I'm working on a online component to let Hacker Dojo members better connect with eachother.</p>
+
+<p>One simple question - what's your twitter handle?</p>
+
+<form method=GET action="http://{{base}}/api/settwitter">
+<div style="margin:2em; padding:1em; border:1px solid #ccc; width:400px">
+Your twitter handle: <input type=text name=twitter><input type=hidden name=user value={{user.key}}> <input type=submit>
+</div>
+</form>
+
+<p>(Mostly this will just be used to pull your thumbnail/picture from twitter.)<p>
+
+<p>Thanks & Happy New Years!</p>
+
+
+

0 comments on commit 28b9fad

Please sign in to comment.