diff --git a/files/helpers/const.py b/files/helpers/const.py index e0ef02c41..74a52fd4c 100644 --- a/files/helpers/const.py +++ b/files/helpers/const.py @@ -1016,18 +1016,19 @@ linefeeds_regex = re.compile("([^\n])\n([^\n])", flags=re.A) def make_name(*args, **kwargs): return request.base_url # Lottery -LOTTERY_TICKET_COST = 12 - -# The amount of dramacoins permanently removed from the economy to reduce expected value -LOTTERY_SINK_RATE = 3 - -# The amount of dramacoins the lottery founders receive -LOTTERY_ROYALTY_RATE = 1 - -# The account in which royalties are to be deposited -LOTTERY_ROYALTY_ACCOUNT_ID = 9 -# LOTTERY_ROYALTY_ACCOUNT_ID = 8239 # (McCoxmaul) - -# The account in which the prize is held to be accessed by anyone -LOTTERY_MANAGER_ACCOUNT_ID = 3 -# LOTTERY_MANAGER_ACCOUNT_ID = 11651 (Lottershe) \ No newline at end of file +if SITE_NAME == 'rDrama': + LOTTERY_ENABLED = True + LOTTERY_TICKET_COST = 12 + LOTTERY_SINK_RATE = 3 + LOTTERY_ROYALTY_RATE = 1 + LOTTERY_ROYALTY_ACCOUNT_ID = 9 + # LOTTERY_ROYALTY_ACCOUNT_ID = 8239 # (McCoxmaul) + LOTTERY_MANAGER_ACCOUNT_ID = 3 + # LOTTERY_MANAGER_ACCOUNT_ID = 11651 (Lottershe) +else: + LOTTERY_ENABLED = False + LOTTERY_TICKET_COST = 0 + LOTTERY_SINK_RATE = 0 + LOTTERY_ROYALTY_RATE = 0 + LOTTERY_ROYALTY_ACCOUNT_ID = 0 + LOTTERY_MANAGER_ACCOUNT_ID = 0 \ No newline at end of file diff --git a/files/helpers/jinja2.py b/files/helpers/jinja2.py index d9e33cb6f..49701af9f 100644 --- a/files/helpers/jinja2.py +++ b/files/helpers/jinja2.py @@ -50,4 +50,9 @@ def timestamp(timestamp): @app.context_processor 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} \ No newline at end of file + 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} \ No newline at end of file diff --git a/files/helpers/lottery.py b/files/helpers/lottery.py index a96ae50c0..71a1fe218 100644 --- a/files/helpers/lottery.py +++ b/files/helpers/lottery.py @@ -64,7 +64,6 @@ def start_new_lottery_session(): one_week_from_now = epoch_time + 60 * 60 * 24 * 7 lottery.ends_at = one_week_from_now lottery.is_active = True - lottery.winner_id = 1 g.db.add(lottery) g.db.commit() @@ -82,8 +81,7 @@ def purchase_lottery_ticket(v): v.currently_held_lottery_tickets += 1 v.total_held_lottery_tickets += 1 - net_ticket_value = LOTTERY_TICKET_COST - \ - LOTTERY_SINK_RATE - LOTTERY_ROYALTY_RATE + net_ticket_value = LOTTERY_TICKET_COST - LOTTERY_SINK_RATE - LOTTERY_ROYALTY_RATE most_recent_lottery.prize += net_ticket_value most_recent_lottery.tickets_sold += 1 diff --git a/files/helpers/wrappers.py b/files/helpers/wrappers.py index 7861ca3eb..b57299d9e 100644 --- a/files/helpers/wrappers.py +++ b/files/helpers/wrappers.py @@ -137,4 +137,15 @@ def admin_level_required(x): wrapper.__name__ = f.__name__ return wrapper - return wrapper_maker \ No newline at end of file + 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 \ No newline at end of file diff --git a/files/routes/comments.py b/files/routes/comments.py index 636b94051..9b51cf640 100644 --- a/files/routes/comments.py +++ b/files/routes/comments.py @@ -669,7 +669,6 @@ def api_comment(v): parent_post.comment_count += 1 g.db.add(parent_post) - v.coins += 20000 g.db.commit() if request.headers.get("Authorization"): return c.json diff --git a/files/routes/lottery.py b/files/routes/lottery.py index 3105bf797..84baf4e8d 100644 --- a/files/routes/lottery.py +++ b/files/routes/lottery.py @@ -3,11 +3,13 @@ from files.helpers.wrappers import * from files.helpers.alerts import * from files.helpers.get import * from files.helpers.const import * +from files.helpers.wrappers import * from files.helpers.lottery import * @app.post("/lottery/end") -@auth_required +@admin_level_required(3) +@lottery_required def lottery_end(v): if v.admin_level > 2: success, message = end_lottery_session() @@ -17,7 +19,8 @@ def lottery_end(v): @app.post("/lottery/start") -@auth_required +@admin_level_required(3) +@lottery_required def lottery_start(v): if v.admin_level > 2: start_new_lottery_session() @@ -29,6 +32,7 @@ def lottery_start(v): @app.post("/lottery/buy") @limiter.limit("1/second;30/minute;200/hour;1000/day") @auth_required +@lottery_required def lottery_buy(v): success, message = purchase_lottery_ticket(v) lottery, participants = get_active_lottery_stats() @@ -42,6 +46,7 @@ def lottery_buy(v): @app.get("/lottery/active") @limiter.limit("1/second;30/minute;200/hour;1000/day") @auth_required +@lottery_required def lottery_active(v): lottery, participants = get_active_lottery_stats() diff --git a/files/templates/header.html b/files/templates/header.html index 247e3e670..ba4ec4292 100644 --- a/files/templates/header.html +++ b/files/templates/header.html @@ -75,7 +75,7 @@ {% if not err %} - {% if v %} + {% if v and LOTTERY_ENABLED %} - {% if v %} + {% if v and LOTTERY_ENABLED %}