mirror of
https://github.com/UofCBaja/BajaCloud.git
synced 2025-07-06 11:07:12 -06:00
Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
63059233da |
@ -82,7 +82,7 @@ if __name__ == "__main__":
|
||||
year_donation = int(str(datetime.datetime.now().year)[2:]) + 1 # gets the last two digits of the current year then adds 1 for the current season
|
||||
# name based off the 2025 naming system
|
||||
# Define the path to the Excel file and the lock file
|
||||
file_name = f"../Interviews/OR{year_donation}-L-Interview Data.xlsx"
|
||||
file_name = f"./Interviews/OR{year_donation}-L-Interview Data.xlsx"
|
||||
try:
|
||||
data = ReadDatabase(file_name)
|
||||
print(json.dumps(data, indent=4))
|
||||
|
@ -33,8 +33,7 @@ def ReadDatabase(file_path, lock_path):
|
||||
# Process each row in the DataFrame to structure data by date and time
|
||||
for _, row in df.iterrows():
|
||||
# Convert Date and Start Time to string format for easier comparison
|
||||
date = str(row['Date']).split(" ")[0] # Extract the date part
|
||||
|
||||
date = str(row['Date']).split(" ")[0] # Format date to YYYY-MM-DD
|
||||
start_time = str(row['Start Time Slot'])
|
||||
|
||||
# Calculate the slot capacity and current number of interviewees
|
||||
|
@ -1,8 +1,6 @@
|
||||
import datetime
|
||||
from .ReadDB import ReadDatabase
|
||||
|
||||
|
||||
|
||||
def getSchedulePackager(file_name):
|
||||
"""
|
||||
Packages up the response for a http response
|
||||
@ -41,8 +39,7 @@ def SelectAppointment (file_name, appointmentJson):
|
||||
try:
|
||||
validEmail = validate_email(appointmentJson["intervieweeEmail"], check_deliverability=True)
|
||||
if validEmail:
|
||||
date_formatted = datetime.datetime.strptime(appointmentJson["date"], '%m/%d/%Y').strftime('%Y-%m-%d')
|
||||
status = AppendAppointment(file_path=file_name, date=date_formatted, start_time=appointmentJson["startTime"], interviewee_name=appointmentJson["intervieweeName"], interviewee_email=appointmentJson["intervieweeEmail"])
|
||||
status = AppendAppointment(file_path=file_name, date=appointmentJson["date"], start_time=appointmentJson["startTime"], interviewee_name=appointmentJson["intervieweeName"], interviewee_email=appointmentJson["intervieweeEmail"])
|
||||
|
||||
if status:
|
||||
resBody = {"Success": True, "validEmail": "true"}
|
||||
|
@ -45,94 +45,38 @@ def send_email(interviewee_email="darkicewolf50@gmail.com", interviewee_name="br
|
||||
|
||||
# Message body
|
||||
body = f'''
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<title>Interview Invitation</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Dear {interviewee_name},</p>
|
||||
<p>Your interview has been scheduled on {date} at {start_time}</p>
|
||||
<p>Please ensure to be available at the designated time.</p>
|
||||
<table
|
||||
role="presentation"
|
||||
border="0"
|
||||
cellpadding="0"
|
||||
cellspacing="0"
|
||||
style="width: 100%; margin: 20px 0">
|
||||
<tr>
|
||||
<td
|
||||
align="center"
|
||||
style="width: 48%; margin-right: 1%">
|
||||
<a
|
||||
href="https://calendar.google.com/calendar/render?action=TEMPLATE&text=UCalgary+Baja+Interview+with+{interviewee_name}&dates={start_time_google}/{end_time_google}&details=Interview+with+UCalgary+Baja+Team&location={location}"
|
||||
target="_blank"
|
||||
style="
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
background-color: #376fc9;
|
||||
color: white;
|
||||
padding: 10px 20px;
|
||||
font-family: Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
border-radius: 4px;
|
||||
border: 2px solid grey;
|
||||
">
|
||||
<img
|
||||
src="https://res.cloudinary.com/dpgrgsh7g/image/upload/v1745094071/google-calendar-svgrepo-com_vkmq2n.png"
|
||||
alt="Google Calendar"
|
||||
style="
|
||||
vertical-align: middle;
|
||||
height: 40px;
|
||||
margin-right: 10px;
|
||||
" />
|
||||
Add to Google Calendar
|
||||
</a>
|
||||
</td>
|
||||
<td
|
||||
align="center"
|
||||
style="width: 48%; margin-left: 1%">
|
||||
<a
|
||||
href="https://outlook.live.com/calendar/0/deeplink/compose?subject=UCalgary+Baja+Interview+with+{interviewee_name}&body=Interview+with+UCalgary+Baja+Team&location={location}&startdt={outlook_start}&enddt={outlook_end}"
|
||||
target="_blank"
|
||||
style="
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
background-color: #376fc9;
|
||||
color: white;
|
||||
padding: 10px 20px;
|
||||
font-family: Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
border-radius: 4px;
|
||||
border: 2px solid grey;
|
||||
">
|
||||
<img
|
||||
src="https://res.cloudinary.com/dpgrgsh7g/image/upload/v1745094071/ms-outlook-svgrepo-com_idmyw0.png"
|
||||
alt="Outlook Logo"
|
||||
style="
|
||||
vertical-align: middle;
|
||||
height: 40px;
|
||||
margin-right: 10px;
|
||||
" />
|
||||
Add to Outlook Calendar
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>Best regards,</p>
|
||||
<p>UCalgary Baja Interview Team</p>
|
||||
<img
|
||||
src="https://res.cloudinary.com/dpgrgsh7g/image/upload/v1733003224/UCalgaryBAJA_Logo-2024_mpmljh.png"
|
||||
alt="UCalgary Baja Logo"
|
||||
height="120svh" />
|
||||
<p>
|
||||
If you need to change the date or cancel please email
|
||||
<a href="mailto:uofcbaja@gmail.com">uofcbaja@gmail.com</a>
|
||||
or reply all to this email
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
'''
|
||||
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<title>Interview Invitation</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Dear {interviewee_name},</p>
|
||||
<p>Your interview has been scheduled on {date} at {start_time} MST.</p>
|
||||
<p> Your interview location is at {location} or will be emailed to you. </p>
|
||||
<p>Please ensure to be available at the designated time.</p>
|
||||
<a
|
||||
href="https://calendar.google.com/calendar/render?action=TEMPLATE&text=UCalgary+Baja+Interview+with+{interviewee_name}&dates={start_time_google}/{end_time_google}&details=Interview+with+UCalgary+Baja+Team&location={location}"
|
||||
target="_blank"
|
||||
>
|
||||
<button type="button" class="AddtoCal">Add to Google Calendar</button>
|
||||
</a>
|
||||
<a
|
||||
href="https://outlook.live.com/calendar/0/deeplink/compose?subject=UCalgary+Baja+Interview+with+{interviewee_name}&body=Interview+with+UCalgary+Baja+Team&location={location}&startdt={outlook_start}&enddt={outlook_end}"
|
||||
target="_blank"
|
||||
>
|
||||
<button type="button" class="AddtoCal">Add to Outlook Calendar</button>
|
||||
</a>
|
||||
<p>Best regards,</p>
|
||||
<p>UCalgary Baja Interview Team</p>
|
||||
<img
|
||||
src="https://res.cloudinary.com/dpgrgsh7g/image/upload/v1733003224/UCalgaryBAJA_Logo-2024_mpmljh.png"
|
||||
alt="UCalgary Baja Team"
|
||||
height="120svh"
|
||||
/>
|
||||
</body>
|
||||
</html>
|
||||
'''
|
||||
|
||||
msg.attach(MIMEText(body, 'html'))
|
||||
|
||||
try:
|
||||
|
@ -1,86 +1,29 @@
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<title>Interview Invitation</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Dear {interviewee_name},</p>
|
||||
<p>Your interview has been scheduled on {date} at {start_time}</p>
|
||||
<p>Please ensure to be available at the designated time.</p>
|
||||
<table
|
||||
role="presentation"
|
||||
border="0"
|
||||
cellpadding="0"
|
||||
cellspacing="0"
|
||||
style="width: 100%; margin: 20px 0">
|
||||
<tr>
|
||||
<td
|
||||
align="center"
|
||||
style="width: 48%; margin-right: 1%">
|
||||
<a
|
||||
href="https://calendar.google.com/calendar/render?action=TEMPLATE&text=UCalgary+Baja+Interview+with+{interviewee_name}&dates={start_time_google}/{end_time_google}&details=Interview+with+UCalgary+Baja+Team&location={location}"
|
||||
target="_blank"
|
||||
style="
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
background-color: #376fc9;
|
||||
color: white;
|
||||
padding: 10px 20px;
|
||||
font-family: Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
border-radius: 4px;
|
||||
border: 2px solid grey;
|
||||
">
|
||||
<img
|
||||
src="https://res.cloudinary.com/dpgrgsh7g/image/upload/v1745094071/google-calendar-svgrepo-com_vkmq2n.png"
|
||||
alt="Google Calendar"
|
||||
style="
|
||||
vertical-align: middle;
|
||||
height: 40px;
|
||||
margin-right: 10px;
|
||||
" />
|
||||
Add to Google Calendar
|
||||
</a>
|
||||
</td>
|
||||
<td
|
||||
align="center"
|
||||
style="width: 48%; margin-left: 1%">
|
||||
<a
|
||||
href="https://outlook.live.com/calendar/0/deeplink/compose?subject=UCalgary+Baja+Interview+with+{interviewee_name}&body=Interview+with+UCalgary+Baja+Team&location={location}&startdt={outlook_start}&enddt={outlook_end}"
|
||||
target="_blank"
|
||||
style="
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
background-color: #376fc9;
|
||||
color: white;
|
||||
padding: 10px 20px;
|
||||
font-family: Arial, sans-serif;
|
||||
font-size: 14px;
|
||||
border-radius: 4px;
|
||||
border: 2px solid grey;
|
||||
">
|
||||
<img
|
||||
src="https://res.cloudinary.com/dpgrgsh7g/image/upload/v1745094071/ms-outlook-svgrepo-com_idmyw0.png"
|
||||
alt="Outlook Logo"
|
||||
style="
|
||||
vertical-align: middle;
|
||||
height: 40px;
|
||||
margin-right: 10px;
|
||||
" />
|
||||
Add to Outlook Calendar
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>Best regards,</p>
|
||||
<p>UCalgary Baja Interview Team</p>
|
||||
<img
|
||||
src="https://res.cloudinary.com/dpgrgsh7g/image/upload/v1733003224/UCalgaryBAJA_Logo-2024_mpmljh.png"
|
||||
alt="UCalgary Baja Logo"
|
||||
height="120svh" />
|
||||
<p>
|
||||
If you need to change the date or cancel please email
|
||||
<a href="mailto:uofcbaja@gmail.com">uofcbaja@gmail.com</a>
|
||||
or reply all to this email
|
||||
</p>
|
||||
</body>
|
||||
<head>
|
||||
<title>Interview Invitation</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Dear {interviewee_name},</p>
|
||||
<p>Your interview has been scheduled on {date} at {start_time}</p>
|
||||
<p>Please ensure to be available at the designated time.</p>
|
||||
<a
|
||||
href="https://calendar.google.com/calendar/render?action=TEMPLATE&text=Interview+with+{interviewee_name}&dates=20241130T100000Z/20241130T110000Z&details=Interview+with+UCalgary+Baja+Team&location=ENC37"
|
||||
target="_blank"
|
||||
>
|
||||
<button type="button" class="AddtoCal">Add to Google Calendar</button>
|
||||
</a>
|
||||
<a
|
||||
href="https://outlook.live.com/calendar/0/deeplink/compose?subject=Interview+with+{interviewee_name}&body=Interview+with+UCalgary+Baja+Team&location=ENC37&startdt=2024-11-30T10:00:00&enddt=2024-11-30T11:00:00"
|
||||
target="_blank"
|
||||
>
|
||||
<button type="button" class="AddtoCal">Add to Outlook Calendar</button>
|
||||
</a>
|
||||
<p>Best regards,</p>
|
||||
<p>UCalgary Baja Interview Team</p>
|
||||
<img
|
||||
src="https://res.cloudinary.com/dpgrgsh7g/image/upload/v1733003224/UCalgaryBAJA_Logo-2024_mpmljh.png"
|
||||
alt="UCalgary Baja Team"
|
||||
height="120svh"
|
||||
/>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -5,7 +5,7 @@ The Docker Project that runs on the Baja Nas
|
||||
|
||||
# BAJA CLoud Backend
|
||||
|
||||
Can be found [here](https://bajabackend.bajacloud.duckdns.org/)
|
||||
Can be found [here](http://darkicewofl50.asuscomm.com:43443/)
|
||||
|
||||
Reason in "Baja Data 2024 - 2025/W - Software/Brock's Learning.docx"
|
||||
|
||||
|
44
main.py
44
main.py
@ -1,6 +1,5 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.responses import JSONResponse
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from pydantic import BaseModel
|
||||
|
||||
from InterviewBooking.NoSheet import NoSheet
|
||||
@ -15,32 +14,8 @@ if not os.path.isfile(file_name):
|
||||
os.makedirs(os.path.dirname(file_name), exist_ok=True)
|
||||
NoSheet(file_name)
|
||||
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"], # This allows all origins
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"], # Allow all methods (GET, POST, OPTIONS, etc.)
|
||||
allow_headers=["*"], # Allow all headers
|
||||
)
|
||||
"""
|
||||
YOU MUST ADD CORS MANUALLY TO ANY METHOD USE THIS TEMPLATE
|
||||
ADD TO JSONRESPONSE
|
||||
|
||||
USE APPROPRIATE METHOD fOR THE TYPE IE
|
||||
@app.get = ... "Access-Control-Allow-Methods": "GET", ...
|
||||
|
||||
headers={
|
||||
"isBase64Encoded": "false", # Header Modification
|
||||
# Adding CORS headers explicitly
|
||||
"Access-Control-Allow-Origin": "*", # Allow all origins
|
||||
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS", # Allowed methods
|
||||
"Access-Control-Allow-Headers": "*", # Allow all headers
|
||||
},
|
||||
"""
|
||||
|
||||
@app.get("/")
|
||||
def get_root():
|
||||
"""
|
||||
@ -62,9 +37,6 @@ def get_root():
|
||||
return JSONResponse(
|
||||
headers={
|
||||
"isBase64Encoded": "false", # Header Modification
|
||||
"Access-Control-Allow-Origin": "*", # Allow all origins
|
||||
"Access-Control-Allow-Methods": "GET", # Allowed methods
|
||||
"Access-Control-Allow-Headers": "*", # Allow all headers
|
||||
},
|
||||
content={
|
||||
"body": res # Ensure res is a dict or do json.dumps to enusre it is stringified
|
||||
@ -96,10 +68,6 @@ async def getAppointments():
|
||||
return JSONResponse(
|
||||
headers={
|
||||
"isBase64Encoded": "false", # Header Modification
|
||||
# Adding CORS headers explicitly
|
||||
"Access-Control-Allow-Origin": "*", # Allow all origins
|
||||
"Access-Control-Allow-Methods": "GET", # Allowed methods
|
||||
"Access-Control-Allow-Headers": "*", # Allow all headers
|
||||
},
|
||||
content={
|
||||
"body": res # Ensure res is a dict or do json.dumps to enusre it is stringified
|
||||
@ -124,8 +92,8 @@ class Appointment(BaseModel):
|
||||
|
||||
"""
|
||||
intervieweeName: str
|
||||
startTime: str
|
||||
date: str
|
||||
startTime: str
|
||||
intervieweeEmail: str
|
||||
|
||||
|
||||
@ -143,16 +111,13 @@ async def postSelectInterview(rawRequest: Appointment):
|
||||
``Contact``: darkicewolf50@gmail.com
|
||||
|
||||
"""
|
||||
requestDict = {key: str(value) for key, value in rawRequest.model_dump().items()}
|
||||
|
||||
requestDict = {key: str(value) for key, value in rawRequest.dict().items()}
|
||||
res = SelectAppointment(file_name, requestDict)
|
||||
|
||||
|
||||
return JSONResponse(
|
||||
headers={
|
||||
"isBase64Encoded": "false", # Header Modification
|
||||
# Adding CORS headers explicitly
|
||||
"Access-Control-Allow-Origin": "*", # Allow all origins
|
||||
"Access-Control-Allow-Methods": "POST", # Allowed methods
|
||||
"Access-Control-Allow-Headers": "*", # Allow all headers
|
||||
},
|
||||
content={
|
||||
"body": res # Ensure res is a dict or do json.dumps to enusre it is stringified
|
||||
@ -160,3 +125,4 @@ async def postSelectInterview(rawRequest: Appointment):
|
||||
|
||||
# status_code=200 commented out just to show how to change it if you wanted
|
||||
)
|
||||
|
||||
|
Reference in New Issue
Block a user