Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anya's branch #14

Open
wants to merge 75 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
7862f4a
updating name
AnyaKhemlani Nov 21, 2024
f0093b9
update home.py
AnyaKhemlani Dec 2, 2024
3088897
starting work on system admin pages
AnyaKhemlani Dec 2, 2024
34c1dd6
Added Student profile, with Image, Stats and Resumes
lilybedi Dec 2, 2024
3cd49a7
added logo + working on alumn pages
AnyaKhemlani Dec 2, 2024
3357937
made the colors match our brand identity
AnyaKhemlani Dec 2, 2024
86a4b4a
Update Home.py
AnyaKhemlani Dec 2, 2024
bc20b26
Merge branch 'anya's-branch'
AnyaKhemlani Dec 2, 2024
8e0551b
Add files via upload
tarinis1 Dec 5, 2024
6095260
Editing the Student info page
lilybedi Dec 5, 2024
f2c17a3
Added profile photo
lilybedi Dec 5, 2024
942b57f
Add files via upload
tarinis1 Dec 5, 2024
9fd51f6
Committing changes to Career_Compass_Database.sql file
Dec 5, 2024
814bdca
Redid the whole student page + proper naming
lilybedi Dec 5, 2024
ddf5be9
Committing working changes to database schema creation
Dec 5, 2024
4a7cf39
Stylistically Finalized Student Prof
lilybedi Dec 5, 2024
aeb8b6b
Made changes to schema format. changed Many to Many relationship for …
Dec 5, 2024
60a6ab4
about 2/3 done with refactoring of data
Dec 5, 2024
44043d2
Finished (atleast first draft) student profile page
lilybedi Dec 5, 2024
4c115b3
Adding the Alumni Majors and minor join tables to the schema
Dec 5, 2024
58f56f5
Progressing forward with updates to the DB schema
Dec 5, 2024
325ab0a
Trying to ensure that the data aligns with itself
Dec 5, 2024
88caad2
Preliminary job applications profile
lilybedi Dec 5, 2024
7a10468
Makes proper buttons
lilybedi Dec 5, 2024
ad1d022
Merge branch 'Lily's-Branch'
AnyaKhemlani Dec 5, 2024
40b96eb
Ensuring Application has a Many to Many relationship with student
Dec 5, 2024
fb15d70
trying to finish up table creation -- specifically relationship with …
Dec 5, 2024
8882c7d
re-fixing home and modifying chat stuff
AnyaKhemlani Dec 5, 2024
5c9574b
fixed navbar in sutdent section
KalinaM11 Dec 5, 2024
b171a6f
Reverted the application because I made a mistake with StudentApplica…
Dec 5, 2024
3f17d27
fixed navabar for students
KalinaM11 Dec 5, 2024
d045ded
Finished modeling messages
Dec 5, 2024
037ec51
Deleting old template, going to run the database and see what happens
Dec 5, 2024
aa2f3bf
deleted csvs
KalinaM11 Dec 5, 2024
6d07816
Merge branch 'main' into kalina
KalinaM11 Dec 5, 2024
32653e7
Merge pull request #2 from lilybedi/kalina
KalinaM11 Dec 5, 2024
97284e2
Revert "Merge branch 'main' into kalina"
KalinaM11 Dec 5, 2024
7d226de
Merge pull request #3 from lilybedi/kalina
KalinaM11 Dec 5, 2024
1f87865
Adding changes to fix syntax
Dec 5, 2024
b9ee24e
Fixing order -- still getting compile problems
Dec 5, 2024
2f3de9f
Finally, this passes syntax and creates everything
Dec 5, 2024
e691f9b
Updated nav bar and advisor section
KalinaM11 Dec 5, 2024
26641bf
Merge pull request #4 from lilybedi/kalina
KalinaM11 Dec 5, 2024
6618d68
Making small change to create pull request
Dec 6, 2024
c152893
Merge pull request #5 from lilybedi/neel/database-creation/populating-db
neel-avancha Dec 6, 2024
1c86103
Created several pages, cosmetically functional
lilybedi Dec 6, 2024
9fba6ab
Committing the back-end file
Dec 6, 2024
496f65b
Committing working student routes, further testing/checking post routes
Dec 6, 2024
e3c5d77
All routes are tested and working outside of the cv upload one -- nee…
Dec 6, 2024
4fe6d1e
Changes to the company view postings
lilybedi Dec 6, 2024
6bb7a70
Lots of new things
lilybedi Dec 6, 2024
cdbec9b
Removed NorthWind
lilybedi Dec 6, 2024
7d7d10d
Removed sample pages
lilybedi Dec 6, 2024
bb27019
Removing unnecessary backend files
lilybedi Dec 6, 2024
d6cf722
Removing template files
lilybedi Dec 6, 2024
cdeb507
Removing more unnecessary files
lilybedi Dec 6, 2024
2cb44e2
Committing routes for Alumni as well as the student
Dec 6, 2024
fcaa0dc
Fixing route to show all postings
Dec 6, 2024
f3065af
Merge pull request #6 from lilybedi/neel/creating-routes
neel-avancha Dec 6, 2024
7ae9c6a
Connected Student Profile to database
lilybedi Dec 6, 2024
0bc9b32
Edit profile button!!
lilybedi Dec 6, 2024
71e22f4
Merge branch 'main' into anya's-branch
AnyaKhemlani Dec 6, 2024
ac13bc8
Prep job search (renamed Student Home) for new fixed routing
lilybedi Dec 6, 2024
3b6223a
Considerable progress on backend connection
lilybedi Dec 6, 2024
426bae0
alumni page to edit profile exists
AnyaKhemlani Dec 6, 2024
415e965
Potentially final commit before merging
lilybedi Dec 6, 2024
f0ddb0a
Merge branch 'main' into Lily's-Branch
lilybedi Dec 6, 2024
2dd5463
Merge pull request #8 from lilybedi/Lily's-Branch
lilybedi Dec 6, 2024
6f2f3d3
Fixing syntax error so the student_routes will compile
Dec 7, 2024
bfb2b93
try to make alumni profile editable
AnyaKhemlani Dec 7, 2024
f5a34db
make it so they can add a co-op experience
AnyaKhemlani Dec 7, 2024
975d0e6
Merge branch 'main' into anya's-branch
AnyaKhemlani Dec 7, 2024
dd72b73
more alumn pages
AnyaKhemlani Dec 7, 2024
69217db
make chat exist!
AnyaKhemlani Dec 7, 2024
8f15db2
Update Add_Alumn_Experience.py
AnyaKhemlani Dec 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions api/.env.template

