forked from MarseyWorld/MarseyWorld
make hat designers gets their own hat for free
parent
64f95f1fca
commit
b166fdcaf3
|
@ -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:
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue