u
This commit is contained in:
parent
f5cf5cf396
commit
ffe4075157
7 changed files with 84 additions and 10 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,6 +2,8 @@ resumes*/
|
||||||
resumes*.zip
|
resumes*.zip
|
||||||
config_hackWPI.py
|
config_hackWPI.py
|
||||||
config.py
|
config.py
|
||||||
|
admin/*.json
|
||||||
|
admin/*.csv
|
||||||
# Created by https://www.gitignore.io/api/web,vim,git,macos,linux,bower,grunt,python,pycharm,windows,eclipse,webstorm,intellij,jetbrains,virtualenv,visualstudio,visualstudiocode
|
# Created by https://www.gitignore.io/api/web,vim,git,macos,linux,bower,grunt,python,pycharm,windows,eclipse,webstorm,intellij,jetbrains,virtualenv,visualstudio,visualstudiocode
|
||||||
|
|
||||||
# Dev ENV Stuff
|
# Dev ENV Stuff
|
||||||
|
|
44
admin/__init__.py
Normal file
44
admin/__init__.py
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
import json
|
||||||
|
import csv
|
||||||
|
from io import StringIO
|
||||||
|
|
||||||
|
|
||||||
|
def json_to_csv(data):
|
||||||
|
# Opening JSON file and loading the data
|
||||||
|
# into the variable data
|
||||||
|
|
||||||
|
json_data=[]
|
||||||
|
if(type(data) is json):
|
||||||
|
json_data=data
|
||||||
|
elif(type(data) is str):
|
||||||
|
json_data=json.loads(data)
|
||||||
|
else:
|
||||||
|
json_data = json.loads(json.dumps(data))
|
||||||
|
# now we will open a file for writing
|
||||||
|
csv_out = StringIO("")
|
||||||
|
|
||||||
|
# create the csv writer object
|
||||||
|
csv_writer = csv.writer(csv_out)
|
||||||
|
|
||||||
|
# Counter variable used for writing
|
||||||
|
# headers to the CSV file
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
for e in json_data:
|
||||||
|
if count == 0:
|
||||||
|
|
||||||
|
# Writing headers of CSV file
|
||||||
|
header = e.keys()
|
||||||
|
csv_writer.writerow(header)
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
# Writing data of CSV file
|
||||||
|
csv_writer.writerow(e.values())
|
||||||
|
csv_out.seek(0)
|
||||||
|
return csv_out.read()
|
||||||
|
|
||||||
|
if __name__=="__main__":
|
||||||
|
with open('hack22.json') as f:
|
||||||
|
j = json.load(f)['data']
|
||||||
|
print(type(j))
|
||||||
|
print(json_to_csv(j))
|
18
flask_app.py
18
flask_app.py
|
@ -545,21 +545,29 @@ def send_email(to, subject, body):
|
||||||
body += 'To update your status, you can go to hack.wpi.edu/dashboard\n'
|
body += 'To update your status, you can go to hack.wpi.edu/dashboard\n'
|
||||||
body += '\nAll the best!\nThe Hack@WPI Team'
|
body += '\nAll the best!\nThe Hack@WPI Team'
|
||||||
|
|
||||||
server = smtplib.SMTP('smtp.gmail.com', 587)
|
smtp_server = api_keys['smtp_email']['smtp_server']
|
||||||
|
smtp_port = api_keys['smtp_email']['smtp_port']
|
||||||
|
server = smtplib.SMTP(smtp_server, smtp_port)
|
||||||
|
# Enable TLS if we're using secure SMTP
|
||||||
|
if(smtp_port > 25):
|
||||||
server.starttls()
|
server.starttls()
|
||||||
sender = api_keys['smtp_email']['user']
|
user = api_keys['smtp_email']['user']
|
||||||
server.login(sender, api_keys['smtp_email']['pass'])
|
sender = api_keys['smtp_email']['sender']
|
||||||
|
# Login if we're using server with auth
|
||||||
|
if ('pass' in api_keys['smtp_email']):
|
||||||
|
server.login(user, api_keys['smtp_email']['pass'])
|
||||||
|
|
||||||
msg = _create_MIMEMultipart(subject, sender, to, body)
|
msg = _create_MIMEMultipart(subject, sender, to, body, user)
|
||||||
|
|
||||||
server.send_message(msg)
|
server.send_message(msg)
|
||||||
print("Sucess! (Email to " + to)
|
print("Sucess! (Email to " + to)
|
||||||
|
|
||||||
|
|
||||||
def _create_MIMEMultipart(subject, sender, to, body):
|
def _create_MIMEMultipart(subject, sender, to, body, user=None):
|
||||||
msg = MIMEMultipart()
|
msg = MIMEMultipart()
|
||||||
msg['Subject'] = subject
|
msg['Subject'] = subject
|
||||||
msg['From'] = sender
|
msg['From'] = sender
|
||||||
|
msg.add_header('reply-to', user)
|
||||||
if type(to) == list:
|
if type(to) == list:
|
||||||
msg['To'] = ", ".join(to)
|
msg['To'] = ", ".join(to)
|
||||||
else:
|
else:
|
||||||
|
|
15
manage_waitlist
Executable file
15
manage_waitlist
Executable file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# cd to script dir
|
||||||
|
SCRIPT_RELATIVE_DIR=$(dirname "${BASH_SOURCE[0]}")
|
||||||
|
cd $SCRIPT_RELATIVE_DIR
|
||||||
|
|
||||||
|
# enable python venv
|
||||||
|
source ./venv/bin/activate
|
||||||
|
|
||||||
|
echo `which python`
|
||||||
|
|
||||||
|
# noot
|
||||||
|
python ./manage_waitlist.py
|
||||||
|
|
||||||
|
# disable venv
|
||||||
|
deactivate
|
|
@ -1,6 +1,6 @@
|
||||||
import requests
|
import requests
|
||||||
from flask_app import db, Hacker, send_email, gen_new_auto_promote_keys
|
from flask_app import db, Hacker, send_email, gen_new_auto_promote_keys
|
||||||
from config_hackWPI import WAITLIST_LIMIT
|
from config_hackWPI import WAITLIST_LIMIT, WEBHOOK_URL
|
||||||
|
|
||||||
num_attendees = db.session.query(Hacker).filter(Hacker.waitlisted == False).count()
|
num_attendees = db.session.query(Hacker).filter(Hacker.waitlisted == False).count()
|
||||||
num_waitlisted = db.session.query(Hacker).filter(Hacker.waitlisted == True).count()
|
num_waitlisted = db.session.query(Hacker).filter(Hacker.waitlisted == True).count()
|
||||||
|
@ -52,5 +52,9 @@ msg += ' ' + str(errs) + '\n'
|
||||||
|
|
||||||
print(msg)
|
print(msg)
|
||||||
|
|
||||||
|
# requests.post(WEBHOOK_URL, {
|
||||||
|
# "content": msg
|
||||||
|
# })
|
||||||
|
|
||||||
# send_email('hack@wpi.edu', 'HackWPI - Daily Waitlist Report!', msg)
|
# send_email('hack@wpi.edu', 'HackWPI - Daily Waitlist Report!', msg)
|
||||||
send_email('bkayastha@wpi.edu', 'HackWPI - Daily Waitlist Report!', msg)
|
send_email('mikel@wpi.edu', 'HackWPI - Daily Waitlist Report!', msg)
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 6a023042c9f337071b701fbff228581b0a1e6e14
|
Subproject commit bfb9d7799fbb8630f4351f043a05aa617964becf
|
|
@ -59,6 +59,7 @@
|
||||||
<input type="checkbox" name="mlh1" id="checkboxid1" required><label for="checkboxid1"><b style="color:white;">*I have read and agree to the MLH Code of Conduct</b></label>
|
<input type="checkbox" name="mlh1" id="checkboxid1" required><label for="checkboxid1"><b style="color:white;">*I have read and agree to the MLH Code of Conduct</b></label>
|
||||||
<input type="checkbox" name="mlh2" id="checkboxid2" required><label for="checkboxid2"><b style="color:white;">*I authorize you to share my application/registration information with Major League Hacking for event administration, ranking, and MLH administration in-line with the MLH Privacy Policy. I further agree to the terms of both the MLH Contest Terms and Conditions and the MLH Privacy Policy.</b></label>
|
<input type="checkbox" name="mlh2" id="checkboxid2" required><label for="checkboxid2"><b style="color:white;">*I authorize you to share my application/registration information with Major League Hacking for event administration, ranking, and MLH administration in-line with the MLH Privacy Policy. I further agree to the terms of both the MLH Contest Terms and Conditions and the MLH Privacy Policy.</b></label>
|
||||||
<input type="checkbox" name="mlh3" id="checkboxid3" required><label for="checkboxid3"><b style="color:white;">*I authorize MLH to send me pre- and post-event information emails, which contain free credit and opportunities from their partners.</b></label>
|
<input type="checkbox" name="mlh3" id="checkboxid3" required><label for="checkboxid3"><b style="color:white;">*I authorize MLH to send me pre- and post-event information emails, which contain free credit and opportunities from their partners.</b></label>
|
||||||
|
<input type="checkbox" name="mlh3" id="checkboxid4" required><label for="checkboxid4"><b style="color:white;">*I understand that in-person participation is limited to WPI students that are part of the testing protocol only.</b></label>
|
||||||
<br><br>
|
<br><br>
|
||||||
<center><input name="submit" class="btn btn-lg btn-primary btn-invert" type="submit" value="Submit"/></center>
|
<center><input name="submit" class="btn btn-lg btn-primary btn-invert" type="submit" value="Submit"/></center>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Add table
Reference in a new issue