This file was deleted.

File renamed without changes.
231 changes: 231 additions & 0 deletions api/backend/alumni/alumni_routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,231 @@
from flask import Blueprint
from flask import request
from flask import jsonify
from flask import make_response
from flask import current_app
from backend.db_connection import db
from werkzeug.utils import secure_filename
import logging
#------------------------------------------------------------
# Create a new Blueprint object, which is a collection of
# routes.
alumni = Blueprint('alumni', __name__)

@alumni.route('/<int:alumni_id>', methods=['GET'])
def get_alumni_profile(alumni_id):
query = '''
SELECT a.ID, a.First_Name, a.Last_Name, a.Email, a.Grad_Year,
c.Name as College,
GROUP_CONCAT(DISTINCT f1.Name) as Majors,
GROUP_CONCAT(DISTINCT f2.Name) as Minors
FROM Alumni a
JOIN College c ON a.College_ID = c.ID
LEFT JOIN Alumni_Majors am ON a.ID = am.Alumni_ID
LEFT JOIN Alumni_Minors an ON a.ID = an.Alumni_ID
LEFT JOIN FieldOfStudy f1 ON am.FieldOfStudy_ID = f1.ID
LEFT JOIN FieldOfStudy f2 ON an.FieldOfStudy_ID = f2.ID
WHERE a.ID = %s
GROUP BY a.ID
'''
cursor = db.get_db().cursor()
cursor.execute(query, (alumni_id,))
result = cursor.fetchone()

