fix 500 error
parent
bd2ba5e372
commit
dbfd9adda7
|
@ -233,7 +233,19 @@ def award_thing(v, thing_type, id):
|
||||||
if kind == 'spider' and author.spider == 1:
|
if kind == 'spider' and author.spider == 1:
|
||||||
abort(409, f"{safe_username} already best friends with a spider!")
|
abort(409, f"{safe_username} already best friends with a spider!")
|
||||||
|
|
||||||
|
awards = g.db.query(AwardRelationship).filter(
|
||||||
|
AwardRelationship.kind == kind,
|
||||||
|
AwardRelationship.user_id == v.id,
|
||||||
|
AwardRelationship.post_id == None,
|
||||||
|
AwardRelationship.comment_id == None
|
||||||
|
).order_by(AwardRelationship.id).limit(quantity).all()
|
||||||
|
num_owned = len(awards)
|
||||||
|
|
||||||
|
if quantity > num_owned:
|
||||||
|
bought = buy_awards(v, kind, AWARDS, quantity-num_owned)
|
||||||
|
if isinstance(bought, dict):
|
||||||
|
return bought
|
||||||
|
awards.extend(bought)
|
||||||
|
|
||||||
if v.id != author.id:
|
if v.id != author.id:
|
||||||
if author.deflector and v.deflector and AWARDS[kind]['deflectable']:
|
if author.deflector and v.deflector and AWARDS[kind]['deflectable']:
|
||||||
|
@ -271,20 +283,6 @@ def award_thing(v, thing_type, id):
|
||||||
|
|
||||||
can_alter_body = not obj.author.deflector or v == obj.author
|
can_alter_body = not obj.author.deflector or v == obj.author
|
||||||
|
|
||||||
awards = g.db.query(AwardRelationship).filter(
|
|
||||||
AwardRelationship.kind == kind,
|
|
||||||
AwardRelationship.user_id == v.id,
|
|
||||||
AwardRelationship.post_id == None,
|
|
||||||
AwardRelationship.comment_id == None
|
|
||||||
).order_by(AwardRelationship.id).limit(quantity).all()
|
|
||||||
num_owned = len(awards)
|
|
||||||
|
|
||||||
if quantity > num_owned:
|
|
||||||
bought = buy_awards(v, kind, AWARDS, quantity-num_owned)
|
|
||||||
if isinstance(bought, dict):
|
|
||||||
return bought
|
|
||||||
awards.extend(bought)
|
|
||||||
|
|
||||||
for award in awards:
|
for award in awards:
|
||||||
if isinstance(obj, Post): award.post_id = obj.id
|
if isinstance(obj, Post): award.post_id = obj.id
|
||||||
else: award.comment_id = obj.id
|
else: award.comment_id = obj.id
|
||||||
|
|
Loading…
Reference in New Issue