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
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Import os
from os import getenv, path
from datetime import timedelta
from os import getenv, path

from dotenv import load_dotenv

Expand Down
11 changes: 6 additions & 5 deletions db_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
Then pass an Executable into Session.execute()
"""

import sys
import requests
import re

import sys
from datetime import date, datetime

import requests

from labconnect import create_app, db
from labconnect.helpers import LocationEnum, SemesterEnum
from labconnect.models import LabManager # Professors and Grad students
from labconnect.models import (
ClassYears,
Courses,
LabManager, # Professors and Grad students
Leads,
Majors,
Opportunities,
Expand Down Expand Up @@ -395,7 +395,8 @@ def main() -> None:
),
(
"Data Science Research",
"Work with a team of researchers to analyze large datasets and extract meaningful insights.",
"Work with a team of researchers to analyze large datasets and "
"extract meaningful insights.",
"Python, Machine Learning, Data Analysis",
20.0,
True,
Expand Down
6 changes: 1 addition & 5 deletions labconnect/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
import json
import os
from datetime import datetime, timedelta, timezone

import sentry_sdk

# Import logging
from logging.config import dictConfig

# Import Flask modules
import sentry_sdk
from flask import Flask
from flask_cors import CORS
from flask_jwt_extended import (
Expand Down
10 changes: 5 additions & 5 deletions labconnect/main/auth_routes.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
from datetime import datetime, timedelta
from uuid import uuid4

from flask import current_app, make_response, redirect, request, abort
from flask import abort, current_app, make_response, redirect, request
from flask_jwt_extended import (
get_jwt_identity,
create_access_token,
create_refresh_token,
get_jwt_identity,
jwt_required,
set_access_cookies,
set_refresh_cookies,
unset_jwt_cookies,
jwt_required,
)
from onelogin.saml2.auth import OneLogin_Saml2_Auth
from werkzeug.wrappers.response import Response

from labconnect import db
from labconnect.helpers import prepare_flask_request
from labconnect.models import (
Codes,
ManagementPermissions,
User,
UserCourses,
UserDepartments,
UserMajors,
ManagementPermissions,
Codes,
)

from . import main_blueprint
Expand Down
69 changes: 0 additions & 69 deletions labconnect/main/discover_routes.py

This file was deleted.

25 changes: 15 additions & 10 deletions labconnect/main/opportunity_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

from flask import abort, request
from flask_jwt_extended import get_jwt_identity, jwt_required
from sqlalchemy import func, case
from sqlalchemy import case, func

from labconnect import db
from labconnect.helpers import (
LocationEnum,
SemesterEnum,
format_credits,
convert_to_enum,
format_credits,
)
from labconnect.models import (
Courses,
LabManager,
Leads,
Opportunities,
RecommendsClassYears,
User,
Courses,
Participates,
RecommendsClassYears,
RecommendsMajors,
User,
UserSavedOpportunities,
)
from labconnect.serializers import serialize_opportunity
Expand Down Expand Up @@ -149,7 +149,8 @@ def getOpportunity(opp_id: int):
query = db.session.execute(
db.select(
Opportunities,
# Creates an array for all of the recommended class years for the opportunity labeled recommended_years
# Creates an array for all of the recommended class years for the
# opportunity labeled recommended_years
func.array_agg(RecommendsClassYears.class_year).label("recommended_years"),
)
.join(
Expand Down Expand Up @@ -317,7 +318,8 @@ def filterOpportunities():
opportunity[0],
lab_managers=", ".join(
[
f"{name.get('preferred_name', None) or name.get('first_name')} {name.get('last_name')}"
f"{name.get('preferred_name', None) or name.get('first_name')} "
f"{name.get('last_name')}"
for name in opportunity[1]
]
),
Expand Down Expand Up @@ -404,7 +406,8 @@ def getProfileOpportunities(rcs_id: str) -> list[dict[str, str]]:
# function to search for lab managers
@main_blueprint.get("/searchLabManagers/<string:query>")
def searchLabManagers(query: str):
# Perform a search on User table by first name, last name, or email using ILIKE for exact partial matches
# Perform a search on User table by first name, last name, or email using ILIKE
# for exact partial matches
stmt = (
db.select(User)
.join(LabManager, User.lab_manager_id == LabManager.id)
Expand Down Expand Up @@ -444,7 +447,9 @@ def searchLabManagers(query: str):

@main_blueprint.get("/searchCourses/<string:query>")
def searchCourses(query: str):
# Perform a search on Courses table by code and name using ILIKE for exact partial matches
# Perform a search on Courses table by code and
# name using ILIKE for exact partial matches
# TODO: merge into filtering
stmt = (
db.select(Courses)
.distinct()
Expand Down Expand Up @@ -880,7 +885,7 @@ def allSavedUserOportunities():
return saved_opportunities_list, 200


# Create route to allow for multiple pages to be unsaved given a list of opp_ids delete them
# Create route to allow for multiple pages to be unsaved given a list of opp_ids
@main_blueprint.delete("/UnsaveMultiplePages/")
@jwt_required()
# Delete id that appear on delete_ids list
Expand Down
8 changes: 4 additions & 4 deletions labconnect/main/routes.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
from typing import NoReturn

from flask import abort, request
from flask_jwt_extended import get_jwt_identity, jwt_required

from labconnect import db
from labconnect.models import (
ClassYears,
Courses,
LabManager,
Majors,
Opportunities,
RPIDepartments,
User,
ClassYears,
UserDepartments,
Majors,
Courses,
)
from labconnect.serializers import serialize_course

Expand Down Expand Up @@ -186,7 +187,6 @@ def changeActiveStatus() -> dict[str, bool]:
if opportunity.active != setStatus:
abort(500)

# if match is found, change the opportunities active status to true or false based on setStatus
return {"activeStatus": opportunity}


Expand Down
2 changes: 1 addition & 1 deletion labconnect/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

from labconnect import db
from labconnect.helpers import (
LabManagerTypeEnum,
LocationEnum,
SemesterEnum,
LabManagerTypeEnum,
)

# DD - Entities
Expand Down
2 changes: 1 addition & 1 deletion labconnect/serializers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from labconnect.models import Courses, Opportunities
from labconnect.helpers import format_credits
from labconnect.models import Courses, Opportunities


def serialize_course(course: Courses) -> str:
Expand Down
3 changes: 1 addition & 2 deletions migrations/env.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import logging
from logging.config import fileConfig

from flask import current_app

from alembic import context
from flask import current_app

# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
Expand Down
17 changes: 13 additions & 4 deletions migrations/versions/0e1d1657b500_.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@

"""