if not result:
return jsonify({"error": "Alumni not found"}), 404

return jsonify(result), 200



@alumni.route('/<int:alumni_id>', methods=['PUT'])
def update_alumni_profile(alumni_id):
data = request.get_json()
cursor = db.get_db().cursor()

# Get College ID if college is being updated
college_id = None
if 'College' in data:
cursor.execute('SELECT ID FROM College WHERE Name = %s', (data['College'],))
college_result = cursor.fetchone()
if not college_result:
return jsonify({"error": "College not found"}), 404
college_id = college_result['ID']

# Update basic info
update_query = '''
UPDATE Alumni
SET First_Name = %s,
Last_Name = %s,
Email = %s,
Grad_Year = %s
'''
params = [
data['First_Name'],
data['Last_Name'],
data['Email'],
data['Grad_Year']
]

if college_id:
update_query += ', College_ID = %s'
params.append(college_id)

update_query += ' WHERE ID = %s'
params.append(alumni_id)

cursor.execute(update_query, tuple(params))

# Update majors if provided
if 'Majors' in data:
cursor.execute('DELETE FROM Alumni_Majors WHERE Alumni_ID = %s', (alumni_id,))
for major_name in data['Majors']:
cursor.execute('SELECT ID FROM FieldOfStudy WHERE Name = %s', (major_name,))
major_result = cursor.fetchone()
if major_result:
cursor.execute('INSERT INTO Alumni_Majors VALUES (%s, %s)',
(alumni_id, major_result['ID']))

# Update minors if provided
if 'Minors' in data:
cursor.execute('DELETE FROM Alumni_Minors WHERE Alumni_ID = %s', (alumni_id,))
for minor_name in data['Minors']:
cursor.execute('SELECT ID FROM FieldOfStudy WHERE Name = %s', (minor_name,))
minor_result = cursor.fetchone()
if minor_result:
cursor.execute('INSERT INTO Alumni_Minors VALUES (%s, %s)',
(alumni_id, minor_result['ID']))

db.get_db().commit()
return jsonify({"message": "Profile updated successfully"}), 200

@alumni.route('/<int:alumni_id>/positions', methods=['GET'])
def get_alumni_positions(alumni_id):
query = '''
SELECT p.*, c.Name as Company_Name, pl.City, pl.State, pl.Country
FROM Alumni_Position ap
JOIN Posting p ON ap.Position_ID = p.ID
JOIN Company c ON p.Company_ID = c.ID
JOIN Posting_Location pl ON p.Location = pl.ID
WHERE ap.Alumni_ID = %s
ORDER BY p.Date_Start DESC
'''
cursor = db.get_db().cursor()
cursor.execute(query, (alumni_id,))
return jsonify(cursor.fetchall()), 200

@alumni.route('/messages/send', methods=['POST'])
def send_message():
data = request.get_json()
query = '''
INSERT INTO Message (Student_ID, Alumni_ID, Message, RE)
VALUES (%s, %s, %s, %s)
'''
cursor = db.get_db().cursor()
cursor.execute(query, (
data['Student_ID'],
data['Alumni_ID'],
data['Message'],
data.get('RE') # Reply to message ID if it's a reply
))
db.get_db().commit()
return jsonify({"message": "Message sent successfully"}), 201

@alumni.route('/messages/<int:alumni_id>', methods=['GET'])
def get_messages(alumni_id):
query = '''
SELECT m.*,
s.First_Name as Student_First_Name,
s.Last_Name as Student_Last_Name
FROM Message m
JOIN Student s ON m.Student_ID = s.ID
WHERE m.Alumni_ID = %s
ORDER BY m.ID DESC
'''
cursor = db.get_db().cursor()
cursor.execute(query, (alumni_id,))
return jsonify(cursor.fetchall()), 200

