aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
Diffstat (limited to 'routes')
-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()