Jul 16 - Fill the gaps between Single-tenant mode and Multi-tenant mode - MT3
This commit is contained in:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user