forked from MarseyWorld/MarseyWorld
refactor donation code
parent
f4d75100b6
commit
06a70f7fd7
|
@ -13,7 +13,8 @@ export TURNSTILE_SECRET="blahblahblah"
|
||||||
export YOUTUBE_KEY="blahblahblah"
|
export YOUTUBE_KEY="blahblahblah"
|
||||||
export VAPID_PUBLIC_KEY="blahblahblah"
|
export VAPID_PUBLIC_KEY="blahblahblah"
|
||||||
export VAPID_PRIVATE_KEY="blahblahblah"
|
export VAPID_PRIVATE_KEY="blahblahblah"
|
||||||
export GUMROAD_LINK="blahblahblah"
|
export DONATE_SERVICE="blahblahblah"
|
||||||
|
export DONATE_LINK="https://blahblahblah"
|
||||||
export CF_KEY="blahblahblah"
|
export CF_KEY="blahblahblah"
|
||||||
export CF_ZONE="blahblahblah"
|
export CF_ZONE="blahblahblah"
|
||||||
export DEBIAN_FRONTEND="noninteractive"
|
export DEBIAN_FRONTEND="noninteractive"
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
from sqlalchemy.ext.declarative import declarative_base
|
from sqlalchemy.ext.declarative import declarative_base
|
||||||
Base = declarative_base()
|
Base = declarative_base()
|
||||||
|
|
||||||
# then load our required constants...
|
|
||||||
from files.helpers.config.const import FEATURES, KOFI_TOKEN
|
|
||||||
|
|
||||||
# then load all of our classes :)
|
# then load all of our classes :)
|
||||||
from .alts import *
|
from .alts import *
|
||||||
from .clients import *
|
from .clients import *
|
||||||
|
|
|
@ -42,15 +42,14 @@ TURNSTILE_SECRET = environ.get("TURNSTILE_SECRET").strip()
|
||||||
YOUTUBE_KEY = environ.get("YOUTUBE_KEY").strip()
|
YOUTUBE_KEY = environ.get("YOUTUBE_KEY").strip()
|
||||||
VAPID_PUBLIC_KEY = environ.get("VAPID_PUBLIC_KEY").strip()
|
VAPID_PUBLIC_KEY = environ.get("VAPID_PUBLIC_KEY").strip()
|
||||||
VAPID_PRIVATE_KEY = environ.get("VAPID_PRIVATE_KEY").strip()
|
VAPID_PRIVATE_KEY = environ.get("VAPID_PRIVATE_KEY").strip()
|
||||||
GUMROAD_LINK = environ.get("GUMROAD_LINK").strip()
|
DONATE_SERVICE = environ.get("DONATE_SERVICE").strip()
|
||||||
|
DONATE_LINK = environ.get("DONATE_LINK").strip()
|
||||||
CF_KEY = environ.get("CF_KEY").strip()
|
CF_KEY = environ.get("CF_KEY").strip()
|
||||||
CF_ZONE = environ.get("CF_ZONE").strip()
|
CF_ZONE = environ.get("CF_ZONE").strip()
|
||||||
GLOBAL = environ.get("GLOBAL", "").strip()
|
GLOBAL = environ.get("GLOBAL", "").strip()
|
||||||
blackjack = environ.get("BLACKJACK", "").strip()
|
blackjack = environ.get("BLACKJACK", "").strip()
|
||||||
blackjack2 = environ.get("BLACKJACK2", "").strip()
|
blackjack2 = environ.get("BLACKJACK2", "").strip()
|
||||||
FP = environ.get("FP", "").strip()
|
FP = environ.get("FP", "").strip()
|
||||||
KOFI_TOKEN = environ.get("KOFI_TOKEN", "").strip()
|
|
||||||
KOFI_LINK = environ.get("KOFI_LINK", "").strip()
|
|
||||||
PROGSTACK_MUL = float(environ.get("PROGSTACK_MUL", 2.0))
|
PROGSTACK_MUL = float(environ.get("PROGSTACK_MUL", 2.0))
|
||||||
ENCOURAGED = environ.get("ENCOURAGED", "").strip().split()
|
ENCOURAGED = environ.get("ENCOURAGED", "").strip().split()
|
||||||
ENCOURAGED2 = environ.get("ENCOURAGED2", "").strip().split()
|
ENCOURAGED2 = environ.get("ENCOURAGED2", "").strip().split()
|
||||||
|
@ -665,8 +664,6 @@ LEADERBOARD_LIMIT = PAGE_SIZE
|
||||||
HOUSE_JOIN_COST = 500
|
HOUSE_JOIN_COST = 500
|
||||||
HOUSE_SWITCH_COST = 2000
|
HOUSE_SWITCH_COST = 2000
|
||||||
|
|
||||||
DONATE_SERVICE = "KoFi" if KOFI_TOKEN else "Gumroad"
|
|
||||||
DONATE_LINK = KOFI_LINK if KOFI_TOKEN else GUMROAD_LINK
|
|
||||||
TIERS_ID_TO_NAME = {
|
TIERS_ID_TO_NAME = {
|
||||||
1: "Paypig",
|
1: "Paypig",
|
||||||
2: "Renthog",
|
2: "Renthog",
|
||||||
|
|
|
@ -105,12 +105,11 @@ def inject_constants():
|
||||||
"PIZZASHILL_ID":PIZZASHILL_ID, "DEFAULT_COLOR":DEFAULT_COLOR,
|
"PIZZASHILL_ID":PIZZASHILL_ID, "DEFAULT_COLOR":DEFAULT_COLOR,
|
||||||
"COLORS":COLORS, "time":time, "PERMS":PERMS, "FEATURES":FEATURES,
|
"COLORS":COLORS, "time":time, "PERMS":PERMS, "FEATURES":FEATURES,
|
||||||
"HOLE_NAME":HOLE_NAME, "HOLE_STYLE_FLAIR":HOLE_STYLE_FLAIR, "HOLE_REQUIRED":HOLE_REQUIRED,
|
"HOLE_NAME":HOLE_NAME, "HOLE_STYLE_FLAIR":HOLE_STYLE_FLAIR, "HOLE_REQUIRED":HOLE_REQUIRED,
|
||||||
"GUMROAD_LINK":GUMROAD_LINK, "DEFAULT_THEME":DEFAULT_THEME, "DESCRIPTION":DESCRIPTION,
|
"DEFAULT_THEME":DEFAULT_THEME, "DESCRIPTION":DESCRIPTION,
|
||||||
"has_sidebar":has_sidebar, "has_logo":has_logo,
|
"has_sidebar":has_sidebar, "has_logo":has_logo,
|
||||||
"FP":FP, "patron":patron, "get_setting": get_setting,
|
"FP":FP, "patron":patron, "get_setting": get_setting,
|
||||||
"SIDEBAR_THREAD":SIDEBAR_THREAD, "BANNER_THREAD":BANNER_THREAD,
|
"SIDEBAR_THREAD":SIDEBAR_THREAD, "BANNER_THREAD":BANNER_THREAD,
|
||||||
"BADGE_THREAD":BADGE_THREAD, "SNAPPY_THREAD":SNAPPY_THREAD,
|
"BADGE_THREAD":BADGE_THREAD, "SNAPPY_THREAD":SNAPPY_THREAD,
|
||||||
"KOFI_TOKEN":KOFI_TOKEN, "KOFI_LINK":KOFI_LINK,
|
|
||||||
"approved_embed_hosts":approved_embed_hosts,
|
"approved_embed_hosts":approved_embed_hosts,
|
||||||
"site_settings":get_settings(), "EMAIL":EMAIL, "max": max, "min": min, "user_can_see":User.can_see,
|
"site_settings":get_settings(), "EMAIL":EMAIL, "max": max, "min": min, "user_can_see":User.can_see,
|
||||||
"TELEGRAM_ID":TELEGRAM_ID, "EMAIL_REGEX_PATTERN":EMAIL_REGEX_PATTERN,
|
"TELEGRAM_ID":TELEGRAM_ID, "EMAIL_REGEX_PATTERN":EMAIL_REGEX_PATTERN,
|
||||||
|
|
|
@ -1302,39 +1302,39 @@ def claim_rewards(v):
|
||||||
g.db.delete(badge)
|
g.db.delete(badge)
|
||||||
badge_grant(badge_id=20+highest_tier, user=v)
|
badge_grant(badge_id=20+highest_tier, user=v)
|
||||||
|
|
||||||
|
KOFI_TOKEN = environ.get("KOFI_TOKEN", "").strip()
|
||||||
|
if KOFI_TOKEN:
|
||||||
|
@app.post("/kofi")
|
||||||
|
def kofi():
|
||||||
|
data = json.loads(request.values['data'])
|
||||||
|
verification_token = data['verification_token']
|
||||||
|
if verification_token != KOFI_TOKEN: abort(400)
|
||||||
|
|
||||||
@app.post("/kofi")
|
id = data['kofi_transaction_id']
|
||||||
def kofi():
|
created_utc = int(time.mktime(time.strptime(data['timestamp'].split('.')[0], "%Y-%m-%dT%H:%M:%SZ")))
|
||||||
if not KOFI_TOKEN: abort(404)
|
type = data['type']
|
||||||
data = json.loads(request.values['data'])
|
amount = 0
|
||||||
verification_token = data['verification_token']
|
try:
|
||||||
if verification_token != KOFI_TOKEN: abort(400)
|
amount = int(float(data['amount']))
|
||||||
|
except:
|
||||||
|
abort(400, 'invalid amount')
|
||||||
|
email = data['email']
|
||||||
|
|
||||||
id = data['kofi_transaction_id']
|
transaction = Transaction(
|
||||||
created_utc = int(time.mktime(time.strptime(data['timestamp'].split('.')[0], "%Y-%m-%dT%H:%M:%SZ")))
|
id=id,
|
||||||
type = data['type']
|
created_utc=created_utc,
|
||||||
amount = 0
|
type=type,
|
||||||
try:
|
amount=amount,
|
||||||
amount = int(float(data['amount']))
|
email=email
|
||||||
except:
|
)
|
||||||
abort(400, 'invalid amount')
|
|
||||||
email = data['email']
|
|
||||||
|
|
||||||
transaction = Transaction(
|
g.db.add(transaction)
|
||||||
id=id,
|
|
||||||
created_utc=created_utc,
|
|
||||||
type=type,
|
|
||||||
amount=amount,
|
|
||||||
email=email
|
|
||||||
)
|
|
||||||
|
|
||||||
g.db.add(transaction)
|
user = g.db.query(User).filter_by(email=email, is_activated=True).order_by(User.truescore.desc()).first()
|
||||||
|
if user:
|
||||||
|
claim_rewards(user)
|
||||||
|
|
||||||
user = g.db.query(User).filter_by(email=email, is_activated=True).order_by(User.truescore.desc()).first()
|
return ''
|
||||||
if user:
|
|
||||||
claim_rewards(user)
|
|
||||||
|
|
||||||
return ''
|
|
||||||
|
|
||||||
@app.post("/gumroad")
|
@app.post("/gumroad")
|
||||||
def gumroad():
|
def gumroad():
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
{% if v and v.truescore >= TRUESCORE_DONATE_MINIMUM %}
|
{% if v and v.truescore >= TRUESCORE_DONATE_MINIMUM %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>Kofi</td>
|
<td>{{DONATE_SERVICE}}</td>
|
||||||
<td><a rel="nofollow noopener" href="{{KOFI_LINK}}">{{KOFI_LINK}}</a></td>
|
<td><a rel="nofollow noopener" href="{{DONATE_LINK}}">{{DONATE_LINK}}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
{% if v and v.truescore >= TRUESCORE_DONATE_MINIMUM %}
|
{% if v and v.truescore >= TRUESCORE_DONATE_MINIMUM %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>Gumroad</td>
|
<td>{{DONATE_SERVICE}}</td>
|
||||||
<td><a rel="nofollow noopener" href="{{GUMROAD_LINK}}">{{GUMROAD_LINK}}</a></td>
|
<td><a rel="nofollow noopener" href="{{DONATE_LINK}}">{{DONATE_LINK}}</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -47,11 +47,7 @@
|
||||||
<span class="text-small text-muted pl-1">Must be same email as the one you used to donate
|
<span class="text-small text-muted pl-1">Must be same email as the one you used to donate
|
||||||
{% if v.truescore >= TRUESCORE_DONATE_MINIMUM %}
|
{% if v.truescore >= TRUESCORE_DONATE_MINIMUM %}
|
||||||
on
|
on
|
||||||
{% if KOFI_TOKEN %}
|
<a rel="nofollow noopener" class="text-primary" href="{{DONATE_LINK}}">{{DONATE_SERVICE}}</a>
|
||||||
<a rel="nofollow noopener" class="text-primary" href="{{KOFI_LINK}}">Kofi</a>
|
|
||||||
{% else %}
|
|
||||||
<a rel="nofollow noopener" class="text-primary" href="{{GUMROAD_LINK}}">Gumroad</a>
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</span>
|
</span>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
Loading…
Reference in New Issue