Skip to content

Commit

Permalink
submitting reports working
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Reyes committed Oct 31, 2011
1 parent f8f4d62 commit 5a28270
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 44 deletions.
2 changes: 1 addition & 1 deletion app.yaml
@@ -1,5 +1,5 @@
application: cmufreenoms
version: 1
version: 2
runtime: python
api_version: 1

Expand Down
Binary file removed images/rageface.cur
Binary file not shown.
28 changes: 22 additions & 6 deletions main.py
Expand Up @@ -16,24 +16,40 @@
#

import os
import cgi
from google.appengine.ext import db
from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.ext.webapp import template


class Report(db.Model):
type = db.StringProperty()
location = db.StringProperty()
date = db.DateTimeProperty(auto_now_add = True)

class MainHandler(webapp.RequestHandler):
def get(self):
reports = Report.all().fetch(100)

path = templatePath('views/index.html')
template_values = {}
template_values = {"reports": reports}
self.response.out.write(template.render(path,template_values))

class ReportHandler(webapp.RequestHandler):
def get(self):
rtype = cgi.escape(self.request.get("type"))
rlocation = cgi.escape(self.request.get("location"))

report = Report(type = rtype, location = rlocation)
report.put()

def main():
application = webapp.WSGIApplication([('/', MainHandler)],
debug=True)
util.run_wsgi_app(application)

routes = [
('/', MainHandler),
('/report', ReportHandler)
]
application = webapp.WSGIApplication(routes, debug=True)
util.run_wsgi_app(application)

def templatePath(path):
return os.path.join(os.path.dirname(__file__), path)
Expand Down
3 changes: 3 additions & 0 deletions report.py
@@ -0,0 +1,3 @@
class Report(db.Model):
type = db.StringProperty()
location = db.StringProperty()
30 changes: 4 additions & 26 deletions scripts/index.js
@@ -1,26 +1,4 @@
function addNom(pnom) {
var green = Math.random();

var newSpan = document.createElement("span");

if (green > .85) {
newSpan.className = "greenNom";
newSpan.appendChild(document.createTextNode("NOM! "));
} else {
newSpan.appendChild(document.createTextNode("nom "));
}

$(newSpan).bind("mouseover",
function() {
$(newSpan).fadeOut()
});
pnom.appendChild(newSpan);
}

window.onload = function() {
var pnom = document.getElementById("noms");

setInterval(function() { addNom(pnom); }, 50);

document.body.style.cursor = "url('../images/rageface.cur'), default";
}
// Handler for .ready() called.
$(function(){

});
11 changes: 2 additions & 9 deletions stylesheets/style.css
@@ -1,13 +1,6 @@
*
{
cursor: url("../images/rageface.cur");
}

body
{
font-family: Sans-Serif;
color: white;
background-color: #333;
}

#frame
Expand All @@ -16,7 +9,7 @@ body
margin: 0 auto;
}

.greenNom
table
{
color: green;
width: 100%;
}
31 changes: 29 additions & 2 deletions views/index.html
Expand Up @@ -9,8 +9,35 @@
<body>
<div id="frame">
<h1>Free Noms!</h1>
<h2>Use mouse to eat noms!</h2>
<p id="noms"></p>
<div>
<h2>Report Free Noms</h2>
<form action="/report" method="get">
<label for="type"/>Type:</label>
<input id="type" type="text" name="type"/>

<label for="location"/>Location:</label>
<input id="location" type="text" name="location"/>

<input id="submit" type="submit" value="Report!">
</form>
</div>
<div>
<h2>Reported Noms</h2>
<table>
<tr>
<th>Type</th>
<th>Location</th>
<th>Date</th>
</tr>
{% for report in reports %}
<tr>
<td>{{ report.type }}</td>
<td>{{ report.location }}</td>
<td>{{ report.date }}</td>
</tr>
{% endfor %}
</table>
</div>
</div>
</body>
</html>

0 comments on commit 5a28270

Please sign in to comment.