From 2dc4671d7ed47e5de8ddd5e57fe3552caf364f4a Mon Sep 17 00:00:00 2001 From: chriswebb09 Date: Sun, 24 Dec 2023 00:09:55 -0500 Subject: [PATCH] update code --- DirectReport/browserview/__init__.py | 14 ++++---------- DirectReport/browserview/auth/__init__.py | 3 +-- DirectReport/browserview/auth/routes.py | 9 +++++---- DirectReport/browserview/errors/__init__.py | 4 ++-- DirectReport/browserview/errors/handlers.py | 6 ++---- DirectReport/browserview/main/__init__.py | 4 ++-- DirectReport/browserview/main/routes.py | 6 +++--- pyproject.toml | 5 ++++- 8 files changed, 23 insertions(+), 28 deletions(-) diff --git a/DirectReport/browserview/__init__.py b/DirectReport/browserview/__init__.py index 5fc00c85..83fb0c3f 100644 --- a/DirectReport/browserview/__init__.py +++ b/DirectReport/browserview/__init__.py @@ -1,23 +1,18 @@ import sys from pathlib import Path - +from flask import Flask, request from flask import redirect, url_for -from flask import Flask, request, current_app -from flask_login import LoginManager, current_user, login_required -from DirectReport.config import Config - - +from flask_login import LoginManager, current_user from DirectReport.browserview.services.github import GithubClient from DirectReport.browserview.services.prompt_logic import generate_email +from DirectReport.config import Config from DirectReport.datadependencies import appsecrets from DirectReport.models.user_model import UserModel - file = Path(__file__).resolve() package_root_directory = file.parents[1] sys.path.append(str(package_root_directory)) -# -# login_manager = LoginManager() + client_id = appsecrets.GITHUB_CLIENT_ID client_secret = appsecrets.GITHUB_CLIENT_SECRET @@ -50,7 +45,6 @@ def unauthorized_handler(): def create_app(config_class=Config): - user_model = UserModel() app = Flask(__name__, template_folder="templates") from DirectReport.browserview.auth import bp as auth_bp diff --git a/DirectReport/browserview/auth/__init__.py b/DirectReport/browserview/auth/__init__.py index d743a804..5207fc5b 100644 --- a/DirectReport/browserview/auth/__init__.py +++ b/DirectReport/browserview/auth/__init__.py @@ -1,5 +1,4 @@ from flask import Blueprint +from DirectReport.browserview.auth import routes bp = Blueprint('auth', __name__) - -from DirectReport.browserview.auth import routes diff --git a/DirectReport/browserview/auth/routes.py b/DirectReport/browserview/auth/routes.py index 1246dff8..75c1abdd 100644 --- a/DirectReport/browserview/auth/routes.py +++ b/DirectReport/browserview/auth/routes.py @@ -1,11 +1,12 @@ from flask import render_template, request, redirect, url_for, flash -from werkzeug.security import generate_password_hash -from DirectReport.models.user_model import UserModel from flask_login import login_user, login_required, logout_user, current_user +from werkzeug.security import generate_password_hash + +from DirectReport.browserview.auth import bp +from DirectReport.browserview.services.github import GithubClient from DirectReport.datadependencies import appsecrets from DirectReport.models.report.report_builder import ReportBuilder -from DirectReport.browserview.services.github import GithubClient -from DirectReport.browserview.auth import bp +from DirectReport.models.user_model import UserModel user_model = UserModel() diff --git a/DirectReport/browserview/errors/__init__.py b/DirectReport/browserview/errors/__init__.py index 5701c1d1..485ca853 100644 --- a/DirectReport/browserview/errors/__init__.py +++ b/DirectReport/browserview/errors/__init__.py @@ -1,5 +1,5 @@ from flask import Blueprint +from DirectReport.browserview.errors import handlers -bp = Blueprint('errors', __name__) -from app.errors import handlers +bp = Blueprint('errors', __name__) diff --git a/DirectReport/browserview/errors/handlers.py b/DirectReport/browserview/errors/handlers.py index 0e841721..b5619610 100644 --- a/DirectReport/browserview/errors/handlers.py +++ b/DirectReport/browserview/errors/handlers.py @@ -1,7 +1,6 @@ from flask import render_template, request -from app import db -from app.errors import bp -from app.api.errors import error_response as api_error_response +from DirectReport.browserview.errors import bp +from DirectReport.browserview.api.errors import error_response as api_error_response def wants_json_response(): @@ -23,7 +22,6 @@ def page_not_found(e): @bp.app_errorhandler(500) def internal_error(error): - db.session.rollback() if wants_json_response(): return api_error_response(500) return render_template('errors/500.html'), 500 diff --git a/DirectReport/browserview/main/__init__.py b/DirectReport/browserview/main/__init__.py index 515ede67..c537d020 100644 --- a/DirectReport/browserview/main/__init__.py +++ b/DirectReport/browserview/main/__init__.py @@ -1,5 +1,5 @@ from flask import Blueprint +from DirectReport.browserview.main import routes -bp = Blueprint('main', __name__) -from DirectReport.browserview.main import routes +bp = Blueprint('main', __name__) diff --git a/DirectReport/browserview/main/routes.py b/DirectReport/browserview/main/routes.py index 2d466f90..59394b7e 100644 --- a/DirectReport/browserview/main/routes.py +++ b/DirectReport/browserview/main/routes.py @@ -1,13 +1,13 @@ -import requests +from datetime import datetime, timedelta +import requests from flask import render_template, session, request, redirect, json -from datetime import datetime, timedelta from flask_login import current_user +from DirectReport.browserview.main import bp from DirectReport.browserview.services.github import GithubClient from DirectReport.browserview.services.prompt_logic import generate_email from DirectReport.datadependencies import appsecrets -from DirectReport.browserview.main import bp client_id = appsecrets.GITHUB_CLIENT_ID client_secret = appsecrets.GITHUB_CLIENT_SECRET diff --git a/pyproject.toml b/pyproject.toml index 7d0e05da..2e57741c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -77,7 +77,10 @@ exclude=[ 'tests/*' ] per-file-ignores= [ - 'DirectReport/__init__.py:F401, F403' + 'DirectReport/__init__.py:F401, F403, E402', + 'DirectReport/browserview/api/__init__.py:F401, F403, E402', + 'DirectReport/browserview/main/routes.py:F401, F403, E402, W503', + 'DirectReport/datadependencies/prompts.py:F401, F403, E402, W503' ]