✨ New Features: - Added view_orders route with proper table display - Implemented CSV upload with preview workflow and date parsing - Added production WSGI server configuration with Gunicorn - Created comprehensive production management scripts 🔧 Bug Fixes: - Fixed upload_data route column mapping for actual CSV structure - Resolved print module database queries and template rendering - Fixed view orders navigation routing (was pointing to JSON API) - Corrected barcode display width constraints in print module - Added proper date format parsing for MySQL compatibility 🎨 UI/UX Improvements: - Updated view_orders template with theme-compliant styling - Hidden barcode text in print module preview for cleaner display - Enhanced CSV upload with two-step preview-then-save workflow - Improved error handling and debugging throughout upload process 🚀 Production Infrastructure: - Added Gunicorn WSGI server with proper configuration - Created systemd service for production deployment - Implemented production management scripts (start/stop/status) - Added comprehensive logging setup - Updated requirements.txt with production dependencies 📊 Database & Data: - Enhanced order_for_labels table compatibility - Fixed column mappings for real CSV data structure - Added proper date parsing and validation - Improved error handling with detailed debugging 🔧 Technical Debt: - Reorganized database setup documentation - Added proper error handling throughout upload workflow - Enhanced debugging capabilities for troubleshooting - Improved code organization and documentation
4.1 KiB
4.1 KiB
Quick Database Setup for Trasabilitate Application
This script provides a complete one-step database setup for quick deployment of the Trasabilitate application.
Prerequisites
Before running the setup script, ensure:
- MariaDB is installed and running
- Database and user are created:
CREATE DATABASE trasabilitate; CREATE USER 'trasabilitate'@'localhost' IDENTIFIED BY 'Initial01!'; GRANT ALL PRIVILEGES ON trasabilitate.* TO 'trasabilitate'@'localhost'; FLUSH PRIVILEGES; - Python virtual environment is activated:
source ../recticel/bin/activate - Python dependencies are installed:
pip install -r requirements.txt
Usage
Quick Setup (Recommended)
cd /srv/quality_recticel/py_app
source ../recticel/bin/activate
python3 app/db_create_scripts/setup_complete_database.py
What the script creates:
MariaDB Tables:
scan1_orders- Quality scanning data for process 1scanfg_orders- Quality scanning data for finished goodsorder_for_labels- Label printing orderswarehouse_locations- Warehouse location managementpermissions- System permissionsrole_permissions- Role-permission mappingsrole_hierarchy- User role hierarchypermission_audit_log- Permission change audit trail
Database Triggers:
- Auto-increment approved/rejected quantities based on quality codes
- Triggers for both scan1_orders and scanfg_orders tables
SQLite Tables:
users- User authentication (in instance/users.db)roles- User roles (in instance/users.db)
Configuration:
- Updates
instance/external_server.confwith correct database settings - Creates default superadmin user (username:
superadmin, password:superadmin123)
Permission System:
- 7 user roles (superadmin, admin, manager, quality_manager, warehouse_manager, quality_worker, warehouse_worker)
- 25+ granular permissions for different application areas
- Complete role hierarchy with inheritance
After Setup
-
Start the application:
python3 run.py -
Access the application:
- Local: http://127.0.0.1:8781
- Network: http://192.168.0.205:8781
-
Login with superadmin:
- Username:
superadmin - Password:
superadmin123
- Username:
Troubleshooting
Common Issues:
-
Database connection failed:
- Check if MariaDB is running:
sudo systemctl status mariadb - Verify database exists:
sudo mysql -e "SHOW DATABASES;" - Check user privileges:
sudo mysql -e "SHOW GRANTS FOR 'trasabilitate'@'localhost';"
- Check if MariaDB is running:
-
Import errors:
- Ensure virtual environment is activated
- Install missing dependencies:
pip install -r requirements.txt
-
Permission denied:
- Make script executable:
chmod +x app/db_create_scripts/setup_complete_database.py - Check file ownership:
ls -la app/db_create_scripts/
- Make script executable:
Manual Database Recreation:
If you need to completely reset the database:
# Drop and recreate database
sudo mysql -e "DROP DATABASE IF EXISTS trasabilitate; CREATE DATABASE trasabilitate; GRANT ALL PRIVILEGES ON trasabilitate.* TO 'trasabilitate'@'localhost'; FLUSH PRIVILEGES;"
# Remove SQLite database
rm -f instance/users.db
# Run setup script
python3 app/db_create_scripts/setup_complete_database.py
Script Features
- ✅ Comprehensive: Creates all necessary database structure
- ✅ Safe: Uses
IF NOT EXISTSclauses to prevent conflicts - ✅ Verified: Includes verification step to confirm setup
- ✅ Informative: Detailed output showing each step
- ✅ Error handling: Clear error messages and troubleshooting hints
- ✅ Idempotent: Can be run multiple times safely
Development Notes
The script combines functionality from these individual scripts:
create_scan_1db.pycreate_scanfg_orders.pycreate_order_for_labels_table.pycreate_warehouse_locations_table.pycreate_permissions_tables.pycreate_roles_table.pycreate_triggers.pycreate_triggers_fg.pypopulate_permissions.py
For development or debugging, you can still run individual scripts if needed.