-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome.py
30 lines (23 loc) · 913 Bytes
/
home.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from tipfy import RequestHandler, request, Response
from tipfy.ext.jinja2 import render_template
from google.appengine.ext import db
from google.appengine.api import users
import models, quotejson
from filters import FilterCollection, filters
class HomeHandler(RequestHandler):
def get(self, **kwargs):
json = request.is_xhr or request.args.get('json', '')
response = Response(mimetype = 'application/json' if json else 'text/html')
collection = FilterCollection(filters, request, response)
q = models.accepted_quotes()
collection.add_to_query(q)
q.order('-creation_date')
if json:
out = quotejson.json(q)
else:
out = render_template(
'cppbash/home.html',
quotes = q,
filter_collection = collection)
response.response = [out]
return response