diff --git a/files/routes/comments.py b/files/routes/comments.py index 82d84a87a6..ae574206ac 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -290,17 +290,23 @@ def comment(v): copyfile(oldname, filename) process_image(filename, 200) - hat = HatDef( + hat_def = HatDef( name=name, description=hat["description"], author_id=user.id, price=hat["price"] ) + g.db.add(hat_def) + g.db.flush() + + hat = Hat( + user_id=user.id, + hat_id=hat_def.id + ) g.db.add(hat) all_by_author = g.db.query(HatDef).filter_by(author_id=user.id).count() - # off-by-one: newly added hat isn't counted if all_by_author >= 250: badge_grant(badge_id=166, user=user) elif all_by_author >= 100: diff --git a/files/routes/hats.py b/files/routes/hats.py index 7bdfe89693..2ad3793767 100644 --- a/files/routes/hats.py +++ b/files/routes/hats.py @@ -58,11 +58,10 @@ def buy_hat(v, hat_id): g.db.add(v) g.db.add(hat.author) - if v.id != hat.author.id: - send_repeatable_notification( - hat.author.id, - f":marseycapitalistmanlet: @{v.username} has just bought `{hat.name}`, you have received your 10% cut ({int(hat.price * 0.1)} {currency}) :!marseycapitalistmanlet:" - ) + send_repeatable_notification( + hat.author.id, + f":marseycapitalistmanlet: @{v.username} has just bought `{hat.name}`, you have received your 10% cut ({int(hat.price * 0.1)} {currency}) :!marseycapitalistmanlet:" + ) if v.num_of_owned_hats >= 250: badge_grant(user=v, badge_id=154)