Jul 16 - Fill the gaps between Single-tenant mode and Multi-tenant mode - MT3

This commit is contained in:
2026-07-16 17:17:44 -04:00
parent a60afc6c41
commit 02b030b1d2
12 changed files with 1294 additions and 90 deletions
+12
View File
@@ -42,6 +42,18 @@ class Area(db.Model):
name = db.Column(db.String(255), nullable=False)
area_type = db.Column(db.String(50))
# phase42: unguessable token behind the public area scan page (/f/area/<token>).
# NULL until first requested — ensure_qr_token() generates it lazily, exactly
# like Facility.qr_token above.
qr_token = db.Column(db.String(64), unique=True, nullable=True)
def ensure_qr_token(self):
"""Generate the QR token on first use. Caller commits."""
if not self.qr_token:
import secrets
self.qr_token = secrets.token_urlsafe(32)
return self.qr_token
# Relationships
inspections = db.relationship('Inspection', backref='area', lazy='dynamic')
issues = db.relationship('Issue', backref='area', lazy='dynamic')