
- Created a new Blueprint for main routes in `routes/__init__.py`. - Implemented inventory listing and item management in `routes/inventory.py`. - Added user listing and detail views in `routes/user.py`. - Developed worklog listing and entry views in `routes/worklog.py`. - Introduced search functionality across inventory, users, and worklogs in `routes/search.py`. - Established settings management for brands, items, rooms, and functions in `routes/settings.py`. - Enhanced helper functions for rendering headers and managing data in `routes/helpers.py`. - Updated index route to display active worklogs and inventory conditions in `routes/index.py`.
26 lines
1,014 B
Python
26 lines
1,014 B
Python
from bs4 import BeautifulSoup
|
|
from flask import render_template, url_for, request, redirect
|
|
from flask import current_app as app
|
|
import pandas as pd
|
|
from sqlalchemy import or_
|
|
from sqlalchemy.orm import aliased
|
|
|
|
from . import db
|
|
from .models import Inventory, User, WorkLog
|
|
from .routes import main
|
|
from .routes.helpers import worklog_headers, inventory_headers, user_headers
|
|
from .utils.load import eager_load_user_relationships, eager_load_inventory_relationships, eager_load_worklog_relationships
|
|
|
|
@main.after_request
|
|
def prettify_html_response(response):
|
|
if app.debug and response.content_type.startswith("text/html"):
|
|
try:
|
|
soup = BeautifulSoup(response.get_data(as_text=True), 'html5lib')
|
|
pretty_html = soup.prettify()
|
|
|
|
response.set_data(pretty_html.encode("utf-8")) # type: ignore
|
|
response.headers['Content-Type'] = 'text/html; charset=utf-8'
|
|
|
|
except Exception as e:
|
|
print(f"⚠️ Prettifying failed: {e}")
|
|
return response
|