remotes/1693045480750635534/spooky-22
Aevann1 2021-10-24 20:59:50 +02:00
parent a9c97f40f0
commit 02b1a204dc
4 changed files with 52 additions and 11 deletions

View File

@ -409,6 +409,29 @@ def buy(v, award):
if v.coins < price: return {"error": "Not enough coins."}, 400
v.coins -= price
v.coins_spent += price
if v.coins_spent >= 1000000 and not v.has_badge(73):
new_badge = Badge(badge_id=73, user_id=v.id)
g.db.add(new_badge)
old_badge = v.has_badge(72)
if old_badge: old_badge.delete()
elif v.coins_spent >= 500000 and not v.has_badge(72):
new_badge = Badge(badge_id=72, user_id=v.id)
g.db.add(new_badge)
old_badge = v.has_badge(71)
if old_badge: old_badge.delete()
elif v.coins_spent >= 250000 and not v.has_badge(71):
new_badge = Badge(badge_id=71, user_id=v.id)
g.db.add(new_badge)
old_badge = v.has_badge(70)
if old_badge: old_badge.delete()
elif v.coins_spent >= 100000 and not v.has_badge(70):
new_badge = Badge(badge_id=70, user_id=v.id)
g.db.add(new_badge)
old_badge = v.has_badge(69)
if old_badge: old_badge.delete()
elif v.coins_spent >= 10000 and not v.has_badge(69):
new_badge = Badge(badge_id=69, user_id=v.id)
g.db.add(new_badge)
g.db.add(v)
g.db.add(v)
@ -528,9 +551,13 @@ def award_post(pid, v):
elif kind == "pause":
author.mute = True
send_notification(995, f"@{v.username} bought {kind} award!")
new_badge = Badge(badge_id=68, user_id=author.id)
g.db.add(new_badge)
elif kind == "unpausable":
author.unmutable = True
send_notification(995, f"@{v.username} bought {kind} award!")
new_badge = Badge(badge_id=67, user_id=author.id)
g.db.add(new_badge)
post.author.received_award_count += 1
g.db.add(post.author)
@ -641,9 +668,13 @@ def award_comment(cid, v):
elif kind == "pause":
author.mute = True
send_notification(995, f"@{v.username} bought {kind} award!")
new_badge = Badge(badge_id=68, user_id=author.id)
g.db.add(new_badge)
elif kind == "unpausable":
author.unmutable = True
send_notification(995, f"@{v.username} bought {kind} award!")
new_badge = Badge(badge_id=67, user_id=author.id)
g.db.add(new_badge)
c.author.received_award_count += 1
g.db.add(c.author)

View File

@ -128,15 +128,6 @@ def transfer_coins(v, username):
if v.coins < amount: return {"error": f"You don't have enough {app.config['COINS_NAME']}"}, 400
if amount < 100: return {"error": f"You have to gift at least 100 {app.config['COINS_NAME']}."}, 400
v.coins -= amount
receiver.coins += amount-tax
transfer_message = f"🤑 [@{v.username}]({v.url}) has gifted you {amount} {app.config['COINS_NAME']}!"
send_notification(receiver.id, transfer_message)
g.db.add(receiver)
g.db.add(v)
if TAX_RATE and TAX_RECEIVER_ID:
tax = math.ceil(amount*TAX_RATE)
tax_receiver = g.db.query(User).filter_by(id=TAX_RECEIVER_ID).first()
@ -144,6 +135,15 @@ def transfer_coins(v, username):
log_message = f"[@{v.username}]({v.url}) has transferred {amount} {app.config['COINS_NAME']} to [@{receiver.username}]({receiver.url})"
send_notification(TAX_RECEIVER_ID, log_message)
g.db.add(tax_receiver)
receiver.coins += amount-tax
v.coins -= amount
transfer_message = f"🤑 [@{v.username}]({v.url}) has gifted you {amount} {app.config['COINS_NAME']}!"
send_notification(receiver.id, transfer_message)
g.db.add(receiver)
g.db.add(v)
g.db.commit()
return {"message": f"{amount-tax} {app.config['COINS_NAME']} transferred!"}, 200

View File

@ -274,8 +274,18 @@
{% block Banner %}
{% if '@' not in request.path %}
<style>
.banner {
margin-top: -3px;
}
@media (min-width: 992px) {
.banner {
margin-top: 10px !important;
}
}
</style>
<a rel="nofollow noopener noreferrer" href="{% if 'rama' in request.host %}https://secure.transequality.org/site/Donation2?df_id=1480{% else %}/{% endif %}">
<img loading="lazy" style="margin-top: -3px;" src="/assets/images/{{'SITE_NAME' | app_config}}/{% if v %}banner.gif{% else %}cached.gif{% endif %}" width="100%">
<img loading="lazy" class="banner" src="/assets/images/{{'SITE_NAME' | app_config}}/{% if v %}banner.gif{% else %}cached.gif{% endif %}" width="100%">
</a>
{% endif %}
{% endblock %}

View File

@ -48,7 +48,7 @@
{% else %}
<a class="mobile-nav-icon d-md-none" href="/login"><i class="fas fa-feather-alt align-middle text-gray-500 black"></i></a>
{% endif %}
<button class="navbar-toggler pr-1" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive"
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive"
aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon {% if v and v.notifications_count %}position-relative{% endif %}"><i class="fal fa-bars text-gray-500 black"></i>
{% if v and v.notifications_count %}