summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFulgen301 <tokmajigeorge@gmail.com>2018-09-16 17:48:50 +0200
committerFulgen301 <tokmajigeorge@gmail.com>2018-09-16 17:48:50 +0200
commit119d2aaabedc678bd94e07d12d3192ab5ad862f1 (patch)
treeeb4ca2610997087ab6bdb538059a5964b6dbd8eb
parent0486b0801e1f5750f3e478607082552d5e7946fc (diff)
downloadparry-119d2aaabedc678bd94e07d12d3192ab5ad862f1.tar.gz
parry-119d2aaabedc678bd94e07d12d3192ab5ad862f1.zip
uploads: Fix GET /api/uploads, always return comment and vote on creationv0.1
-rw-r--r--routes/uploads.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/routes/uploads.py b/routes/uploads.py
index 3777795..40d9426 100644
--- a/routes/uploads.py
+++ b/routes/uploads.py
@@ -46,7 +46,7 @@ def _add_upload(entry : Upload, session : DBSession):
votes = session.query(Vote).filter_by(upload=entry)
e["voting"] = {
- "sum" : sum(i.vote for i in votes),
+ "sum" : sum(i.impact for i in votes),
"count" : votes.count()
}
@@ -187,16 +187,18 @@ def post_comments(id):
raise HTTPResponse("Invalid upload id", 404)
try:
- session.add(Comment(
+
+ comment = Comment(
body=request_data()["body"],
author=get_user(session),
upload=upload
- ))
+ )
except KeyError as e:
raise HTTPResponse(f"Missing json value: {e.args[0]}", 400)
+ session.add(comment)
session.commit()
- return HTTPResponse(status=201)
+ return comment.json()
@delete("/api/uploads/<id>/comments/<comment_id>")
@jwt_auth_required
@@ -241,4 +243,4 @@ def post_vote(id):
vote.impact = request_data()["impact"]
session.add(vote)
session.commit()
- return HTTPResponse(status=204)
+ return vote.json()