Skip to content

Commit fa6a9ee

Browse files
committed
Merge remote-tracking branch 'origin/master' into rewrite
2 parents 6b48c30 + 9144ad8 commit fa6a9ee

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

goathacks/cli.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from goathacks import db, mail
1010
from goathacks.models import User
1111

12+
from tabulate import tabulate
13+
1214
gr = AppGroup("user")
1315

1416
@gr.command('create')
@@ -122,3 +124,56 @@ def drop_user(email, confirm):
122124
db.session.commit()
123125
click.echo(f"Dropped {user.first_name}'s registration")
124126

127+
@gr.command("list")
128+
def list_users():
129+
"""
130+
Gets a list of all users
131+
"""
132+
users = User.query.all()
133+
134+
def make_table_content(user):
135+
return [user.email, f"{user.first_name} {user.last_name}", user.waitlisted, user.is_admin]
136+
137+
table = map(make_table_content, users)
138+
139+
print(tabulate(table, headers=["Email", "Name", "Waitlisted", "Admin"]))
140+
141+
142+
@gr.command("autopromote")
143+
def autopromote_users():
144+
"""
145+
Runs through and automatically promotes users up to the waitlist limit
146+
"""
147+
WAITLIST_LIMIT = current_app.config['MAX_BEFORE_WAITLIST']
148+
num_confirmed = db.session.query(User).filter(User.waitlisted == False).count()
149+
click.echo(f"Got {num_confirmed} confirmed attendees")
150+
num_waitlisted = db.session.query(User).filter(User.waitlisted == True).count()
151+
click.echo(f"Got {num_waitlisted} waitlisted attendees")
152+
153+
num_to_promote = WAITLIST_LIMIT - num_confirmed
154+
155+
if num_to_promote > num_waitlisted:
156+
num_to_promote = num_waitlisted
157+
158+
click.echo(f"About to promote {str(num_to_promote)} attendees from waitlist")
159+
160+
users = db.session.query(User).filter(User.waitlisted == True).all()
161+
162+
num_promoted = 0
163+
num_to_promote_orig = num_to_promote
164+
165+
for u in users:
166+
if num_to_promote > 0:
167+
click.echo(f"Attempting to promote {u.email} ({u.id})")
168+
u.waitlisted = False
169+
db.session.commit()
170+
msg = Message("Waitlist Promotion")
171+
msg.add_recipient(u.email)
172+
msg.sender = ("GoatHacks Team", "[email protected]")
173+
msg.body = render_template("emails/waitlist_promotion.txt", user=u)
174+
mail.send(msg)
175+
num_promoted += 1
176+
num_to_promote -= 1
177+
178+
click.echo(f"Promoted {num_promoted}/{num_to_promote_orig} attendees off the waitlist!")
179+

goathacks/config.py.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ SECRET_KEY="bad-key-change-me"
44

55
UPLOAD_FOLDER="./uploads/"
66

7+
DISCORD_LINK=None
8+
79

810
# Mail settings
911
MAIL_SERVER="localhost"

goathacks/templates/events/qrcode.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
<title>QR Code for {{ event.name }}</title>
33
</head>
44
<body>
5-
<img src="{{ qrcode(url_for('events.workshop_checkin', id=event.id)) }}">
5+
<img src="{{ qrcode(url_for('events.workshop_checkin', id=event.id,
6+
_external=True)) }}">
67
</body>

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ WTForms==3.0.1
2525
ulid
2626
bootstrap-flask
2727
Font-Awesome-Flask
28+
tabulate

0 commit comments

Comments
 (0)