Don't show lotteries on the sister sites
parent
a0cc7e1cf6
commit
b9dc28e6d1
|
@ -1016,18 +1016,19 @@ linefeeds_regex = re.compile("([^\n])\n([^\n])", flags=re.A)
|
||||||
def make_name(*args, **kwargs): return request.base_url
|
def make_name(*args, **kwargs): return request.base_url
|
||||||
|
|
||||||
# Lottery
|
# Lottery
|
||||||
LOTTERY_TICKET_COST = 12
|
if SITE_NAME == 'rDrama':
|
||||||
|
LOTTERY_ENABLED = True
|
||||||
# The amount of dramacoins permanently removed from the economy to reduce expected value
|
LOTTERY_TICKET_COST = 12
|
||||||
LOTTERY_SINK_RATE = 3
|
LOTTERY_SINK_RATE = 3
|
||||||
|
LOTTERY_ROYALTY_RATE = 1
|
||||||
# The amount of dramacoins the lottery founders receive
|
LOTTERY_ROYALTY_ACCOUNT_ID = 9
|
||||||
LOTTERY_ROYALTY_RATE = 1
|
# LOTTERY_ROYALTY_ACCOUNT_ID = 8239 # (McCoxmaul)
|
||||||
|
LOTTERY_MANAGER_ACCOUNT_ID = 3
|
||||||
# The account in which royalties are to be deposited
|
# LOTTERY_MANAGER_ACCOUNT_ID = 11651 (Lottershe)
|
||||||
LOTTERY_ROYALTY_ACCOUNT_ID = 9
|
else:
|
||||||
# LOTTERY_ROYALTY_ACCOUNT_ID = 8239 # (McCoxmaul)
|
LOTTERY_ENABLED = False
|
||||||
|
LOTTERY_TICKET_COST = 0
|
||||||
# The account in which the prize is held to be accessed by anyone
|
LOTTERY_SINK_RATE = 0
|
||||||
LOTTERY_MANAGER_ACCOUNT_ID = 3
|
LOTTERY_ROYALTY_RATE = 0
|
||||||
# LOTTERY_MANAGER_ACCOUNT_ID = 11651 (Lottershe)
|
LOTTERY_ROYALTY_ACCOUNT_ID = 0
|
||||||
|
LOTTERY_MANAGER_ACCOUNT_ID = 0
|
|
@ -50,4 +50,9 @@ def timestamp(timestamp):
|
||||||
|
|
||||||
@app.context_processor
|
@app.context_processor
|
||||||
def inject_constants():
|
def inject_constants():
|
||||||
return {"environ":environ, "SITE":SITE, "SITE_NAME":SITE_NAME, "SITE_FULL":SITE_FULL, "AUTOJANNY_ID":AUTOJANNY_ID, "NOTIFICATIONS_ID":NOTIFICATIONS_ID, "PUSHER_ID":PUSHER_ID, "CC":CC, "CC_TITLE":CC_TITLE, "listdir":listdir, "MOOSE_ID":MOOSE_ID, "AEVANN_ID":AEVANN_ID, "PIZZASHILL_ID":PIZZASHILL_ID, "config":app.config.get, "DEFAULT_COLOR":DEFAULT_COLOR, "COLORS":COLORS, "ADMIGGERS":ADMIGGERS, "datetime":datetime, "time":time}
|
return {"environ":environ, "SITE":SITE, "SITE_NAME":SITE_NAME, "SITE_FULL":SITE_FULL,
|
||||||
|
"AUTOJANNY_ID":AUTOJANNY_ID, "NOTIFICATIONS_ID":NOTIFICATIONS_ID, "PUSHER_ID":PUSHER_ID,
|
||||||
|
"CC":CC, "CC_TITLE":CC_TITLE, "listdir":listdir, "MOOSE_ID":MOOSE_ID, "AEVANN_ID":AEVANN_ID,
|
||||||
|
"PIZZASHILL_ID":PIZZASHILL_ID, "config":app.config.get, "DEFAULT_COLOR":DEFAULT_COLOR,
|
||||||
|
"COLORS":COLORS, "ADMIGGERS":ADMIGGERS, "datetime":datetime, "time":time,
|
||||||
|
"LOTTERY_ENABLED": LOTTERY_ENABLED}
|
|
@ -64,7 +64,6 @@ def start_new_lottery_session():
|
||||||
one_week_from_now = epoch_time + 60 * 60 * 24 * 7
|
one_week_from_now = epoch_time + 60 * 60 * 24 * 7
|
||||||
lottery.ends_at = one_week_from_now
|
lottery.ends_at = one_week_from_now
|
||||||
lottery.is_active = True
|
lottery.is_active = True
|
||||||
lottery.winner_id = 1
|
|
||||||
|
|
||||||
g.db.add(lottery)
|
g.db.add(lottery)
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
@ -82,8 +81,7 @@ def purchase_lottery_ticket(v):
|
||||||
v.currently_held_lottery_tickets += 1
|
v.currently_held_lottery_tickets += 1
|
||||||
v.total_held_lottery_tickets += 1
|
v.total_held_lottery_tickets += 1
|
||||||
|
|
||||||
net_ticket_value = LOTTERY_TICKET_COST - \
|
net_ticket_value = LOTTERY_TICKET_COST - LOTTERY_SINK_RATE - LOTTERY_ROYALTY_RATE
|
||||||
LOTTERY_SINK_RATE - LOTTERY_ROYALTY_RATE
|
|
||||||
most_recent_lottery.prize += net_ticket_value
|
most_recent_lottery.prize += net_ticket_value
|
||||||
most_recent_lottery.tickets_sold += 1
|
most_recent_lottery.tickets_sold += 1
|
||||||
|
|
||||||
|
|
|
@ -137,4 +137,15 @@ def admin_level_required(x):
|
||||||
wrapper.__name__ = f.__name__
|
wrapper.__name__ = f.__name__
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|
||||||
return wrapper_maker
|
return wrapper_maker
|
||||||
|
|
||||||
|
def lottery_required(f):
|
||||||
|
def wrapper(*args, **kwargs):
|
||||||
|
v = get_logged_in_user()
|
||||||
|
|
||||||
|
if not LOTTERY_ENABLED: abort(404)
|
||||||
|
|
||||||
|
return make_response(f(v=v))
|
||||||
|
|
||||||
|
wrapper.__name__ = f.__name__
|
||||||
|
return wrapper
|
|
@ -669,7 +669,6 @@ def api_comment(v):
|
||||||
parent_post.comment_count += 1
|
parent_post.comment_count += 1
|
||||||
g.db.add(parent_post)
|
g.db.add(parent_post)
|
||||||
|
|
||||||
v.coins += 20000
|
|
||||||
g.db.commit()
|
g.db.commit()
|
||||||
|
|
||||||
if request.headers.get("Authorization"): return c.json
|
if request.headers.get("Authorization"): return c.json
|
||||||
|
|
|
@ -3,11 +3,13 @@ from files.helpers.wrappers import *
|
||||||
from files.helpers.alerts import *
|
from files.helpers.alerts import *
|
||||||
from files.helpers.get import *
|
from files.helpers.get import *
|
||||||
from files.helpers.const import *
|
from files.helpers.const import *
|
||||||
|
from files.helpers.wrappers import *
|
||||||
from files.helpers.lottery import *
|
from files.helpers.lottery import *
|
||||||
|
|
||||||
|
|
||||||
@app.post("/lottery/end")
|
@app.post("/lottery/end")
|
||||||
@auth_required
|
@admin_level_required(3)
|
||||||
|
@lottery_required
|
||||||
def lottery_end(v):
|
def lottery_end(v):
|
||||||
if v.admin_level > 2:
|
if v.admin_level > 2:
|
||||||
success, message = end_lottery_session()
|
success, message = end_lottery_session()
|
||||||
|
@ -17,7 +19,8 @@ def lottery_end(v):
|
||||||
|
|
||||||
|
|
||||||
@app.post("/lottery/start")
|
@app.post("/lottery/start")
|
||||||
@auth_required
|
@admin_level_required(3)
|
||||||
|
@lottery_required
|
||||||
def lottery_start(v):
|
def lottery_start(v):
|
||||||
if v.admin_level > 2:
|
if v.admin_level > 2:
|
||||||
start_new_lottery_session()
|
start_new_lottery_session()
|
||||||
|
@ -29,6 +32,7 @@ def lottery_start(v):
|
||||||
@app.post("/lottery/buy")
|
@app.post("/lottery/buy")
|
||||||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||||
@auth_required
|
@auth_required
|
||||||
|
@lottery_required
|
||||||
def lottery_buy(v):
|
def lottery_buy(v):
|
||||||
success, message = purchase_lottery_ticket(v)
|
success, message = purchase_lottery_ticket(v)
|
||||||
lottery, participants = get_active_lottery_stats()
|
lottery, participants = get_active_lottery_stats()
|
||||||
|
@ -42,6 +46,7 @@ def lottery_buy(v):
|
||||||
@app.get("/lottery/active")
|
@app.get("/lottery/active")
|
||||||
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
@limiter.limit("1/second;30/minute;200/hour;1000/day")
|
||||||
@auth_required
|
@auth_required
|
||||||
|
@lottery_required
|
||||||
def lottery_active(v):
|
def lottery_active(v):
|
||||||
lottery, participants = get_active_lottery_stats()
|
lottery, participants = get_active_lottery_stats()
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@
|
||||||
{% if not err %}
|
{% if not err %}
|
||||||
<a class="mobile-nav-icon d-md-none" href="/random_user"><i class="fas fa-music align-middle text-gray-500 black"></i></a>
|
<a class="mobile-nav-icon d-md-none" href="/random_user"><i class="fas fa-music align-middle text-gray-500 black"></i></a>
|
||||||
<a class="mobile-nav-icon d-md-none" href="/random_post"><i class="fas fa-random align-middle text-gray-500 black"></i></a>
|
<a class="mobile-nav-icon d-md-none" href="/random_post"><i class="fas fa-random align-middle text-gray-500 black"></i></a>
|
||||||
{% if v %}
|
{% if v and LOTTERY_ENABLED %}
|
||||||
<a
|
<a
|
||||||
href="#"
|
href="#"
|
||||||
class="mobile-nav-icon d-md-none"
|
class="mobile-nav-icon d-md-none"
|
||||||
|
@ -112,7 +112,7 @@
|
||||||
<a class="nav-link" href="/random_post/" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Random post"><i class="fas fa-random"></i></a>
|
<a class="nav-link" href="/random_post/" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Random post"><i class="fas fa-random"></i></a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
{% if v %}
|
{% if v and LOTTERY_ENABLED %}
|
||||||
<li class="nav-item d-flex align-items-center justify-content-center text-center mx-1">
|
<li class="nav-item d-flex align-items-center justify-content-center text-center mx-1">
|
||||||
<a
|
<a
|
||||||
href="#"
|
href="#"
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
{% if LOTTERY_ENABLED %}
|
||||||
<div
|
<div
|
||||||
class="modal fade"
|
class="modal fade"
|
||||||
id="lotteryModal"
|
id="lotteryModal"
|
||||||
|
@ -80,8 +81,9 @@
|
||||||
title=""
|
title=""
|
||||||
aria-label="coins"
|
aria-label="coins"
|
||||||
data-bs-original-title="coins"
|
data-bs-original-title="coins"
|
||||||
style="display: none; position: relative; top: -2px;"
|
style="display: none; position: relative; top: -2px"
|
||||||
/> <span id="prize">-</span>
|
/>
|
||||||
|
<span id="prize">-</span>
|
||||||
</div>
|
</div>
|
||||||
<div id="timeLeft">-</div>
|
<div id="timeLeft">-</div>
|
||||||
<div id="ticketsSoldThisSession">-</div>
|
<div id="ticketsSoldThisSession">-</div>
|
||||||
|
@ -181,3 +183,4 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/assets/js/lottery_modal.js?v=249" data-cfasync="false"></script>
|
<script src="/assets/js/lottery_modal.js?v=249" data-cfasync="false"></script>
|
||||||
|
{% endif %}
|
||||||
|
|
|
@ -1857,13 +1857,13 @@ CREATE TABLE public.lotteries (
|
||||||
ends_at integer DEFAULT 0 NOT NULL,
|
ends_at integer DEFAULT 0 NOT NULL,
|
||||||
prize integer DEFAULT 0 NOT NULL,
|
prize integer DEFAULT 0 NOT NULL,
|
||||||
tickets_sold integer DEFAULT 0 NOT NULL,
|
tickets_sold integer DEFAULT 0 NOT NULL,
|
||||||
winner_id integer DEFAULT 0 NOT NULL
|
winner_id integer DEFAULT null NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
ALTER TABLE ONLY public.lotteries
|
ALTER TABLE ONLY public.lotteries
|
||||||
ADD CONSTRAINT fk_winner FOREIGN KEY (winner_id) REFERENCES public.users(id);
|
ADD CONSTRAINT fk_winner FOREIGN KEY (winner_id) REFERENCES public.users(id);
|
||||||
|
|
||||||
ALTER TABLE public.users
|
ALTER TABLE ONLY public.users
|
||||||
ADD currently_held_lottery_tickets integer DEFAULT 0 NOT NULL,
|
ADD currently_held_lottery_tickets integer DEFAULT 0 NOT NULL,
|
||||||
ADD total_held_lottery_tickets integer DEFAULT 0 NOT NULL,
|
ADD total_held_lottery_tickets integer DEFAULT 0 NOT NULL,
|
||||||
ADD total_lottery_winnings integer DEFAULT 0 NOT NULL;
|
ADD total_lottery_winnings integer DEFAULT 0 NOT NULL;
|
Loading…
Reference in New Issue