Browse files

Python 2.7 & cc mode

  • Loading branch information...
1 parent 03519eb commit bf204d2ebcc764d2c078f5ecc0d88e1be2cb6507 @dustball dustball committed Apr 26, 2013
Showing with 239 additions and 25 deletions.
  1. +10 −8 app.yaml
  2. +15 −13 main.py
  3. BIN static/cc.png
  4. +12 −4 static/signin.js
  5. +202 −0 templates/cc.html
View
18 app.yaml
@@ -1,23 +1,25 @@
-application: hackerdojo-signin
+application: hd-signin-hrd
version: 1
-runtime: python
+runtime: python27
+threadsafe: true
api_version: 1
inbound_services:
- mail
builtins:
- appstats: on
-
+- deferred: on
+
handlers:
- url: /stats.*
- script: $PYTHON_LIB/google/appengine/ext/appstats/ui.py
+ script: google.appengine.ext.appstats.ui.app
- url: /static
static_dir: static
-- url: /_ah/queue/deferred
- script: $PYTHON_LIB/google/appengine/ext/deferred/handler.py
- login: admin
+#- url: /_ah/queue/deferred
+# script: google.appengine.ext.deferred.handler.app
+# login: admin
- url: .*
- script: main.py
+ script: main.app
View
28 main.py
@@ -13,12 +13,12 @@
from google.appengine.ext.webapp.util import login_required
from datetime import tzinfo, datetime, timedelta
import urllib, hashlib, time, random
-from django.utils import simplejson
import logging, email
from google.appengine.ext import webapp
from google.appengine.ext.webapp.mail_handlers import InboundMailHandler
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.api import mail
+import json
import math
import pprint
import string
@@ -32,7 +32,7 @@
MAX_SIGNIN_TIME = 60 * 60 * 8
def parse_json(data):
- return simplejson.loads(data.replace('/*-secure-','').replace('*/', ''))
+ return json.loads(data.replace('/*-secure-','').replace('*/', ''))
class DoorLog(db.Model):
event_time = db.DateTimeProperty(auto_now_add=True)
@@ -222,7 +222,7 @@ def get(self):
method=urlfetch.POST,
headers={'Content-Type': 'application/x-www-form-urlencoded'})
- self.response.out.write(simplejson.dumps(response))
+ self.response.out.write(json.dumps(response))
# Initializes SigninRecord database (see util.py)
class InitRecordsHandler(webapp.RequestHandler):
@@ -245,6 +245,12 @@ def get(self):
self.response.out.write(e.email+"\n")
# Renders the main page
+class CCHandler(webapp.RequestHandler):
+ def get(self):
+ self.response.out.write(template.render('templates/cc.html', locals()))
+
+
+# Renders the main page
class MainHandler(webapp.RequestHandler):
def get(self):
today_count = DailyCount.get()
@@ -444,9 +450,9 @@ def get(self):
door = self.request.get('door')
)
dl.put()
- self.response.out.write(simplejson.dumps({"result": "ok"}))
+ self.response.out.write(json.dumps({"result": "ok"}))
else:
- self.response.out.write(simplejson.dumps({"error": "must specify 'door' and 'status' parameters"}))
+ self.response.out.write(json.dumps({"error": "must specify 'door' and 'status' parameters"}))
class ChargeHandler(webapp.RequestHandler):
def post(self):
@@ -471,7 +477,7 @@ def post(self):
response = gateway.sale(amount, card)
d = Donation(amount=amount, transaction_id=response.trans_id, status=response.status_strings[response.status], status_code=response.status, name=name)
d.put()
- self.response.out.write(simplejson.dumps({"trans_id": response.trans_id,
+ self.response.out.write(json.dumps({"trans_id": response.trans_id,
"amount": amount,
"dollar_amount": dollar_amount,
"status": response.status_strings[response.status],
@@ -492,7 +498,7 @@ def to_dict(staffer):
created=staffer.created.strftime("%m-%d-%Y %H:%M:%S"),
refTime=datetime.now().strftime("%m-%d-%Y %H:%M:%S"),)
- self.response.out.write(simplejson.dumps([to_dict(staffer) for staffer in staff]))
+ self.response.out.write(wjson.dumps([to_dict(staffer) for staffer in staff]))
# Used to power there@hackerdojo.com - send e-mail to everyone "there" (signed in) at the Dojo
class MailHandler(InboundMailHandler):
@@ -517,9 +523,9 @@ def receive(self, mail_message):
subject="there@ bounce message",
body="Sorry, it doesn't look like anyone is signed in as staff right now.")
-def main():
- application = webapp.WSGIApplication([
+app = webapp.WSGIApplication([
('/', MainHandler),
+ ('/cc', CCHandler),
(r'^/_ah/mail/there.*', MailHandler),
('/eventmode', EventModeHandler),
('/report/donations', DonationReportHandler),
@@ -539,8 +545,4 @@ def main():
('/appreciationemail', AppreciationEmailHandler),
('/staffjson', JSONHandler),
], debug=True)
- run_wsgi_app(application)
-
-if __name__ == '__main__':
- main()
View
BIN static/cc.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
16 static/signin.js
@@ -52,12 +52,12 @@ function charge(cc,month,year,first,last) {
$('#ccamount').html(data.dollar_amount);
$('#ccthanksmessage').html(data.message+" #"+data.trans_id);
$('#ccthanks').fadeIn();
- setTimeout("$('#ccthanks').fadeOut();",6 * 1000);
+ setTimeout("$('#ccthanks').fadeOut();",15 * 1000);
} else {
$('#ccerrormessage').html(data.message);
$('#ajaxloading').hide();
$('#ccerror').fadeIn();
- setTimeout("$('#ccerror').fadeOut();",3 * 1000);
+ setTimeout("$('#ccerror').fadeOut();",7 * 1000);
}
}
});
@@ -121,7 +121,15 @@ function stopRKey(evt) {
$('#ccerrormessage').html("");
setTimeout("$('#ccerror').fadeOut();",3 * 1000);
return;
- }
+ }
+
+ if (window.cconly) {
+ auto_reset();
+ $('#ccerror').fadeIn();
+ $('#ccerrormessage').html("");
+ setTimeout("$('#ccerror').fadeOut();",3 * 1000);
+ return;
+ }
entered = $("input[name=email]").val().replace(/^\;/, "").replace(/\?$/, "");
@@ -297,7 +305,7 @@ function isEmail (s) {
/* Refresh the page every 15 minutes to clean things up, and update banner */
function refreshPage() {
$.ajax({
- url: '/',
+ url: window.cconly?'/cc':'/',
success: function(data) {
if (window.oldint) {
clearTimeout(window.oldint);
View
202 templates/cc.html
@@ -0,0 +1,202 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Donation</title>
+ <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
+ <script>window.cconly = 1;</script>
+ <script type="text/javascript" src="/static/md5.js"></script>
+ <script type="text/javascript" src="/static/signin.js?v=13"></script>
+ <link rel="stylesheet" type="text/css" href="/static/signin.css?v=11" />
+</head>
+<body id="body">
+
+{% if today_count_signigicant %}
+<div style="text-align:center; font-size:18px; position:absolute; background:#f9f9f9; top:12px; right:12px; border:1px solid #ccc; padding:.5em; -webkit-border-radius: 7px; -moz-border-radius: 7px; border-radius: 7px;" id="banner">
+ <span id="todaycount">{{today_count}}</span> sign-ins today
+ <br />
+ ~ {{day}} ~
+</div>
+{% endif %}
+
+<div id="auto" class="corners" style="padding:1em; display:none; position:absolute; z-index:20; top:-12px; right:-12px; width:20%; border:2px solid #90900f; background:#ffffa0 ">
+ <center>
+ Auto Sign In
+ <img id="count" src="/static/countdown.gif" style="margin:1em" align="absmiddle" />
+ </center>
+</div>
+
+<div id="tos" class="corners" style="display:none; position:absolute; z-index:2; top:10%; left:10%; width:80%; height:80%; border:2px solid black; background:white ">
+ <iframe style="border:none" border=0 width=100% src="https://hackerdojo.pbworks.com/api_v2/op/GetPage/page/Policies/_type/html" height=80%>
+ </iframe>
+ <center>
+ <input style="margin:1em" type=button onclick="thanks();" value="I agree to the terms above" />
+ </center>
+</div>
+
+<div id="rfidwelcome" class="corners" style="display:none; position:absolute; z-index:2; top:05%; left:15%; width:70%; border:2px solid black; background:#dbf2dc; padding:1em">
+ <h2 style="margin:0">
+ Welcome
+ <span class="rfidname">Name</span>
+ </h2>
+
+ <p style="font-size:24px; margin-bottom:1em">Please choose a sign-in option.</p>
+
+ <table width="80%" align="center" border="0" cellspacing="0" cellpadding="0" id="rfidtable">
+ <tr class="hrow" onclick="go('Anonymous')">
+ <td>&nbsp;
+ </td>
+ <td width="84">
+ <img height="84" width="84" src="/static/anon.png">
+ </td>
+ <td>
+ <h3 style="margin:0">Anonymous</h3>
+ </td>
+ <td>
+ <input type="button" value="1" style="border:2px solid black" />
+ </td>
+ <td>&nbsp;
+ </td>
+ </tr>
+ <tr class="hrow" onclick="go('Member')">
+ <td>&nbsp;
+ </td>
+ <td>
+ <img height="80" width="80" src="/static/anon.png" class="rfidpic" style="border:2px solid orange">
+ </td>
+ <td>
+ <h3 style="margin:0">
+ <span class="rfidname">Name</span>
+ </h3>
+ <h4 style="margin:0">Member</h4>
+ </td>
+ <td>
+ <input type="button" value="2" style="border:2px solid orange" />
+ </td>
+ <td>&nbsp;
+ </td>
+ </tr>
+ <tr class="hrow" onclick="go('StaffKey')">
+ <td>&nbsp;
+ </td>
+ <td>
+ <img height="80" width="80" src="/static/anon.png" class="rfidpic" style="border:2px solid blue">
+ </td>
+ <td>
+ <h3 style="margin:0">
+ <span class="rfidname">Name</span>
+ </h3>
+ <h4 style="margin:0">Acting as staff</h4>
+ </td>
+ <td>
+ <input type="button" value="3" style="border:2px solid blue" />
+ </td>
+ <td>&nbsp;
+ </td>
+ </tr>
+ <tr class=hrow onclick="cancel()">
+ <td>&nbsp;
+ </td>
+ <td>
+ <img height="84" width="84" src="/static/x.png">
+ </td>
+ <td>
+ <h3 style="margin:0">Cancel</h3>
+ </td>
+ <td>
+ <input type="button" value="4" style="border:2px solid red" />
+ </td>
+ <td>&nbsp;
+ </td>
+ </tr>
+ </table>
+</div>
+
+<div id="ajaxloading" class="corners" style="padding:3em; display:none; position:absolute; z-index:2; top:35%; left:35%; width:20%; border:2px solid #90900f; background:#ffffa0 ">
+ <center>
+ Please Wait
+ <img src="/static/spin1.gif" style="margin:1em" width="32" height="32" align="absmiddle" />
+ </center>
+</div>
+
+<div id="thanks" class="corners" style="padding:2em; display:none; position:absolute; z-index:2; top:35%; left:29%; width:35%; border:2px solid #227b1b; background:#b5e5b2 ">
+ <img src="/static/check.png" height="130" width="130" align="left" style="margin-right:1em">
+ <p style="text-align:center" id="thanksmessage">Thank You</p>
+</div>
+
+<div id="denied" class="corners" style="padding:4em; display:none; color:black; position:absolute; z-index:2; top:35%; left:25%; width:40%; border:2px solid red; background:#faa ">
+ <h1>
+ <center>Access Denied</center>
+ </h1>
+</div>
+
+<div id="ccerror" class="corners" style="padding:4em; display:none; color:black; position:absolute; z-index:2; top:15%; left:25%; width:40%; border:2px solid red; background:#faa ">
+ <h1><center>Credit Card Error</center></h1>
+ <h3><p style="text-align:center" id="ccerrormessage">&nbsp;</p></h3>
+ </h1>
+</div>
+
+<div id="ccthanks" class="corners" style="padding:2em; display:none; position:absolute; z-index:2; top:15%; left:29%; width:35%; border:2px solid #227b1b; background:#b5e5b2 ">
+ <img src="/static/check.png" height="130" width="130" align="left" style="margin-right:1em">
+ <p style="text-align:center; font-size:180%" id="ccamount">&nbsp;</p>
+ <p style="text-align:center" >THANK YOU</p>
+ <p style="text-align:center; font-weight:normal; font-size:85%" id="ccthanksmessage">&nbsp;</p>
+</div>
+
+<div id="dojodomain" class="corners" style="padding:2em; display:none; color:black; position:absolute; z-index:2; top:15%; left:15%; width:60%; border:2px solid red; background:#faa ">
+ <h2 style="margin-top:0">Please use your @hackerdojo.com address</h2>
+ <ul class="domainbenefits">
+ <li>Every member gets a <code>@hackerdojo.com</code> account
+ <li>Your <code>@hackerdojo.com</code> account is used for all kinds of things at the Dojo: e-mail, RFID keys, event hosting, signin, kudos, etc.
+ <li>You probably already have one in the form of <code>firstname.lastname@hackerdojo.com</code>
+ <li>If you need one, you can get one at <nobr><code>http://signup.hackerdojo.com/upgrade/needaccount</code></nobr>
+ </ul>
+ <p>
+ <a href="#" onclick="$('#dojodomain').fadeOut(); $('#em').focus();">OK</a>
+ </p>
+</div>
+
+<div id="privacy" class="corners" style="padding:1em; display:none; position:absolute; z-index:2; top:25%; left:25%; width:40%; border:2px solid black; background:#dbf2dc; font-size:80% ">
+ <h2>E-mail Privacy</h2>
+ <p>The Dojo will not sell, rent, or give out your e-mail address to
+ ANYONE.</p>
+ <p>The Dojo may send you a "welcome e-mail" telling you about
+ membership, and we may contact you in the future about interesting
+ events and other happenings (which of course, you can opt-out of).</p>
+ <p>We hate spam & we're not evil ;)</p>
+ <p>
+ <a href="#" onclick="$('#privacy').fadeOut(); $('#em').focus();">Close</a>
+ </p>
+</div>
+
+<center>
+ <form id="ajax_form" onsubmit="return false;">
+
+ <img style="margin:1.5em" src="/static/cc.png" width="690" height="212" />
+
+ <h2><u>Creddit Carts Donatian Statshune</u></h2>
+
+<h5>Swipe your credit card below to donate a random<br/>amount between $0 and $20 insantlies.</h5>
+<p style="color:green; font-size:20px; font-weight:bold; position:absolute; bottom:1px; left:16px">&lt;&lt; swipe magnetic stripe facing up &lt;&lt;</p>
+
+ {% if current_event.custom_html %}
+ {{current_event.custom_html}}
+ <br>
+ <input type="button" value="Event Attendee" onclick="go('Event')" />
+ <input type="button" value="Hacker Dojo Member" onclick="clickmember()" />
+ {% else %}
+<div style="-moz-opacity:0.11; -webkit-opacity:0.11; opacity:0.11">
+ CC Data:
+ <input id="em" type="text" name="email" autocomplete="off" >
+</div>
+ </div>
+ {% endif %}
+ <input id="ttt" type="hidden" name="type" value="" />
+ </form>
+</center>
+
+<audio autobuffer nocontrols>
+<source src='/static/money.wav'>
+</audio>
+
+</body>
+</html>

0 comments on commit bf204d2

Please sign in to comment.