forked from rDrama/rDrama
sneed
parent
3ec7098f35
commit
95b2fbe833
|
@ -79,15 +79,15 @@ def award_post(pid, v):
|
||||||
if post.author_id == v.id:
|
if post.author_id == v.id:
|
||||||
return jsonify({"error": "You can't award yourself."}), 403
|
return jsonify({"error": "You can't award yourself."}), 403
|
||||||
|
|
||||||
# existing_award = g.db.query(AwardRelationship).filter(
|
existing_award = g.db.query(AwardRelationship).filter(
|
||||||
# and_(
|
and_(
|
||||||
# AwardRelationship.submission_id == post.id,
|
AwardRelationship.submission_id == post.id,
|
||||||
# AwardRelationship.user_id == v.id,
|
AwardRelationship.user_id == v.id,
|
||||||
# AwardRelationship.kind == kind
|
AwardRelationship.kind == kind
|
||||||
# )
|
)
|
||||||
# ).first()
|
).first()
|
||||||
|
|
||||||
if kind not in ALLOW_MULTIPLE:
|
if existing_award and kind not in ALLOW_MULTIPLE:
|
||||||
return jsonify({"error": "You can't give that award multiple times to the same post."}), 409
|
return jsonify({"error": "You can't give that award multiple times to the same post."}), 409
|
||||||
|
|
||||||
post_award.submission_id = post.id
|
post_award.submission_id = post.id
|
||||||
|
@ -141,14 +141,15 @@ def award_comment(cid, v):
|
||||||
if c.author_id == v.id:
|
if c.author_id == v.id:
|
||||||
return jsonify({"error": "You can't award yourself."}), 403
|
return jsonify({"error": "You can't award yourself."}), 403
|
||||||
|
|
||||||
# existing_award = g.db.query(AwardRelationship).filter(
|
existing_award = g.db.query(AwardRelationship).filter(
|
||||||
# and_(
|
and_(
|
||||||
# AwardRelationship.comment_id == c.id,
|
AwardRelationship.comment_id == c.id,
|
||||||
# AwardRelationship.user_id == v.id
|
AwardRelationship.user_id == v.id,
|
||||||
# )
|
AwardRelationship.kind == kind
|
||||||
# ).first()
|
)
|
||||||
|
).first()
|
||||||
|
|
||||||
if kind not in ALLOW_MULTIPLE:
|
if existing_award and kind not in ALLOW_MULTIPLE:
|
||||||
return jsonify({"error": "You can't give that award multiple times to the same comment."}), 409
|
return jsonify({"error": "You can't give that award multiple times to the same comment."}), 409
|
||||||
|
|
||||||
comment_award.comment_id = c.id
|
comment_award.comment_id = c.id
|
||||||
|
|
Loading…
Reference in New Issue