Skip to content

Commit

Permalink
Removed Sqlalchemy refrences.
Browse files Browse the repository at this point in the history
  • Loading branch information
DMalone87 committed Sep 23, 2024
1 parent 3c752b9 commit 4a56bfe
Show file tree
Hide file tree
Showing 24 changed files with 634 additions and 543 deletions.
10 changes: 4 additions & 6 deletions alembic/dev_seeds.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from backend.database.core import db
from backend.database import User, UserRole
from backend.auth import user_manager
from backend.database.models.partner import Partner, PartnerMember, MemberRole
from backend.database.models.officer import Officer
from backend.database.models.agency import Agency, Unit
Expand Down Expand Up @@ -90,7 +88,7 @@ def create_seeds():
create_user(
User(
email="[email protected]",
password=user_manager.hash_password("password"),
password_hash=User.hash_password("password"),
role=UserRole.PUBLIC.value,
first_name="Test",
last_name="Example",
Expand All @@ -100,7 +98,7 @@ def create_seeds():
create_user(
User(
email="[email protected]",
password=user_manager.hash_password("password"),
password_hash=User.hash_password("password"),
role=UserRole.CONTRIBUTOR.value,
first_name="Contributor",
last_name="Example",
Expand All @@ -110,7 +108,7 @@ def create_seeds():
create_user(
User(
email="[email protected]",
password=user_manager.hash_password("password"),
password_hash=User.hash_password("password"),
role=UserRole.ADMIN.value,
first_name="Admin",
last_name="Example",
Expand All @@ -120,7 +118,7 @@ def create_seeds():
create_user(
User(
email="[email protected]",
password=user_manager.hash_password("password"),
password_hash=User.hash_password("password"),
role=UserRole.PASSPORT.value,
first_name="Passport",
last_name="Example",
Expand Down
1 change: 0 additions & 1 deletion alembic/seeds.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from flask import current_app as app
from backend.database.core import db

if app.env == "development":
import alembic.dev_seeds
Expand Down
10 changes: 5 additions & 5 deletions backend/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
from flask import Flask
from flask_mail import Mail
from flask_cors import CORS
from flask_jwt_extended import JWTManager
from backend.config import get_config_from_env
from backend.database import db
from backend.database import db_cli
from backend.auth import user_manager, jwt, refresh_token
from backend.auth import jwt, refresh_token
from backend.schemas import spec
from backend.routes.partners import bp as partners_bp
# from backend.routes.incidents import bp as incidents_bp
Expand Down Expand Up @@ -45,8 +45,6 @@ def create_app(config: Optional[str] = None):


def register_extensions(app: Flask):
db.init_app(app)

# Neo4j setup
# Driver setup
db_driver = GraphDatabase.driver(
Expand Down Expand Up @@ -75,7 +73,9 @@ def register_extensions(app: Flask):
neo_config.DATABASE_URL = neo_url

spec.register(app)
user_manager.init_app(app)
# login_manager.init_app(app)
# TODO: Add the correct route info
# login_manager.login_view = 'auth.login'
jwt.init_app(app)
Mail(app)
CORS(app, resources={r"/api/*": {"origins": "*"}})
Expand Down
2 changes: 1 addition & 1 deletion backend/auth/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# flake8: noqa: F401

from .auth import user_manager, refresh_token
from .auth import refresh_token
from .jwt import jwt, min_role_required, blueprint_role_required
2 changes: 1 addition & 1 deletion backend/auth/jwt.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from flask_jwt_extended import JWTManager, verify_jwt_in_request, get_jwt
from functools import wraps
from ..database import User
from ..database.models.user import User
from flask import abort


Expand Down
23 changes: 16 additions & 7 deletions backend/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,24 @@ class Config(object):
SCRAPER_SQS_QUEUE_NAME = os.environ.get("SCRAPER_SQS_QUEUE_NAME")

@property
def SQLALCHEMY_DATABASE_URI(self):
return "postgresql://%s:%s@%s:%s/%s" % (
self.POSTGRES_USER,
self.POSTGRES_PASSWORD,
self.POSTGRES_HOST,
self.PGPORT,
self.POSTGRES_DB,
def NEO4J_BOLT_URI(self):
return "bolt://{user}:{pw}@{url}:{port}".format(
user=self.GRAPH_USER,
pw=self.GRAPH_PASSWORD,
url=self.GRAPH_URI,
port=self.GRAPH_PORT
)

# @property
# def SQLALCHEMY_DATABASE_URI(self):
# return "postgresql://%s:%s@%s:%s/%s" % (
# self.POSTGRES_USER,
# self.POSTGRES_PASSWORD,
# self.POSTGRES_HOST,
# self.PGPORT,
# self.POSTGRES_DB,
# )

@property
def MIXPANEL_TOKEN(self):
return os.environ.get("MIXPANEL_TOKEN", None)
Expand Down
2 changes: 1 addition & 1 deletion backend/database/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# flake8: noqa: F401
from backend.database.core import db, db_cli, execute_query
from backend.database.core import db_cli, execute_query

# Neo4j / NeoModel related imports
from neomodel import config as neo_config
Expand Down
Loading

0 comments on commit 4a56bfe

Please sign in to comment.