Files
2013-04-04 07:19:33 -04:00

32 lines
702 B
JSON

import locale
import decimal
from aspen import Response
from gittip.utils import get_participant
# ========================================================================== ^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"].replace(',', '')
if goal is not None:
try:
goal = decimal.Decimal(goal)
except decimal.InvalidOperation:
raise Response(400, "Bad input.")
participant = get_participant(request)
participant.goal = goal
if goal is not None:
goal = locale.format("%.2f", goal, grouping=True)
response.body = {"goal": goal}