Skip to content

Commit

Permalink
Front end integration (#752)
Browse files Browse the repository at this point in the history
* Created Professor, club/organziation, and pathway entities(draft)

draft of the professors , club/organization, and pathways entitiy

* Changed SQLalchemy version to 1.4.1

the title

* Adding professors

created functions which should add professors into database
- added foreign key to certain tables

* started professor page

* Remove webex form professor

- Removed webex from table
- planned what other functions to add
for the future

* Professor Name

created function for getting professor first and last name and stores it in json file

* Get professor name by email

- Implemented function for getting professor name by email
- fixed bug where professor table caused YACS to show a blank screen
- updated the requirements

* Removing professor from database

- further testing on /api/professor
- implementation of remove professor function

* Fix finding professor name by eamil

- fixed function on app.py
- added getter function to get profesor by name
- added get prfoesor info by rcsid
- modified Professor table

* FIxed functions for professor

- gave %s values

* Implement more professor functions

Functions:
- get professor by department
- get all professors
- get professor phone number by email

* starting professor explore page

* Added Professor functions

- added get_office_hours_by_email
- added get_professor_rcs_by_email

* Professor functions

implemented all functions except add professor

* worked on professor functions

* Add Professor

- added professor function
- fix remove professor

* got alphabet-sorted professor page working

* created department view

* fixed spacing, buttons, and alphabetization

* created professor pop-up

* added professors header button

* Debugging API calls

- add professors is not working, Internal server error

* Debbuging continued

- compared professor to courses and investigated docker issue

* Debugging continued

- continued debugging for APIs

* possible patch to fix

* change to get method

* Update YacsService.js

* API fix

fixing and testing API calls

* Error with professor test case

- receiving foreign key restraint although there is no foreign key specified

* IT WORKS

debugged API call for testing and retrieving professor

* Finished debugging on localhost

add and remove now work

* move professor api calls to frontend service and created a editProfessors page

* Admin API calls

- all are working except remove and add prof test

* made professor profile page

* debuggign remove professor

remove works on localhost but not on admin

* remove professor

remove professor for admin works

* Bulk upload

- starting bulk upload function

* Improved Admin Page and Maintanence

- made code consistent
- better buttons for admin page
- foreign key for crn

* Bulk upload and clear cache

- created function for bulk upload, remove all and clear cache
- needs testing

* Modified Professor Page and add professor

- fixing add professor
- changed what Professor stores

* Add professor is delayed

It takes a while for add_professor to be seen in getProf

* professor header button icon

* fix add professor

should have fixed add professor

* removed professor phone number

* add bulk professor

- made function to turn a json file into sql tables

* fixed heading alignment

* clean up

cleaning up correct and minor edit

* Fix duplicate Professor

removed duplicate professor table

* added button on admin page

import professor via json

* starting json from frontend to backend

creating front end portion of button

* working on json upload

- fixing json upload to be received into database

* fix issues on the UI of professor bulk insert

* needs testing

json file ready to be tested, need to check with get professors function

* slight modifications to taking in professor json file

turns to string before using function
and fix errors

* cleaned up code

got rid of useless import and improved commenting

* Debug import json file

- changed professor table
- changed functions
- changed requirements

* fixed merge conflict

* Fixing professor json

uploaded json data
json data is being uplaoded a file name, which is wrong

* Professor commenting and debugging

continued working and commenting integration

* cleane up

deleted unecessary lines

* tesitng

see if it fixes code factoring

* code factoring error fixing

fix Possible SQL injection vector through string-based query construction.

* put professor into database

* reveal what to do for testing

added comments

* located error

* debugging database table creation

* fixed skipping database initalization

- new problem ERROR:  relation "professor" already exists
duplicate professor?

* professor database

fixed database names for professor

* fixed attribute name issue

* Improved security

deleted api functions that won't be tested and prevented possible Possible SQL injection vector through string-based query construction

* clean up and improved secuirty

prevented sql inejctions

* updated Department

* fixed warning

* fix warning

* fix warning

* Update professor.py

* removed unnecessary functions

we don't need professors' rcs id

* warning fix

* attempt at fixing warning

* attempt at fixing warning

* fix warning

* fix warning

* Update professor.py

* fixing security error with SQL

* fixing SQL errors

* fixing

* cleaning up function

* trying to get sql injeciton errors

* try again :(

* does this fix it

* few more changes

* get professor buttons work

* clean up

* testing

* revert

* clean up

deleted unecessary lines of code

* clean up

got rid of useless code for cleaner UI

* Create ProfExplorer.vue

* Switched order of prof and final

* fixed backend

deleted useless file

---------

Co-authored-by: ragar3 <qN%ZMi6Q3nq7Qi>
Co-authored-by: Harry Tan <[email protected]>
Co-authored-by: ragar3 <[email protected]>
Co-authored-by: Jun Song <[email protected]>
Co-authored-by: EggyRepublic <[email protected]>
  • Loading branch information
5 people authored Oct 13, 2023
1 parent 7f65d69 commit 8cf1f83
Show file tree
Hide file tree
Showing 20 changed files with 1,528 additions and 294 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ node_modules/
*.ipynb*
courses20.xml
.coverage
compose-dev.yaml
rpi_data/get-summer-2023-2.sh
rpi_data/summer-20232.csv
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ services:
restart: unless-stopped
container_name: yacs_db
image: postgres:12-alpine

1,161 changes: 1,161 additions & 0 deletions rpi_data/pathwayV2.json

Large diffs are not rendered by default.

Empty file modified scripts/dev-create-migration.sh
100644 → 100755
Empty file.
66 changes: 37 additions & 29 deletions src/api/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
admin_info = AdminInfo.Admin(db_conn)
course_select = CourseSelect.student_course_selection(db_conn)
semester_info = SemesterInfo.semester_info(db_conn)
professor_info = All_professors.Professor(db_conn, FastAPICache)
professor_info = All_professors.Professor(db_conn, FastAPICache)
users = UserModel.User()

def is_admin_user(session):
Expand Down Expand Up @@ -153,6 +153,7 @@ async def uploadHandler(
isPubliclyVisible: str = Form(...),
file: UploadFile = File(...)):
# check for user files
print("in process")
if not file:
return Response("No file received", 400)
if file.filename.find('.') == -1 or file.filename.rsplit('.', 1)[1].lower() != 'csv':
Expand All @@ -179,6 +180,40 @@ async def uploadHandler(
print(error)
return Response(error.__str__(), status_code=500)

@app.post('/api/bulkProfessorUpload')
async def uploadJSON(
isPubliclyVisible: str = Form(...),
file: UploadFile = File(...)):
# Check to make sure the user has sent a file
if not file:
return Response("No file received", 400)

# Check that we receive a JSON file
if file.filename.find('.') == -1 or file.filename.rsplit('.', 1)[1].lower() != 'json':
return Response("File must have JSON extension", 400)

# Get file contents
contents = await file.read()

# Load JSON data
try:
#convert string to python dict
json_data = json.loads(contents.decode('utf-8'))
# print(json_data)
except json.JSONDecodeError as e:
return Response(f"Invalid JSON data: {str(e)}", 400)

# Call populate_from_json method
isSuccess, error = professor_info.populate_from_json(json_data)
if isSuccess:
print("SUCCESS")
return Response(status_code=200)
else:
print("NOT WORKING")
print(error)
return Response(error.__str__(), status_code=500)


@app.post('/api/mapDateRangeToSemesterPart')
async def map_date_range_to_semester_part_handler(request: Request):
# This depends on date_start, date_end, and semester_part_name being
Expand Down Expand Up @@ -299,20 +334,12 @@ async def get_all_professors():
db_list = [dict(prof) for prof in professors] if professors else []
return db_list if not error else Response(error, status_code = 500)

@app.get('/api/professor/office_hours/{email}')
async def get_office_hours(email: str):
professor_office_hours, error = professor_info.get_office_hours_by_email(email)
return professor_office_hours if not error else Response(content=error, status_code=500)

@app.get('/api/professor/phone_number/{email}')
async def get_professor_phone_number_by_email(email: str):

phone_number, error = professor_info.get_professor_phone_number_by_email(email)
return phone_number if not error else Response(content=error, status_code=500)

@app.get('/api/professor/rcs/{rcs}')
async def get_professor_info_by_rcs(rcs:str):
professor_rcs, error = professor_info.get_professor_info_by_rcs(rcs)
return professor_rcs if not error else Response(content=error,status_code=500)

@app.get('/api/professor/email/{email}')
async def get_professor_info_by_email(email:str):
Expand Down Expand Up @@ -355,22 +382,3 @@ async def remove_professor(email:str):
print(email)
professor, error = professor_info.remove_professor(email)
return professor if not error else Response(str(error), status_code=500)

#Parses the data from the .csv data files
@app.post('/api/bulkProfUpload')
async def uploadHandler(file: UploadFile = File(...)):
# check for user files
if not file:
return Response("No file received", 400)
if file.filename.find('.') == -1 or file.filename.rsplit('.', 1)[1].lower() != 'csv':
return Response("File must have csv extension", 400)
# get file
contents = await file.read()
csv_file = StringIO(contents.decode())
isSuccess, error = courses.populate_from_csv(csv_file)
# Populate DB from CSV
if (isSuccess):
return Response(status_code=200)
else:
print(error)
return Response(error.__str__(), status_code=500)
1 change: 1 addition & 0 deletions src/api/db/courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def bulk_delete(self, semesters):
for semester in semesters:
_, error = self.delete_by_semester(semester)
if error:
print("ERROR")
print(error)
return error
# on success, invalidate cache
Expand Down
Loading

0 comments on commit 8cf1f83

Please sign in to comment.