mirror of
https://github.com/kennethreitz-archive/www.gittip.com.git
synced 2026-06-21 15:50:59 +00:00
214c6861a1
This is in part b/c the tests are failing when trying to set the goal attribute of a participant. Setting that attribute now uses the current db.session and adds a row to the goals table.
32 lines
702 B
JSON
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}
|