Skip to content
This repository has been archived by the owner on Feb 8, 2018. It is now read-only.

Commit

Permalink
Forgot json file. This keeps happening #110
Browse files Browse the repository at this point in the history
  • Loading branch information
chadwhitacre committed Jul 12, 2012
1 parent f6eaaa5 commit 3f97b17
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions www/%participant_id/goal.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import locale
import decimal

from aspen import Response
from gittip import db

# ========================================================================== ^L

if user.ANON:
raise Response(404)
request.allow("POST")

goal = request.body["goal"]

if goal == "null":
goal = None
elif goal == "custom":
goal = request.body["goal_custom"]

if goal is not None:
try:
goal = decimal.Decimal(goal)
except decimal.InvalidOperation:
raise Response(400, "Bad input.")

rec = db.fetchone( "UPDATE participants SET goal=%s "
"WHERE id=%s RETURNING goal"
, (goal, user.id)
)
goal = rec['goal']
if goal is not None:
goal = locale.format("%.2f", rec['goal'], grouping=True)
response.body = {"goal": goal}

0 comments on commit 3f97b17

Please sign in to comment.