forked from rDrama/rDrama
fds4
parent
74f9877222
commit
79164e40bc
|
@ -66,6 +66,8 @@ app.config['MAIL_PORT'] = 587
|
||||||
app.config['MAIL_USE_TLS'] = True
|
app.config['MAIL_USE_TLS'] = True
|
||||||
app.config['MAIL_USERNAME'] = environ.get("MAIL_USERNAME", "").strip()
|
app.config['MAIL_USERNAME'] = environ.get("MAIL_USERNAME", "").strip()
|
||||||
app.config['MAIL_PASSWORD'] = environ.get("MAIL_PASSWORD", "").strip()
|
app.config['MAIL_PASSWORD'] = environ.get("MAIL_PASSWORD", "").strip()
|
||||||
|
# app.config['TEMPLATES_AUTO_RELOAD'] = True
|
||||||
|
# app.config['DEBUG'] = True
|
||||||
|
|
||||||
r=redis.Redis(host=environ.get("REDIS_URL", "redis://0.0.0.0"), decode_responses=True, ssl_cert_reqs=None)
|
r=redis.Redis(host=environ.get("REDIS_URL", "redis://0.0.0.0"), decode_responses=True, ssl_cert_reqs=None)
|
||||||
|
|
||||||
|
|
|
@ -219,13 +219,18 @@ def shop(v):
|
||||||
|
|
||||||
for useraward in g.db.query(AwardRelationship).filter(AwardRelationship.user_id == v.id, AwardRelationship.submission_id == None, AwardRelationship.comment_id == None).all(): AWARDS[useraward.kind]["owned"] += 1
|
for useraward in g.db.query(AwardRelationship).filter(AwardRelationship.user_id == v.id, AwardRelationship.submission_id == None, AwardRelationship.comment_id == None).all(): AWARDS[useraward.kind]["owned"] += 1
|
||||||
|
|
||||||
if v.patron:
|
if v.patron == 1: discount = 0.90
|
||||||
for val in AWARDS.values():
|
elif v.patron == 2: discount = 0.85
|
||||||
if v.patron == 1: val["price"] = int(val["price"]*0.90)
|
elif v.patron == 3: discount = 0.80
|
||||||
elif v.patron == 2: val["price"] = int(val["price"]*0.85)
|
elif v.patron == 4: discount = 0.75
|
||||||
elif v.patron == 3: val["price"] = int(val["price"]*0.80)
|
elif v.patron == 5: discount = 0.70
|
||||||
elif v.patron == 4: val["price"] = int(val["price"]*0.75)
|
else: discount = 1
|
||||||
else: val["price"] = int(val["price"]*0.70)
|
|
||||||
|
for badge in [69,70,71,72,73]:
|
||||||
|
if v.has_badge(badge): discount -= 0.02
|
||||||
|
|
||||||
|
for val in AWARDS.values():
|
||||||
|
val["price"] = int(val["price"]*discount)
|
||||||
|
|
||||||
sales = g.db.query(Vote.id).count() + g.db.query(CommentVote.id).count() - g.db.query(func.sum(User.coins)).scalar()
|
sales = g.db.query(Vote.id).count() + g.db.query(CommentVote.id).count() - g.db.query(func.sum(User.coins)).scalar()
|
||||||
return render_template("shop.html", awards=list(AWARDS.values()), v=v, sales=sales)
|
return render_template("shop.html", awards=list(AWARDS.values()), v=v, sales=sales)
|
||||||
|
@ -395,12 +400,18 @@ def buy(v, award):
|
||||||
|
|
||||||
if award not in AWARDS: abort(400)
|
if award not in AWARDS: abort(400)
|
||||||
price = AWARDS[award]["price"]
|
price = AWARDS[award]["price"]
|
||||||
if v.patron:
|
|
||||||
if v.patron == 1: price = int(price*0.90)
|
if v.patron == 1: discount = 0.90
|
||||||
elif v.patron == 2: price = int(price*0.85)
|
elif v.patron == 2: discount = 0.85
|
||||||
elif v.patron == 3: price = int(price*0.80)
|
elif v.patron == 3: discount = 0.80
|
||||||
elif v.patron == 4: price = int(price*0.75)
|
elif v.patron == 4: discount = 0.75
|
||||||
else: price = int(price*0.70)
|
elif v.patron == 5: discount = 0.70
|
||||||
|
else: discount = 1
|
||||||
|
|
||||||
|
for badge in [69,70,71,72,73]:
|
||||||
|
if v.has_badge(badge): discount -= 0.02
|
||||||
|
|
||||||
|
price = int(price*discount)
|
||||||
|
|
||||||
if request.values.get("mb"):
|
if request.values.get("mb"):
|
||||||
if v.procoins < price: return {"error": "Not enough marseybux."}, 400
|
if v.procoins < price: return {"error": "Not enough marseybux."}, 400
|
||||||
|
@ -857,14 +868,17 @@ def items(v):
|
||||||
|
|
||||||
for useraward in g.db.query(AwardRelationship).filter(AwardRelationship.user_id == v.id, AwardRelationship.submission_id == None, AwardRelationship.comment_id == None).all(): AWARDS[useraward.kind]["owned"] += 1
|
for useraward in g.db.query(AwardRelationship).filter(AwardRelationship.user_id == v.id, AwardRelationship.submission_id == None, AwardRelationship.comment_id == None).all(): AWARDS[useraward.kind]["owned"] += 1
|
||||||
|
|
||||||
if v.patron:
|
if v.patron == 1: discount = 0.90
|
||||||
for val in AWARDS.values():
|
elif v.patron == 2: discount = 0.85
|
||||||
if v.patron == 1: val["price"] = int(val["price"]*0.90)
|
elif v.patron == 3: discount = 0.80
|
||||||
elif v.patron == 2: val["price"] = int(val["price"]*0.85)
|
elif v.patron == 4: discount = 0.75
|
||||||
elif v.patron == 3: val["price"] = int(val["price"]*0.80)
|
elif v.patron == 5: discount = 0.70
|
||||||
elif v.patron == 4: val["price"] = int(val["price"]*0.75)
|
else: discount = 1
|
||||||
else: val["price"] = int(val["price"]*0.70)
|
|
||||||
|
|
||||||
sales = g.db.query(Vote.id).count() + g.db.query(CommentVote.id).count() - g.db.query(func.sum(User.coins)).scalar()
|
for badge in [69,70,71,72,73]:
|
||||||
return render_template("shop.html", awards=list(AWARDS.values()), v=v, sales=sales)
|
if v.has_badge(badge): discount -= 0.02
|
||||||
|
|
||||||
|
for val in AWARDS.values():
|
||||||
|
val["price"] = int(val["price"]*discount)
|
||||||
|
|
||||||
|
return AWARDS
|
Loading…
Reference in New Issue