Phase 2: enhancements

This commit is contained in:
2026-02-06 17:04:21 -05:00
parent 66b3bb7642
commit 96da98ebd0
3 changed files with 61 additions and 17 deletions
+12 -17
View File
@@ -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
+1
View File
@@ -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
+48
View File
@@ -0,0 +1,48 @@
{% extends "base.html" %}
{% block title %}Login - Janitorial QC{% endblock %}
{% block content %}
<div class="row justify-content-center mt-5">
<div class="col-md-5 col-lg-4">
<div class="card shadow-lg">
<div class="card-header bg-primary text-white text-center py-4">
<h3><i class="bi bi-clipboard-check-fill"></i> Janitorial QC</h3>
<p class="mb-0">Quality Control System</p>
</div>
<div class="card-body p-4">
<form method="POST" action="{{ url_for('auth.login') }}">
{{ form.hidden_tag() }}
<div class="mb-3">
{{ form.username.label(class="form-label") }}
{{ form.username(class="form-control form-control-lg", placeholder="Enter username") }}
{% if form.username.errors %}
<div class="text-danger small mt-1">
{% for error in form.username.errors %}{{ error }}{% endfor %}
</div>
{% endif %}
</div>
<div class="mb-4">
{{ form.password.label(class="form-label") }}
{{ form.password(class="form-control form-control-lg", placeholder="Enter password") }}
{% if form.password.errors %}
<div class="text-danger small mt-1">
{% for error in form.password.errors %}{{ error }}{% endfor %}
</div>
{% endif %}
</div>
<button type="submit" class="btn btn-primary btn-lg w-100">
<i class="bi bi-box-arrow-in-right"></i> Login
</button>
</form>
</div>
<div class="card-footer text-center text-muted small">
&copy; 2025 Janitorial QC System
</div>
</div>
</div>
</div>
{% endblock %}