Booking out QR code

This commit is contained in:
2026-02-20 12:19:21 -05:00
parent a43cf9b732
commit 3a4085afc6
7 changed files with 93 additions and 2 deletions

View File

@@ -3,11 +3,12 @@ FROM python:3.11-slim
# Set working directory # Set working directory
WORKDIR /app WORKDIR /app
# Install system dependencies # Install system dependencies including qrencode
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
gcc \ gcc \
default-libmysqlclient-dev \ default-libmysqlclient-dev \
pkg-config \ pkg-config \
qrencode \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
# Copy requirements first for better caching # Copy requirements first for better caching

View File

@@ -174,6 +174,12 @@ else
exit 1 exit 1
fi fi
echo ""
echo "========================================="
echo "Generating QR Code"
echo "========================================="
python3 /app/generate_qr.py
echo "" echo ""
echo "=========================================" echo "========================================="
echo "Starting Application Server" echo "Starting Application Server"

38
backend/generate_qr.py Normal file
View File

@@ -0,0 +1,38 @@
#!/usr/bin/env python3
"""Generate booking QR code at container startup"""
import os
import sys
import subprocess
def generate_booking_qr():
"""Generate QR code for the booking page"""
# Get base URL from environment, default to localhost
base_url = os.environ.get('BASE_URL', 'http://localhost')
booking_url = f"{base_url}/book"
# Create output directory if it doesn't exist
output_dir = '/web/assets'
os.makedirs(output_dir, exist_ok=True)
output_file = f'{output_dir}/booking-qr.png'
try:
# Generate QR code using qrencode
subprocess.run(
['qrencode', '-o', output_file, '-s', '5', booking_url],
check=True,
capture_output=True
)
print(f"✓ Generated booking QR code: {output_file}")
print(f" URL: {booking_url}")
return True
except subprocess.CalledProcessError as e:
print(f"✗ Failed to generate QR code: {e.stderr.decode()}", file=sys.stderr)
return False
except FileNotFoundError:
print("✗ qrencode not found. Install with: apt-get install qrencode", file=sys.stderr)
return False
if __name__ == '__main__':
success = generate_booking_qr()
sys.exit(0 if success else 1)

View File

@@ -36,6 +36,7 @@ services:
volumes: volumes:
- ./backend:/app - ./backend:/app
- ./db-init:/db-init:ro # Mount CSV data for seeding - ./db-init:/db-init:ro # Mount CSV data for seeding
- ./web/assets:/web/assets # Mount assets for QR code generation
networks: networks:
- app_network - app_network
extra_hosts: extra_hosts:

View File

@@ -48,6 +48,7 @@ services:
volumes: volumes:
- ./backend:/app - ./backend:/app
- ./db-init:/db-init:ro # Mount CSV data for seeding - ./db-init:/db-init:ro # Mount CSV data for seeding
- ./web/assets:/web/assets # Mount assets for QR code generation
networks: networks:
- private_network - private_network
- public_network - public_network

View File

@@ -547,7 +547,7 @@
</div> </div>
<div class="footer"> <div class="footer">
<p>📞 Questions? Contact the airfield operations team</p> <p>📞 Questions? Tower 01792 687042</p>
<p style="margin-top: 10px; font-size: 12px; color: #999;">Version 1.0</p> <p style="margin-top: 10px; font-size: 12px; color: #999;">Version 1.0</p>
</div> </div>
</div> </div>

View File

@@ -178,6 +178,35 @@
left: 28px; left: 28px;
} }
/* QR code for booking */
.qr-code-container {
position: absolute;
left: 300px;
top: 50%;
transform: translateY(-50%);
background: white;
padding: 5px;
border-radius: 4px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
display: flex;
flex-direction: column;
align-items: center;
gap: 5px;
}
.qr-code-container .qr-label {
font-size: 12px;
font-weight: bold;
color: #333;
white-space: nowrap;
}
.qr-code-container img {
display: block;
max-width: 120px;
height: auto;
}
/* Santa hat styles */ /* Santa hat styles */
.santa-hat { .santa-hat {
position: absolute; position: absolute;
@@ -357,6 +386,10 @@
<body> <body>
<header> <header>
<img src="assets/logo.png" alt="EGFH Logo" class="left-image"> <img src="assets/logo.png" alt="EGFH Logo" class="left-image">
<div class="qr-code-container">
<img id="bookingQR" alt="Scan to book a flight" title="Scan to book a flight">
<div class="qr-label">Book Out</div>
</div>
<h1>Flight Information</h1> <h1>Flight Information</h1>
<img src="assets/flightImg.png" alt="EGFH Logo" class="right-image"> <img src="assets/flightImg.png" alt="EGFH Logo" class="right-image">
</header> </header>
@@ -847,11 +880,22 @@
return typeMap[flightType] || flightType; return typeMap[flightType] || flightType;
} }
// Generate QR code for booking page
function generateBookingQR() {
const qrImg = document.getElementById('bookingQR');
if (qrImg) {
qrImg.src = '/assets/booking-qr.png';
}
}
// Load data on page load // Load data on page load
window.addEventListener('load', function() { window.addEventListener('load', function() {
// Initialize Christmas mode // Initialize Christmas mode
initChristmasMode(); initChristmasMode();
// Load booking QR code
generateBookingQR();
loadArrivals(); loadArrivals();
loadDepartures(); loadDepartures();