Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 3 additions & 3 deletions .github/workflows/black.yml → .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: Black Formatter
name: Ruff Lint Check

on:
pull_request:
paths:
- "**.py"

jobs:
lint:
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: psf/black@stable
- uses: astral-sh/ruff-action@v3
2 changes: 1 addition & 1 deletion labconnect/errors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

error_blueprint = Blueprint("errors", __name__, template_folder="templates")

from . import routes
from . import routes # noqa
2 changes: 1 addition & 1 deletion labconnect/errors/routes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flask import Response, make_response, render_template
from flask import Response, make_response

from . import error_blueprint

Expand Down
1 change: 0 additions & 1 deletion labconnect/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import json
from enum import Enum as EnumPython

import orjson
Expand Down
2 changes: 1 addition & 1 deletion labconnect/main/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

main_blueprint = Blueprint("main", __name__)

from . import auth_routes, discover_routes, opportunity_routes, routes
from . import auth_routes, discover_routes, opportunity_routes, routes # noqa
6 changes: 2 additions & 4 deletions labconnect/main/discover_routes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from flask_jwt_extended import get_jwt_identity, jwt_required

from labconnect import db
from labconnect.models import (
ClassYears,
Expand Down Expand Up @@ -35,7 +33,7 @@ def discover_data(jwt_identity, limit):
Opportunities.location,
LabManager.id.label("lab_manager_id"),
)
.where(Opportunities.active == True)
.where(Opportunities.active)
.join(
RecommendsClassYears,
Opportunities.id == RecommendsClassYears.class_year,
Expand All @@ -61,7 +59,7 @@ def discover_data(jwt_identity, limit):
if jwt_identity is None or data is None:
data = db.session.execute(
db.select(Opportunities)
.where(Opportunities.active == True)
.where(Opportunities.active)
.limit(limit)
.order_by(Opportunities.last_updated.desc())
).scalars()
Expand Down
36 changes: 16 additions & 20 deletions labconnect/main/opportunity_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ def packageIndividualOpportunity(opportunityInfo):


def packageOpportunityCard(opportunity):

# get professor and department by getting Leads and LabManager
query = db.session.execute(
db.select(Leads, LabManager, User.first_name, User.last_name)
Expand Down Expand Up @@ -232,7 +231,7 @@ def getOpportunities():
# Handle GET requests for fetching default active opportunities
data = db.session.execute(
db.select(Opportunities)
.where(Opportunities.active == True)
.where(Opportunities.active)
.limit(20)
.order_by(Opportunities.last_updated.desc())
.distinct()
Expand Down Expand Up @@ -263,7 +262,7 @@ def filterOpportunities():
where_conditions = []
query = (
db.select(Opportunities)
.where(Opportunities.active == True)
.where(Opportunities.active)
.limit(20)
.order_by(Opportunities.last_updated)
.distinct()
Expand Down Expand Up @@ -462,9 +461,7 @@ def filterOpportunities():
@main_blueprint.get("/getOpportunityCards")
def getOpportunityCards():
# query database for opportunity
query = db.session.execute(
db.select(Opportunities).where(Opportunities.active == True)
)
query = db.session.execute(db.select(Opportunities).where(Opportunities.active))

data = query.fetchall()
# return data in the below format if opportunity is found
Expand Down Expand Up @@ -497,7 +494,6 @@ def getOpportunityCards():

@main_blueprint.get("/staff/opportunities/<string:rcs_id>")
def getLabManagerOpportunityCards(rcs_id: str) -> list[dict[str, str]]:

query = (
db.select(
Opportunities.id,
Expand Down Expand Up @@ -534,7 +530,6 @@ def getLabManagerOpportunityCards(rcs_id: str) -> list[dict[str, str]]:

@main_blueprint.get("/profile/opportunities/<string:rcs_id>")
def getProfileOpportunities(rcs_id: str) -> list[dict[str, str]]:

query = (
db.select(
Opportunities.id,
Expand Down Expand Up @@ -661,7 +656,7 @@ def createOpportunity():

try:
pay = int(request_data["hourlyPay"])
except:
except ValueError:
pay = None

one = True if "1" in request_data["credits"] else False
Expand Down Expand Up @@ -769,7 +764,9 @@ def editOpportunity_get(opportunity_id):
"type": (
"Any"
if len(credits) > 0 and opportunity.pay and opportunity.pay > 0
else "For Pay" if opportunity.pay and opportunity.pay > 0 else "For Credit"
else "For Pay"
if opportunity.pay and opportunity.pay > 0
else "For Credit"
),
"hourlyPay": str(opportunity.pay),
"credits": credits,
Expand All @@ -791,7 +788,6 @@ def editOpportunity_get(opportunity_id):
@main_blueprint.put("/editOpportunity/<int:opportunity_id>")
@jwt_required()
def editOpportunity(opportunity_id):

user_id = get_jwt_identity()
if not request.data or not user_id:
abort(400)
Expand Down Expand Up @@ -827,7 +823,7 @@ def editOpportunity(opportunity_id):

try:
pay = int(request_data["hourlyPay"])
except:
except ValueError:
pay = None

one = True if "1" in request_data["credits"] else False
Expand Down Expand Up @@ -889,14 +885,14 @@ def editOpportunity(opportunity_id):
db.session.commit()

# Add the updated list of managers
if "lab_manager_ids" in data:
for lab_manager_id in data["lab_manager_ids"]:
new_lead = Leads(
lab_manager_id=lab_manager_id, opportunity_id=opportunity_id
)
db.session.add(new_lead)

db.session.commit() # Commit all changes
# if "lab_manager_ids" in data:
# for lab_manager_id in data["lab_manager_ids"]:
# new_lead = Leads(
# lab_manager_id=lab_manager_id, opportunity_id=opportunity_id
# )
# db.session.add(new_lead)

# db.session.commit() # Commit all changes

return {"data": "Opportunity Updated"}, 200

Expand Down
9 changes: 1 addition & 8 deletions labconnect/main/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def departmentCards():

@main_blueprint.get("/departments/<string:department>")
def departmentDetails(department: str):

department_data = db.session.execute(
db.select(
RPIDepartments.id,
Expand Down Expand Up @@ -92,7 +91,6 @@ def departmentDetails(department: str):
@main_blueprint.get("/profile")
@jwt_required()
def profile():

user_id = get_jwt_identity()

data = db.session.execute(
Expand Down Expand Up @@ -133,7 +131,6 @@ def profile():
@main_blueprint.get("/staff/<string:id>")
@jwt_required()
def getProfessorProfile(id: str):

data = db.session.execute(
db.select(
User.preferred_name,
Expand Down Expand Up @@ -208,7 +205,6 @@ def force_error():

@main_blueprint.get("/majors")
def majors() -> list[dict[str, str]]:

data = db.session.execute(db.select(Majors).order_by(Majors.code)).scalars()

if not data:
Expand All @@ -224,11 +220,8 @@ def majors() -> list[dict[str, str]]:

@main_blueprint.get("/years")
def years() -> list[int]:

data = db.session.execute(
db.select(ClassYears)
.order_by(ClassYears.class_year)
.where(ClassYears.active == True)
db.select(ClassYears).order_by(ClassYears.class_year).where(ClassYears.active)
).scalars()

if not data:
Expand Down
1 change: 0 additions & 1 deletion labconnect/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from atexit import register
from sqlalchemy import Enum, Index, event, func
from sqlalchemy.dialects.postgresql import TSVECTOR

Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pytest==8.3.4
pytest-cov==6.0.0
python3-saml==1.16.0
pytz==2024.2
ruff==0.9.5
sentry-sdk==2.19.2
setuptools==70.3.0
six==1.17.0
Expand Down
1 change: 0 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import pytest

from labconnect import create_app
from labconnect.models import *

# --------
# Fixtures
Expand Down
Loading