diff --git a/app/__init__.py b/app/__init__.py index 417a3ed..5a16c5b 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -6,12 +6,6 @@ from flask_mail import Mail from config import config import os -import app -from app.routes import auth, dashboard, inspections, templates, reports, facilities - -# Add to blueprint registration -app.register_blueprint(facilities.bp) - # Initialize extensions db = SQLAlchemy() login_manager = LoginManager() @@ -20,35 +14,36 @@ mail = Mail() def create_app(config_name='default'): app = Flask(__name__) - + # Load configuration app.config.from_object(config[config_name]) - + # Initialize extensions with app db.init_app(app) login_manager.init_app(app) migrate.init_app(app, db) mail.init_app(app) - + # Configure login manager login_manager.login_view = 'auth.login' login_manager.login_message = 'Please log in to access this page.' login_manager.login_message_category = 'info' - + # Create upload directory if it doesn't exist os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True) - - # Register blueprints - from app.routes import auth, dashboard, inspections, templates, reports - + + # Register blueprints (import here to avoid circular imports) + from app.routes import auth, dashboard, inspections, templates, reports, facilities + app.register_blueprint(auth.bp) app.register_blueprint(dashboard.bp) app.register_blueprint(inspections.bp) app.register_blueprint(templates.bp) app.register_blueprint(reports.bp) - + app.register_blueprint(facilities.bp) + # Create database tables with app.app_context(): db.create_all() - - return app + + return app \ No newline at end of file diff --git a/app/routes/dashboard.py b/app/routes/dashboard.py index 81d76e2..a365f23 100644 --- a/app/routes/dashboard.py +++ b/app/routes/dashboard.py @@ -1,5 +1,6 @@ from flask import Blueprint, render_template from flask_login import login_required, current_user +from app import db # ADD THIS LINE from app.models.inspection import Inspection, InspectionTemplate from app.models.facility import Facility from app.models.issue import Issue diff --git a/app/templates/auth/login.html b/app/templates/auth/login.html new file mode 100644 index 0000000..31b86e8 --- /dev/null +++ b/app/templates/auth/login.html @@ -0,0 +1,48 @@ +{% extends "base.html" %} + +{% block title %}Login - Janitorial QC{% endblock %} + +{% block content %} +
+
+
+
+

Janitorial QC

+

Quality Control System

+
+
+
+ {{ form.hidden_tag() }} + +
+ {{ form.username.label(class="form-label") }} + {{ form.username(class="form-control form-control-lg", placeholder="Enter username") }} + {% if form.username.errors %} +
+ {% for error in form.username.errors %}{{ error }}{% endfor %} +
+ {% endif %} +
+ +
+ {{ form.password.label(class="form-label") }} + {{ form.password(class="form-control form-control-lg", placeholder="Enter password") }} + {% if form.password.errors %} +
+ {% for error in form.password.errors %}{{ error }}{% endfor %} +
+ {% endif %} +
+ + +
+
+ +
+
+
+{% endblock %} \ No newline at end of file