@@ -171,7 +171,6 @@ def packageIndividualOpportunity(opportunityInfo):
171171
172172
173173def packageOpportunityCard (opportunity ):
174-
175174 # get professor and department by getting Leads and LabManager
176175 query = db .session .execute (
177176 db .select (Leads , LabManager , User .first_name , User .last_name )
@@ -232,7 +231,7 @@ def getOpportunities():
232231 # Handle GET requests for fetching default active opportunities
233232 data = db .session .execute (
234233 db .select (Opportunities )
235- .where (Opportunities .active == True )
234+ .where (Opportunities .active )
236235 .limit (20 )
237236 .order_by (Opportunities .last_updated .desc ())
238237 .distinct ()
@@ -263,7 +262,7 @@ def filterOpportunities():
263262 where_conditions = []
264263 query = (
265264 db .select (Opportunities )
266- .where (Opportunities .active == True )
265+ .where (Opportunities .active )
267266 .limit (20 )
268267 .order_by (Opportunities .last_updated )
269268 .distinct ()
@@ -462,9 +461,7 @@ def filterOpportunities():
462461@main_blueprint .get ("/getOpportunityCards" )
463462def getOpportunityCards ():
464463 # query database for opportunity
465- query = db .session .execute (
466- db .select (Opportunities ).where (Opportunities .active == True )
467- )
464+ query = db .session .execute (db .select (Opportunities ).where (Opportunities .active ))
468465
469466 data = query .fetchall ()
470467 # return data in the below format if opportunity is found
@@ -497,7 +494,6 @@ def getOpportunityCards():
497494
498495@main_blueprint .get ("/staff/opportunities/<string:rcs_id>" )
499496def getLabManagerOpportunityCards (rcs_id : str ) -> list [dict [str , str ]]:
500-
501497 query = (
502498 db .select (
503499 Opportunities .id ,
@@ -534,7 +530,6 @@ def getLabManagerOpportunityCards(rcs_id: str) -> list[dict[str, str]]:
534530
535531@main_blueprint .get ("/profile/opportunities/<string:rcs_id>" )
536532def getProfileOpportunities (rcs_id : str ) -> list [dict [str , str ]]:
537-
538533 query = (
539534 db .select (
540535 Opportunities .id ,
@@ -661,7 +656,7 @@ def createOpportunity():
661656
662657 try :
663658 pay = int (request_data ["hourlyPay" ])
664- except :
659+ except ValueError :
665660 pay = None
666661
667662 one = True if "1" in request_data ["credits" ] else False
@@ -769,7 +764,9 @@ def editOpportunity_get(opportunity_id):
769764 "type" : (
770765 "Any"
771766 if len (credits ) > 0 and opportunity .pay and opportunity .pay > 0
772- else "For Pay" if opportunity .pay and opportunity .pay > 0 else "For Credit"
767+ else "For Pay"
768+ if opportunity .pay and opportunity .pay > 0
769+ else "For Credit"
773770 ),
774771 "hourlyPay" : str (opportunity .pay ),
775772 "credits" : credits ,
@@ -791,7 +788,6 @@ def editOpportunity_get(opportunity_id):
791788@main_blueprint .put ("/editOpportunity/<int:opportunity_id>" )
792789@jwt_required ()
793790def editOpportunity (opportunity_id ):
794-
795791 user_id = get_jwt_identity ()
796792 if not request .data or not user_id :
797793 abort (400 )
@@ -827,7 +823,7 @@ def editOpportunity(opportunity_id):
827823
828824 try :
829825 pay = int (request_data ["hourlyPay" ])
830- except :
826+ except ValueError :
831827 pay = None
832828
833829 one = True if "1" in request_data ["credits" ] else False
@@ -889,14 +885,14 @@ def editOpportunity(opportunity_id):
889885 db .session .commit ()
890886
891887 # Add the updated list of managers
892- if "lab_manager_ids" in data :
893- for lab_manager_id in data ["lab_manager_ids" ]:
894- new_lead = Leads (
895- lab_manager_id = lab_manager_id , opportunity_id = opportunity_id
896- )
897- db .session .add (new_lead )
898-
899- db .session .commit () # Commit all changes
888+ # if "lab_manager_ids" in data:
889+ # for lab_manager_id in data["lab_manager_ids"]:
890+ # new_lead = Leads(
891+ # lab_manager_id=lab_manager_id, opportunity_id=opportunity_id
892+ # )
893+ # db.session.add(new_lead)
894+
895+ # db.session.commit() # Commit all changes
900896
901897 return {"data" : "Opportunity Updated" }, 200
902898
0 commit comments