06/09 Update a customer AI chatbot and support form submision

This commit is contained in:
2026-06-09 16:13:12 -04:00
parent 58d4b351b4
commit 38dff9ea02
9 changed files with 1029 additions and 1 deletions
+41
View File
@@ -0,0 +1,41 @@
from app import db
from app.utils.time_utils import now_eastern
class SupportTicket(db.Model):
__tablename__ = 'support_tickets'
id = db.Column(db.Integer, primary_key=True)
customer_id = db.Column(db.Integer, db.ForeignKey('users.id', ondelete='SET NULL'), nullable=True)
facility_id = db.Column(db.Integer, db.ForeignKey('facilities.id', ondelete='SET NULL'), nullable=True)
subject = db.Column(db.String(200), nullable=False)
body = db.Column(db.Text, nullable=False)
status = db.Column(db.String(20), nullable=False, default='open') # open / answered / closed
created_at = db.Column(db.DateTime, default=now_eastern, nullable=False)
customer = db.relationship('User', foreign_keys=[customer_id], backref='support_tickets')
facility = db.relationship('Facility', foreign_keys=[facility_id], backref='support_tickets')
replies = db.relationship(
'SupportTicketReply', backref='ticket',
cascade='all, delete-orphan',
order_by='SupportTicketReply.created_at',
lazy='dynamic',
)
def __repr__(self):
return f'<SupportTicket {self.id} [{self.status}]>'
class SupportTicketReply(db.Model):
__tablename__ = 'support_ticket_replies'
id = db.Column(db.Integer, primary_key=True)
ticket_id = db.Column(db.Integer, db.ForeignKey('support_tickets.id', ondelete='CASCADE'), nullable=False)
user_id = db.Column(db.Integer, db.ForeignKey('users.id', ondelete='SET NULL'), nullable=True)
body = db.Column(db.Text, nullable=False)
created_at = db.Column(db.DateTime, default=now_eastern, nullable=False)
author = db.relationship('User', foreign_keys=[user_id])
def __repr__(self):
return f'<SupportTicketReply {self.id} ticket={self.ticket_id}>'