from alembic import op
import sqlalchemy as sa

from alembic import op

# revision identifiers, used by Alembic.
revision = "0e1d1657b500"
Expand All @@ -23,8 +22,18 @@ def upgrade():
op.execute("""
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'labmanagertypeenum') THEN
CREATE TYPE labmanagertypeenum AS ENUM ('PI', 'CO_PI', 'LAB_MANAGER', 'POST_DOC', 'GRAD_STUDENT');
IF NOT EXISTS (
SELECT 1
FROM pg_type
WHERE typname = 'labmanagertypeenum'
) THEN
CREATE TYPE labmanagertypeenum AS ENUM (
'PI',
'CO_PI',
'LAB_MANAGER',
'POST_DOC',
'GRAD_STUDENT'
);
END IF;
END$$;
""")
Expand Down
11 changes: 11 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[tool.ruff]
line-length = 88
fix = true

[tool.ruff.lint]
select = ["I", "F", "E"]

[tool.ruff.format]
quote-style = "double"
indent-style = "space"
line-ending = "lf"
5 changes: 4 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ def test_client():
# @pytest.fixture(scope="function")
# def log_in_default_user(test_client):
# test_client.post(
# "/login", data={"email": "[email protected]", "password": "FlaskIsAwesome"}
# "/login", data={
# "email": "[email protected]",
# "password": "FlaskIsAwesome"
# }
# )

# yield # this is where the testing happens!
Expand Down
2 changes: 1 addition & 1 deletion tests/test_courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Test courses routes
"""

import pytest
from flask import json
from flask.testing import FlaskClient
import pytest


@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_departments.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Test department routes
"""

import pytest
from flask import json
from flask.testing import FlaskClient
import pytest


@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Test errors
"""

import pytest
from flask import json
from flask.testing import FlaskClient
import pytest


@pytest.mark.parametrize(
Expand Down
2 changes: 1 addition & 1 deletion tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Test general routes
"""

import pytest
from flask import json
from flask.testing import FlaskClient
import pytest


def test_home_page(test_client: FlaskClient) -> None:
Expand Down
Loading
Loading