Permalink
Browse files

Door log

  • Loading branch information...
1 parent 77cf3fa commit ee756a08c3d9b92c248e36bcb6ab4b5b28aa63f1 @dustball dustball committed Nov 11, 2012
Showing with 85 additions and 1 deletion.
  1. +36 −0 main.py
  2. +48 −0 templates/doorlog.html
  3. +1 −1 templates/main.html
View
36 main.py
@@ -34,6 +34,13 @@
def parse_json(data):
return simplejson.loads(data.replace('/*-secure-','').replace('*/', ''))
+class DoorLog(db.Model):
+ event_time = db.DateTimeProperty(auto_now_add=True)
+ door = db.StringProperty()
+ rfid_tag = db.StringProperty()
+ username = db.StringProperty()
+ status = db.StringProperty()
+
class Donation(db.Model):
amount = db.FloatProperty()
donation_time = db.DateTimeProperty(auto_now_add=True)
@@ -356,6 +363,19 @@ def get(self):
self.response.out.write(template.render('templates/donations.html', locals()))
+# Used by /report/doorlog
+class DoorLogReportHandler(webapp.RequestHandler):
+ def get(self):
+ user = users.get_current_user()
+ if not user:
+ self.redirect(users.create_login_url('/report/doorlog'))
+ if users.is_current_user_admin():
+ logs = DoorLog.all().order("-event_time").fetch(500)
+ self.response.out.write(template.render('templates/doorlog.html', locals()))
+ else:
+ self.response.out.write("Sorry, need admin access")
+
+
# Used by /stats/*
class StatsHandler(webapp.RequestHandler):
def get(self,format):
@@ -396,6 +416,20 @@ def get(self,format):
self.response.out.write("0")
self.response.out.write("\n")
+class DoorLogHandler(webapp.RequestHandler):
+ def get(self):
+ if self.request.get('door') and self.request.get('status'):
+ dl = DoorLog(
+ username = self.request.get('username'),
+ status = self.request.get('status'),
+ rfid_tag = self.request.get('rfid_tag'),
+ door = self.request.get('door')
+ )
+ dl.put()
+ self.response.out.write(simplejson.dumps({"result": "ok"}))
+ else:
+ self.response.out.write(simplejson.dumps({"error": "must specify 'door' and 'status' parameters"}))
+
class ChargeHandler(webapp.RequestHandler):
def post(self):
first_name = self.request.get('first_name')
@@ -471,9 +505,11 @@ def main():
(r'^/_ah/mail/there.*', MailHandler),
('/eventmode', EventModeHandler),
('/report/donations', DonationReportHandler),
+ ('/report/doorlog', DoorLogReportHandler),
('/ministaff', MiniStaffHandler),
('/signin', SigninHandler),
('/staff', StaffHandler),
+ ('/api/doorlog', DoorLogHandler),
('/api/charge', ChargeHandler),
('/sstats/?', StatHandler),
('/sstats/(.+)', StatsHandler),
View
@@ -0,0 +1,48 @@
+<html>
+<head>
+ <link rel="stylesheet" type="text/css" href="/static/kiosk.css" />
+ <title>Door log</title>
+</head>
+<body>
+
+<h1>Door Log</h1>
+
+<style>
+th,td {padding:6px 12px; font-size:18px}
+tr.even td {
+ background-color: #eee;
+}
+tr.odd td {
+ background-color: #fff;
+}
+.ago {
+ color:#999;
+}
+.picheight {
+ height:28px;
+}
+td,th {text-align:left}
+
+</style>
+
+<table cellspacing="0" cellpadding="0" border="0" align="center" >
+<tr>
+ <th><div class="type">Timestamp</div></th>
+ <th><div class="type">Door</div></th>
+ <th><div class="type">RFID Tag</div></th>
+ <th><div class="type">Username</div></th>
+ <th><div class="type">Status</div></th>
+</tr>
+{% for d in logs %}
+ <tr class="{% cycle even,odd %}">
+ <td><div class="type">{{ d.event_time }}</div></td>
+ <td><div class="type">{{ d.door }}</div></td>
+ <td><div class="type">{{ d.rfid_tag }}</div></td>
+ <td><div class="type">{{ d.username }}</div></td>
+ <td><div class="type">{{ d.status }}</div></td>
+ </tr>
+{% endfor %}
+</table>
+
+</body>
+</html>
View
@@ -4,7 +4,7 @@
<title>Sign in</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="/static/md5.js"></script>
- <script type="text/javascript" src="/static/signin.js?v=9"></script>
+ <script type="text/javascript" src="/static/signin.js?v=10"></script>
<link rel="stylesheet" type="text/css" href="/static/signin.css" />
</head>
<body id="body">

0 comments on commit ee756a0

Please sign in to comment.