@alumni.route('/postings', methods=['GET'])
def view_postings():
query = '''
SELECT p.*, c.Name as Company_Name,
pl.City, pl.State, pl.Country,
c.Industry, c.Description as Company_Description
FROM Posting p
JOIN Company c ON p.Company_ID = c.ID
JOIN Posting_Location pl ON p.Location = pl.ID
ORDER BY p.Date_Start DESC
'''
cursor = db.get_db().cursor()
cursor.execute(query)
return jsonify(cursor.fetchall()), 200

@alumni.route('/<int:alumni_id>/cv', methods=['POST'])
def upload_cv(alumni_id):
if 'cv' not in request.files:
return jsonify({"error": "No CV file provided"}), 400

file = request.files['cv']
filename = secure_filename(f"cv_alumni_{alumni_id}_{file.filename}")
filepath = f'cv/{filename}'
file.save(filepath)

# You might want to store this in a new column in the Alumni table
# or create a new table for alumni CVs if you want to maintain history
query = '''
UPDATE Alumni
SET CV_Link = %s
WHERE ID = %s
'''
cursor = db.get_db().cursor()
cursor.execute(query, (filepath, alumni_id))
db.get_db().commit()

return jsonify({"message": "CV uploaded successfully"}), 200

@alumni.route('/create_profile', methods=['POST'])
def create_alumni_profile():
data = request.get_json()
cursor = db.get_db().cursor()

# Get College ID from name
college_query = 'SELECT ID FROM College WHERE Name = %s'
cursor.execute(college_query, (data['College'],))
college_result = cursor.fetchone()

if not college_result:
return jsonify({"error": "College not found"}), 404

alumni_query = '''
INSERT INTO Alumni (First_Name, Last_Name, Email, College_ID, Grad_Year)
VALUES (%s, %s, %s, %s, %s)
'''
cursor.execute(alumni_query, (
data['First_Name'],
data['Last_Name'],
data['Email'],
college_result['ID'],
data['Grad_Year']
))
alumni_id = cursor.lastrowid

# Handle majors and minors
if 'Majors' in data:
for major_name in data['Majors']:
cursor.execute('SELECT ID FROM FieldOfStudy WHERE Name = %s', (major_name,))
major_result = cursor.fetchone()
if major_result:
cursor.execute('INSERT INTO Alumni_Majors VALUES (%s, %s)',
(alumni_id, major_result['ID']))

if 'Minors' in data:
for minor_name in data['Minors']:
cursor.execute('SELECT ID FROM FieldOfStudy WHERE Name = %s', (minor_name,))
minor_result = cursor.fetchone()
if minor_result:
cursor.execute('INSERT INTO Alumni_Minors VALUES (%s, %s)',
(alumni_id, minor_result['ID']))

db.get_db().commit()
return jsonify({"message": "Alumni profile created", "id": alumni_id}), 201
6 changes: 6 additions & 0 deletions api/backend/rest_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from backend.customers.customer_routes import customers
from backend.products.products_routes import products
from backend.simple.simple_routes import simple_routes
from backend.student.student_routes import students
from backend.alumni.alumni_routes import alumni
import os
from dotenv import load_dotenv

Expand All @@ -17,6 +19,7 @@ def create_app():
# commands below to see how they're being used.
load_dotenv()


# secret key that will be used for securely signing the session
# cookie and can be used for any other security related needs by
# extensions or your application
Expand All @@ -40,8 +43,11 @@ def create_app():
# and give a url prefix to each
app.logger.info('current_app(): registering blueprints with Flask app object.')
app.register_blueprint(simple_routes)

app.register_blueprint(customers, url_prefix='/c')
app.register_blueprint(products, url_prefix='/p')
app.register_blueprint(students, url_prefix='/s')
app.register_blueprint(alumni, url_prefix='/a')

# Don't forget to return the app object
return app
Expand Down
Loading