This repository has been archived by the owner on Feb 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Forgot json file. This keeps happening #110
- Loading branch information
1 parent
f6eaaa5
commit 3f97b17
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |