forked from MarseyWorld/MarseyWorld
replace spaces with tabs
parent
d8fff0bc72
commit
0f49c8e32f
|
@ -6,27 +6,27 @@ from files.helpers.const import *
|
|||
|
||||
|
||||
class Lottery(Base):
|
||||
__tablename__ = "lotteries"
|
||||
__tablename__ = "lotteries"
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
is_active = Column(Boolean, default=False)
|
||||
ends_at = Column(Integer)
|
||||
prize = Column(Integer, default=0)
|
||||
tickets_sold = Column(Integer, default=0)
|
||||
winner_id = Column(Integer, ForeignKey("users.id"))
|
||||
id = Column(Integer, primary_key=True)
|
||||
is_active = Column(Boolean, default=False)
|
||||
ends_at = Column(Integer)
|
||||
prize = Column(Integer, default=0)
|
||||
tickets_sold = Column(Integer, default=0)
|
||||
winner_id = Column(Integer, ForeignKey("users.id"))
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def timeleft(self):
|
||||
if not self.is_active:
|
||||
return 0
|
||||
@property
|
||||
@lazy
|
||||
def timeleft(self):
|
||||
if not self.is_active:
|
||||
return 0
|
||||
|
||||
epoch_time = int(time.time())
|
||||
remaining_time = self.ends_at - epoch_time
|
||||
epoch_time = int(time.time())
|
||||
remaining_time = self.ends_at - epoch_time
|
||||
|
||||
return 0 if remaining_time < 0 else remaining_time
|
||||
return 0 if remaining_time < 0 else remaining_time
|
||||
|
||||
@property
|
||||
@lazy
|
||||
def stats(self):
|
||||
return {"active": self.is_active, "timeLeft": self.timeleft, "prize": self.prize, "ticketsSoldThisSession": self.tickets_sold,}
|
||||
@property
|
||||
@lazy
|
||||
def stats(self):
|
||||
return {"active": self.is_active, "timeLeft": self.timeleft, "prize": self.prize, "ticketsSoldThisSession": self.tickets_sold,}
|
||||
|
|
|
@ -4,7 +4,7 @@ from files.classes.badges import Badge, BadgeDef
|
|||
|
||||
# TODO: More sanity checks on passed parameters.
|
||||
# TODO: Add `replace=False` parameter which, when set true, removes any
|
||||
# existing badge with identical id & user and replaces with new one.
|
||||
# existing badge with identical id & user and replaces with new one.
|
||||
def badge_grant(user_id, badge_id, desc='', url='', commit=True):
|
||||
user = g.db.query(User).filter(User.id == int(user_id)).one_or_none()
|
||||
if not user:
|
||||
|
|
|
@ -525,13 +525,13 @@ AWARDS = {
|
|||
"price": 500
|
||||
},
|
||||
"glowie": {
|
||||
"kind": "glowie",
|
||||
"title": "Glowie",
|
||||
"description": "Indicates that the recipient can be seen when driving. Just run them over.",
|
||||
"icon": "fas fa-user-secret",
|
||||
"color": "text-green",
|
||||
"price": 500
|
||||
},
|
||||
"kind": "glowie",
|
||||
"title": "Glowie",
|
||||
"description": "Indicates that the recipient can be seen when driving. Just run them over.",
|
||||
"icon": "fas fa-user-secret",
|
||||
"color": "text-green",
|
||||
"price": 500
|
||||
},
|
||||
"rehab": {
|
||||
"kind": "rehab",
|
||||
"title": "Rehab",
|
||||
|
@ -541,13 +541,13 @@ AWARDS = {
|
|||
"price": 777
|
||||
},
|
||||
"beano": {
|
||||
"kind": "beano",
|
||||
"title": "Beano",
|
||||
"description": "Stops you from embarrassing yourself with your flatulence",
|
||||
"icon": "fas fa-gas-pump-slash",
|
||||
"color": "text-green",
|
||||
"price": 1000
|
||||
},
|
||||
"kind": "beano",
|
||||
"title": "Beano",
|
||||
"description": "Stops you from embarrassing yourself with your flatulence",
|
||||
"icon": "fas fa-gas-pump-slash",
|
||||
"color": "text-green",
|
||||
"price": 1000
|
||||
},
|
||||
"progressivestack": {
|
||||
"kind": "progressivestack",
|
||||
"title": "Progressive Stack",
|
||||
|
|
|
@ -10,120 +10,120 @@ from .const import *
|
|||
LOTTERY_WINNER_BADGE_ID = 137
|
||||
|
||||
def get_active_lottery():
|
||||
return g.db.query(Lottery).order_by(Lottery.id.desc()).filter(Lottery.is_active).one_or_none()
|
||||
return g.db.query(Lottery).order_by(Lottery.id.desc()).filter(Lottery.is_active).one_or_none()
|
||||
|
||||
|
||||
def get_users_participating_in_lottery():
|
||||
return g.db.query(User) \
|
||||
.filter(User.currently_held_lottery_tickets > 0) \
|
||||
.order_by(User.currently_held_lottery_tickets.desc()).all()
|
||||
return g.db.query(User) \
|
||||
.filter(User.currently_held_lottery_tickets > 0) \
|
||||
.order_by(User.currently_held_lottery_tickets.desc()).all()
|
||||
|
||||
|
||||
def get_active_lottery_stats():
|
||||
active_lottery = get_active_lottery()
|
||||
participating_users = get_users_participating_in_lottery()
|
||||
active_lottery = get_active_lottery()
|
||||
participating_users = get_users_participating_in_lottery()
|
||||
|
||||
return None if active_lottery is None else active_lottery.stats, len(participating_users)
|
||||
return None if active_lottery is None else active_lottery.stats, len(participating_users)
|
||||
|
||||
|
||||
def end_lottery_session():
|
||||
active_lottery = get_active_lottery()
|
||||
active_lottery = get_active_lottery()
|
||||
|
||||
if (active_lottery is None):
|
||||
return False, "There is no active lottery."
|
||||
if (active_lottery is None):
|
||||
return False, "There is no active lottery."
|
||||
|
||||
participating_users = get_users_participating_in_lottery()
|
||||
raffle = []
|
||||
for user in participating_users:
|
||||
for _ in range(user.currently_held_lottery_tickets):
|
||||
raffle.append(user.id)
|
||||
participating_users = get_users_participating_in_lottery()
|
||||
raffle = []
|
||||
for user in participating_users:
|
||||
for _ in range(user.currently_held_lottery_tickets):
|
||||
raffle.append(user.id)
|
||||
|
||||
winner = choice(raffle)
|
||||
active_lottery.winner_id = winner
|
||||
winning_user = next(filter(lambda x: x.id == winner, participating_users))
|
||||
winning_user.coins += active_lottery.prize
|
||||
winning_user.total_lottery_winnings += active_lottery.prize
|
||||
badge_grant(winner, LOTTERY_WINNER_BADGE_ID)
|
||||
winner = choice(raffle)
|
||||
active_lottery.winner_id = winner
|
||||
winning_user = next(filter(lambda x: x.id == winner, participating_users))
|
||||
winning_user.coins += active_lottery.prize
|
||||
winning_user.total_lottery_winnings += active_lottery.prize
|
||||
badge_grant(winner, LOTTERY_WINNER_BADGE_ID)
|
||||
|
||||
for user in participating_users:
|
||||
chance_to_win = user.currently_held_lottery_tickets / len(raffle) * 100
|
||||
if user.id == winner:
|
||||
notification_text = f'You won {active_lottery.prize} coins in the lottery! ' \
|
||||
+ f'Congratulations!\nYour odds of winning were: {chance_to_win}%'
|
||||
else:
|
||||
notification_text = f'You did not win the lottery. Better luck next time!\n' \
|
||||
+ f'Your odds of winning were: {chance_to_win}%\nWinner: @{winning_user.username} (won {active_lottery.prize} coins)'
|
||||
send_repeatable_notification(user.id, notification_text)
|
||||
user.currently_held_lottery_tickets = 0
|
||||
for user in participating_users:
|
||||
chance_to_win = user.currently_held_lottery_tickets / len(raffle) * 100
|
||||
if user.id == winner:
|
||||
notification_text = f'You won {active_lottery.prize} coins in the lottery! ' \
|
||||
+ f'Congratulations!\nYour odds of winning were: {chance_to_win}%'
|
||||
else:
|
||||
notification_text = f'You did not win the lottery. Better luck next time!\n' \
|
||||
+ f'Your odds of winning were: {chance_to_win}%\nWinner: @{winning_user.username} (won {active_lottery.prize} coins)'
|
||||
send_repeatable_notification(user.id, notification_text)
|
||||
user.currently_held_lottery_tickets = 0
|
||||
|
||||
active_lottery.is_active = False
|
||||
active_lottery.is_active = False
|
||||
|
||||
g.db.commit()
|
||||
g.db.commit()
|
||||
|
||||
return True, f'{winning_user.username} won {active_lottery.prize} coins!'
|
||||
return True, f'{winning_user.username} won {active_lottery.prize} coins!'
|
||||
|
||||
|
||||
def start_new_lottery_session():
|
||||
end_lottery_session()
|
||||
end_lottery_session()
|
||||
|
||||
lottery = Lottery()
|
||||
epoch_time = int(time.time())
|
||||
# Subtract 4 minutes from one week so cronjob interval doesn't cause the
|
||||
# time to drift toward over multiple weeks.
|
||||
one_week_from_now = epoch_time + 60 * 60 * 24 * 7 - (4 * 60)
|
||||
lottery.ends_at = one_week_from_now
|
||||
lottery.is_active = True
|
||||
lottery = Lottery()
|
||||
epoch_time = int(time.time())
|
||||
# Subtract 4 minutes from one week so cronjob interval doesn't cause the
|
||||
# time to drift toward over multiple weeks.
|
||||
one_week_from_now = epoch_time + 60 * 60 * 24 * 7 - (4 * 60)
|
||||
lottery.ends_at = one_week_from_now
|
||||
lottery.is_active = True
|
||||
|
||||
g.db.add(lottery)
|
||||
g.db.commit()
|
||||
g.db.add(lottery)
|
||||
g.db.commit()
|
||||
|
||||
|
||||
def check_if_end_lottery_task():
|
||||
active_lottery = get_active_lottery()
|
||||
active_lottery = get_active_lottery()
|
||||
|
||||
if active_lottery is None:
|
||||
return False
|
||||
elif active_lottery.timeleft > 0:
|
||||
return False
|
||||
if active_lottery is None:
|
||||
return False
|
||||
elif active_lottery.timeleft > 0:
|
||||
return False
|
||||
|
||||
start_new_lottery_session()
|
||||
return True
|
||||
start_new_lottery_session()
|
||||
return True
|
||||
|
||||
def lottery_ticket_net_value():
|
||||
return LOTTERY_TICKET_COST - LOTTERY_SINK_RATE
|
||||
return LOTTERY_TICKET_COST - LOTTERY_SINK_RATE
|
||||
|
||||
def purchase_lottery_tickets(v, quantity=1):
|
||||
if quantity < 1:
|
||||
return False, "Must purchase one or more lottery tickets."
|
||||
elif (v.coins < LOTTERY_TICKET_COST * quantity):
|
||||
return False, f'Lottery tickets cost {LOTTERY_TICKET_COST} coins each.'
|
||||
if quantity < 1:
|
||||
return False, "Must purchase one or more lottery tickets."
|
||||
elif (v.coins < LOTTERY_TICKET_COST * quantity):
|
||||
return False, f'Lottery tickets cost {LOTTERY_TICKET_COST} coins each.'
|
||||
|
||||
most_recent_lottery = get_active_lottery()
|
||||
if (most_recent_lottery is None):
|
||||
return False, "There is no active lottery."
|
||||
most_recent_lottery = get_active_lottery()
|
||||
if (most_recent_lottery is None):
|
||||
return False, "There is no active lottery."
|
||||
|
||||
v.coins -= LOTTERY_TICKET_COST * quantity
|
||||
v.currently_held_lottery_tickets += quantity
|
||||
v.total_held_lottery_tickets += quantity
|
||||
v.coins -= LOTTERY_TICKET_COST * quantity
|
||||
v.currently_held_lottery_tickets += quantity
|
||||
v.total_held_lottery_tickets += quantity
|
||||
|
||||
net_ticket_value = lottery_ticket_net_value() * quantity
|
||||
most_recent_lottery.prize += net_ticket_value
|
||||
most_recent_lottery.tickets_sold += quantity
|
||||
net_ticket_value = lottery_ticket_net_value() * quantity
|
||||
most_recent_lottery.prize += net_ticket_value
|
||||
most_recent_lottery.tickets_sold += quantity
|
||||
|
||||
g.db.commit()
|
||||
g.db.commit()
|
||||
|
||||
if quantity == 1: return True, f'Successfully purchased {quantity} lottery ticket!'
|
||||
return True, f'Successfully purchased {quantity} lottery tickets!'
|
||||
if quantity == 1: return True, f'Successfully purchased {quantity} lottery ticket!'
|
||||
return True, f'Successfully purchased {quantity} lottery tickets!'
|
||||
|
||||
def grant_lottery_tickets_to_user(v, quantity):
|
||||
active_lottery = get_active_lottery()
|
||||
prize_value = lottery_ticket_net_value() * quantity
|
||||
active_lottery = get_active_lottery()
|
||||
prize_value = lottery_ticket_net_value() * quantity
|
||||
|
||||
if active_lottery:
|
||||
v.currently_held_lottery_tickets += quantity
|
||||
v.total_held_lottery_tickets += quantity
|
||||
if active_lottery:
|
||||
v.currently_held_lottery_tickets += quantity
|
||||
v.total_held_lottery_tickets += quantity
|
||||
|
||||
active_lottery.prize += prize_value
|
||||
active_lottery.tickets_sold += quantity
|
||||
active_lottery.prize += prize_value
|
||||
active_lottery.tickets_sold += quantity
|
||||
|
||||
g.db.commit()
|
||||
g.db.commit()
|
||||
|
|
|
@ -63,13 +63,13 @@ def chart(kind, site):
|
|||
plt.rcParams['figure.figsize'] = (chart_width, 20)
|
||||
|
||||
signup_chart = plt.subplot2grid((chart_width, 20), ( 0, 0), rowspan=6, colspan=chart_width)
|
||||
posts_chart = plt.subplot2grid((chart_width, 20), (10, 0), rowspan=6, colspan=chart_width)
|
||||
posts_chart = plt.subplot2grid((chart_width, 20), (10, 0), rowspan=6, colspan=chart_width)
|
||||
comments_chart = plt.subplot2grid((chart_width, 20), (20, 0), rowspan=6, colspan=chart_width)
|
||||
|
||||
signup_chart.grid(), posts_chart.grid(), comments_chart.grid()
|
||||
|
||||
signup_chart.plot (daily_times, daily_signups, color='red')
|
||||
posts_chart.plot (daily_times, post_stats, color='blue')
|
||||
posts_chart.plot (daily_times, post_stats, color='blue')
|
||||
comments_chart.plot(daily_times, comment_stats, color='purple')
|
||||
|
||||
signup_chart.set_ylim(ymin=0)
|
||||
|
|
|
@ -11,16 +11,16 @@ import requests
|
|||
@admin_level_required(3)
|
||||
@lottery_required
|
||||
def lottery_end(v):
|
||||
success, message = end_lottery_session()
|
||||
return {"message": message} if success else {"error": message}
|
||||
success, message = end_lottery_session()
|
||||
return {"message": message} if success else {"error": message}
|
||||
|
||||
|
||||
@app.post("/lottery/start")
|
||||
@admin_level_required(3)
|
||||
@lottery_required
|
||||
def lottery_start(v):
|
||||
start_new_lottery_session()
|
||||
return {"message": "Lottery started."}
|
||||
start_new_lottery_session()
|
||||
return {"message": "Lottery started."}
|
||||
|
||||
|
||||
@app.post("/lottery/buy")
|
||||
|
@ -28,15 +28,15 @@ def lottery_start(v):
|
|||
@auth_required
|
||||
@lottery_required
|
||||
def lottery_buy(v):
|
||||
quantity = int(request.values.get("quantity"))
|
||||
success, message = purchase_lottery_tickets(v, quantity)
|
||||
lottery, participants = get_active_lottery_stats()
|
||||
quantity = int(request.values.get("quantity"))
|
||||
success, message = purchase_lottery_tickets(v, quantity)
|
||||
lottery, participants = get_active_lottery_stats()
|
||||
|
||||
|
||||
if success:
|
||||
return {"message": message, "stats": {"user": v.lottery_stats, "lottery": lottery, "participants": participants}}
|
||||
else:
|
||||
return {"error": message, "stats": {"user": v.lottery_stats, "lottery": lottery, "participants": participants}}
|
||||
if success:
|
||||
return {"message": message, "stats": {"user": v.lottery_stats, "lottery": lottery, "participants": participants}}
|
||||
else:
|
||||
return {"error": message, "stats": {"user": v.lottery_stats, "lottery": lottery, "participants": participants}}
|
||||
|
||||
|
||||
@app.get("/lottery/active")
|
||||
|
@ -44,20 +44,20 @@ def lottery_buy(v):
|
|||
@auth_required
|
||||
@lottery_required
|
||||
def lottery_active(v):
|
||||
lottery, participants = get_active_lottery_stats()
|
||||
lottery, participants = get_active_lottery_stats()
|
||||
|
||||
return {"message": "", "stats": {"user": v.lottery_stats, "lottery": lottery, "participants": participants}}
|
||||
return {"message": "", "stats": {"user": v.lottery_stats, "lottery": lottery, "participants": participants}}
|
||||
|
||||
@app.get("/lottery")
|
||||
@auth_required
|
||||
@lottery_required
|
||||
def lottery(v):
|
||||
lottery_stats, participant_stats = get_active_lottery_stats()
|
||||
return render_template("lottery.html", v=v, lottery_stats=lottery_stats, participant_stats=participant_stats)
|
||||
lottery_stats, participant_stats = get_active_lottery_stats()
|
||||
return render_template("lottery.html", v=v, lottery_stats=lottery_stats, participant_stats=participant_stats)
|
||||
|
||||
@app.get("/admin/lottery/participants")
|
||||
@admin_level_required(2)
|
||||
@lottery_required
|
||||
def lottery_admin(v):
|
||||
participants = get_users_participating_in_lottery()
|
||||
return render_template("admin/lottery.html", v=v, participants=participants)
|
||||
participants = get_users_participating_in_lottery()
|
||||
return render_template("admin/lottery.html", v=v, participants=participants)
|
||||
|
|
|
@ -44,11 +44,11 @@
|
|||
}
|
||||
{% endif %}
|
||||
</style>
|
||||
<div id="logo-container" class="flex-grow-1 logo-container">
|
||||
<div id="logo-container" class="flex-grow-1 logo-container">
|
||||
<a href="/">
|
||||
<img class="ml-1" id="logo" alt="logo" src="/assets/images/{{SITE_NAME}}/logo.webp?v=1013" width=70>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="flex-grow-1 d-fl d-none d-md-block {% if not v %}pad{% endif %}">
|
||||
|
|
|
@ -1,191 +1,191 @@
|
|||
{% extends "default.html" %} {% block content %}
|
||||
<div>
|
||||
<div class="lottery-page--wrapper">
|
||||
<div class="lottery-page--image">
|
||||
<img src="/assets/images/{{SITE_NAME}}/lottery.webp?v=2" />
|
||||
<img
|
||||
id="lotteryTicketPulled"
|
||||
src="/assets/images/{{SITE_NAME}}/lottery_active.webp?v=2"
|
||||
style="display: none"
|
||||
/>
|
||||
</div>
|
||||
<div class="lottery-page--stats">
|
||||
{% if v.admin_level > 2 %}
|
||||
<div
|
||||
class="lottery-page--stat"
|
||||
style="position: relative; padding-top: 1rem; overflow: hidden"
|
||||
>
|
||||
<i
|
||||
class="fas fa-broom"
|
||||
style="
|
||||
position: absolute;
|
||||
bottom: -4px;
|
||||
right: -4px;
|
||||
font-size: 50px;
|
||||
color: var(--gray-600);
|
||||
"
|
||||
>
|
||||
</i>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-danger"
|
||||
id="endLotterySession"
|
||||
style="display: none"
|
||||
onclick="endLotterySession()"
|
||||
>
|
||||
End Current Session
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-success"
|
||||
id="startLotterySession"
|
||||
style="display: none"
|
||||
onclick="startLotterySession()"
|
||||
>
|
||||
Start New Session
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="lottery-page--stat">
|
||||
<div class="lottery-page--stat-keys">
|
||||
<div>Prize</div>
|
||||
<div>Time Left</div>
|
||||
<div>Tickets Sold</div>
|
||||
<div>Participants</div>
|
||||
</div>
|
||||
<div class="lottery-page--stat-values">
|
||||
<div>
|
||||
<img
|
||||
id="prize-image"
|
||||
alt="coins"
|
||||
class="mr-1 ml-1"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="bottom"
|
||||
height="13"
|
||||
src="/assets/images/{{SITE_NAME}}/coins.webp?v=2"
|
||||
title=""
|
||||
aria-label="coins"
|
||||
data-bs-original-title="coins"
|
||||
style="display: none; position: relative; top: -2px"
|
||||
/>
|
||||
<span id="prize">-</span>
|
||||
</div>
|
||||
<div id="timeLeft">-</div>
|
||||
<div id="ticketsSoldThisSession">-</div>
|
||||
<div id="participantsThisSession">-</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lottery-page--stat">
|
||||
<div class="lottery-page--stat-keys">
|
||||
<div>Your Held Tickets</div>
|
||||
<div>Lifetime Held Tickets</div>
|
||||
<div>Lifetime Winnings</div>
|
||||
</div>
|
||||
<div class="lottery-page--stat-values">
|
||||
<div id="ticketsHeldCurrent">-</div>
|
||||
<div id="ticketsHeldTotal">-</div>
|
||||
<div id="winnings">-</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lottery-page--image">
|
||||
<img src="/assets/images/{{SITE_NAME}}/lottery.webp?v=2" />
|
||||
<img
|
||||
id="lotteryTicketPulled"
|
||||
src="/assets/images/{{SITE_NAME}}/lottery_active.webp?v=2"
|
||||
style="display: none"
|
||||
/>
|
||||
</div>
|
||||
<div class="lottery-page--stats">
|
||||
{% if v.admin_level > 2 %}
|
||||
<div
|
||||
class="lottery-page--stat"
|
||||
style="position: relative; padding-top: 1rem; overflow: hidden"
|
||||
>
|
||||
<i
|
||||
class="fas fa-broom"
|
||||
style="
|
||||
position: absolute;
|
||||
bottom: -4px;
|
||||
right: -4px;
|
||||
font-size: 50px;
|
||||
color: var(--gray-600);
|
||||
"
|
||||
>
|
||||
</i>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-danger"
|
||||
id="endLotterySession"
|
||||
style="display: none"
|
||||
onclick="endLotterySession()"
|
||||
>
|
||||
End Current Session
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-success"
|
||||
id="startLotterySession"
|
||||
style="display: none"
|
||||
onclick="startLotterySession()"
|
||||
>
|
||||
Start New Session
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="lottery-page--stat">
|
||||
<div class="lottery-page--stat-keys">
|
||||
<div>Prize</div>
|
||||
<div>Time Left</div>
|
||||
<div>Tickets Sold</div>
|
||||
<div>Participants</div>
|
||||
</div>
|
||||
<div class="lottery-page--stat-values">
|
||||
<div>
|
||||
<img
|
||||
id="prize-image"
|
||||
alt="coins"
|
||||
class="mr-1 ml-1"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="bottom"
|
||||
height="13"
|
||||
src="/assets/images/{{SITE_NAME}}/coins.webp?v=2"
|
||||
title=""
|
||||
aria-label="coins"
|
||||
data-bs-original-title="coins"
|
||||
style="display: none; position: relative; top: -2px"
|
||||
/>
|
||||
<span id="prize">-</span>
|
||||
</div>
|
||||
<div id="timeLeft">-</div>
|
||||
<div id="ticketsSoldThisSession">-</div>
|
||||
<div id="participantsThisSession">-</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lottery-page--stat">
|
||||
<div class="lottery-page--stat-keys">
|
||||
<div>Your Held Tickets</div>
|
||||
<div>Lifetime Held Tickets</div>
|
||||
<div>Lifetime Winnings</div>
|
||||
</div>
|
||||
<div class="lottery-page--stat-values">
|
||||
<div id="ticketsHeldCurrent">-</div>
|
||||
<div id="ticketsHeldTotal">-</div>
|
||||
<div id="winnings">-</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="lottery-page--stat">
|
||||
<div class="lottery-page--stat-keys">
|
||||
<div>Purchase Quantity</div>
|
||||
</div>
|
||||
<div class="lottery-page--stat-values">
|
||||
<div>
|
||||
<input
|
||||
id="ticketPurchaseQuantity"
|
||||
class="form-control"
|
||||
autocomplete="off"
|
||||
value="1"
|
||||
min="1"
|
||||
step="1"
|
||||
aria-label="Quantity"
|
||||
name="ticketPurchaseQuantity"
|
||||
type="number"
|
||||
style="flex: 1; max-width: 100px; text-align: center;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="lottery-page--stat">
|
||||
<div class="lottery-page--stat-keys">
|
||||
<div>Purchase Quantity</div>
|
||||
</div>
|
||||
<div class="lottery-page--stat-values">
|
||||
<div>
|
||||
<input
|
||||
id="ticketPurchaseQuantity"
|
||||
class="form-control"
|
||||
autocomplete="off"
|
||||
value="1"
|
||||
min="1"
|
||||
step="1"
|
||||
aria-label="Quantity"
|
||||
name="ticketPurchaseQuantity"
|
||||
type="number"
|
||||
style="flex: 1; max-width: 100px; text-align: center;"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-success lottery-page--action"
|
||||
id="purchaseTicket"
|
||||
onclick="purchaseLotteryTicket()"
|
||||
>
|
||||
Purchase <span id="totalQuantityOfTickets">1</span> for
|
||||
<img
|
||||
alt="coins"
|
||||
class="mr-1 ml-1"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="bottom"
|
||||
height="13"
|
||||
src="/assets/images/{{SITE_NAME}}/coins.webp?v=2"
|
||||
title=""
|
||||
aria-label="coins"
|
||||
data-bs-original-title="coins"
|
||||
/>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-success lottery-page--action"
|
||||
id="purchaseTicket"
|
||||
onclick="purchaseLotteryTicket()"
|
||||
>
|
||||
Purchase <span id="totalQuantityOfTickets">1</span> for
|
||||
<img
|
||||
alt="coins"
|
||||
class="mr-1 ml-1"
|
||||
data-bs-toggle="tooltip"
|
||||
data-bs-placement="bottom"
|
||||
height="13"
|
||||
src="/assets/images/{{SITE_NAME}}/coins.webp?v=2"
|
||||
title=""
|
||||
aria-label="coins"
|
||||
data-bs-original-title="coins"
|
||||
/>
|
||||
|
||||
<span id="totalCostOfTickets">12</span>
|
||||
</button>
|
||||
</div>
|
||||
<span id="totalCostOfTickets">12</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Success -->
|
||||
<div
|
||||
class="toast"
|
||||
id="lottery-post-success"
|
||||
style="
|
||||
position: fixed;
|
||||
bottom: 1.5rem;
|
||||
margin: 0 auto;
|
||||
left: 0;
|
||||
right: 0;
|
||||
width: unset;
|
||||
z-index: 1000;
|
||||
height: auto !important;
|
||||
"
|
||||
role="alert"
|
||||
aria-live="assertive"
|
||||
aria-atomic="true"
|
||||
data-bs-animation="true"
|
||||
data-bs-autohide="true"
|
||||
data-bs-delay="5000"
|
||||
>
|
||||
<div class="toast-body bg-success text-center text-white">
|
||||
<i class="fas fa-comment-alt-smile mr-2"></i
|
||||
><span id="lottery-post-success-text"></span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Success -->
|
||||
<div
|
||||
class="toast"
|
||||
id="lottery-post-success"
|
||||
style="
|
||||
position: fixed;
|
||||
bottom: 1.5rem;
|
||||
margin: 0 auto;
|
||||
left: 0;
|
||||
right: 0;
|
||||
width: unset;
|
||||
z-index: 1000;
|
||||
height: auto !important;
|
||||
"
|
||||
role="alert"
|
||||
aria-live="assertive"
|
||||
aria-atomic="true"
|
||||
data-bs-animation="true"
|
||||
data-bs-autohide="true"
|
||||
data-bs-delay="5000"
|
||||
>
|
||||
<div class="toast-body bg-success text-center text-white">
|
||||
<i class="fas fa-comment-alt-smile mr-2"></i
|
||||
><span id="lottery-post-success-text"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Error -->
|
||||
<div
|
||||
class="toast"
|
||||
id="lottery-post-error"
|
||||
style="
|
||||
position: fixed;
|
||||
bottom: 1.5rem;
|
||||
margin: 0 auto;
|
||||
left: 0;
|
||||
right: 0;
|
||||
width: unset;
|
||||
z-index: 1000;
|
||||
height: auto !important;
|
||||
"
|
||||
role="alert"
|
||||
aria-live="assertive"
|
||||
aria-atomic="true"
|
||||
data-bs-animation="true"
|
||||
data-bs-autohide="true"
|
||||
data-bs-delay="5000"
|
||||
>
|
||||
<div class="toast-body bg-danger text-center text-white">
|
||||
<i class="fas fa-exclamation-circle mr-2"></i
|
||||
><span id="lottery-post-error-text"></span>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Error -->
|
||||
<div
|
||||
class="toast"
|
||||
id="lottery-post-error"
|
||||
style="
|
||||
position: fixed;
|
||||
bottom: 1.5rem;
|
||||
margin: 0 auto;
|
||||
left: 0;
|
||||
right: 0;
|
||||
width: unset;
|
||||
z-index: 1000;
|
||||
height: auto !important;
|
||||
"
|
||||
role="alert"
|
||||
aria-live="assertive"
|
||||
aria-atomic="true"
|
||||
data-bs-animation="true"
|
||||
data-bs-autohide="true"
|
||||
data-bs-delay="5000"
|
||||
>
|
||||
<div class="toast-body bg-danger text-center text-white">
|
||||
<i class="fas fa-exclamation-circle mr-2"></i
|
||||
><span id="lottery-post-error-text"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="{{asset('js/lottery.js')}}"></script>
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
{% endif %}
|
||||
|
||||
{% if p.award_count("firework") %}
|
||||
<script defer src="/assets/js/fireworks.js?v=4"></script>
|
||||
<script defer src="/assets/js/fireworks.js?v=4"></script>
|
||||
<div class="firework">
|
||||
<img src="">
|
||||
</div>
|
||||
|
|
60
run_tests.py
60
run_tests.py
|
@ -5,48 +5,48 @@ import sys
|
|||
|
||||
# we want to leave the container in whatever state it currently is, so check to see if it's running
|
||||
docker_inspect = subprocess.run([
|
||||
"docker",
|
||||
"container",
|
||||
"inspect",
|
||||
"-f", "{{.State.Status}}",
|
||||
"rDrama",
|
||||
],
|
||||
capture_output = True,
|
||||
).stdout.decode("utf-8").strip()
|
||||
"docker",
|
||||
"container",
|
||||
"inspect",
|
||||
"-f", "{{.State.Status}}",
|
||||
"rDrama",
|
||||
],
|
||||
capture_output = True,
|
||||
).stdout.decode("utf-8").strip()
|
||||
|
||||
was_running = docker_inspect == "running"
|
||||
|
||||
# update containers, just in case they're out of date
|
||||
if was_running:
|
||||
print("Updating containers . . .", flush=True)
|
||||
print("Updating containers . . .", flush=True)
|
||||
else:
|
||||
print("Starting containers . . .", flush=True)
|
||||
print("Starting containers . . .", flush=True)
|
||||
subprocess.run([
|
||||
"docker-compose",
|
||||
"up",
|
||||
"--build",
|
||||
"-d",
|
||||
],
|
||||
check = True,
|
||||
)
|
||||
"docker-compose",
|
||||
"up",
|
||||
"--build",
|
||||
"-d",
|
||||
],
|
||||
check = True,
|
||||
)
|
||||
|
||||
# run the test
|
||||
print("Running test . . .", flush=True)
|
||||
result = subprocess.run([
|
||||
"docker",
|
||||
"exec",
|
||||
"rDrama",
|
||||
"bash", "-c", "cd service && python3 -m pytest -s"
|
||||
])
|
||||
"docker",
|
||||
"exec",
|
||||
"rDrama",
|
||||
"bash", "-c", "cd service && python3 -m pytest -s"
|
||||
])
|
||||
|
||||
if not was_running:
|
||||
# shut down, if we weren't running in the first place
|
||||
print("Shutting down containers . . .", flush=True)
|
||||
subprocess.run([
|
||||
"docker-compose",
|
||||
"stop",
|
||||
],
|
||||
check = True,
|
||||
)
|
||||
# shut down, if we weren't running in the first place
|
||||
print("Shutting down containers . . .", flush=True)
|
||||
subprocess.run([
|
||||
"docker-compose",
|
||||
"stop",
|
||||
],
|
||||
check = True,
|
||||
)
|
||||
|
||||
sys.exit(result.returncode)
|
Loading…
Reference in New Issue