Queries implemented

This commit is contained in:
José Carlos Cuevas 2013-06-04 01:40:53 +02:00
parent 055600e611
commit a47943e5f9

33
app.py
View file

@ -26,6 +26,7 @@ urls = (
'/app/player_edit/(.+)', 'edit_player',
'/app/config', 'config',
'/app/config/', 'config',
'/query/(.+)', 'query',
)
# Forms used by the app
@ -354,5 +355,37 @@ class config(object):
return "Ooops! Something went wrong."
class query(object):
def GET(self, uuid):
for p in db.select('players', where = 'code = $uuid', vars = locals()):
player = p
name = player.name
stats = []
for stat in db.select('stats'):
default_value = stat.default_value
stat_name = stat.name
stat_id = stat.id
sheet_stat = None
query = db.select('sheet',
where = 'stat_id = $stat_id AND player_name = $name',
vars = locals())
for elem in query:
sheet_stat = elem
if sheet_stat is not None:
stat_value = sheet_stat.value
else:
stat_value = default_value
stats.append(stat_name + ":" + str(stat_value))
result = name + "--" + ",".join(stats)
return result
if __name__ == "__main__":
app.run()