| 2425 | created_at = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow) |
| 2426 | updated_at = db.Column(db.DateTime, nullable=True, onupdate=datetime.datetime.utcnow) |
| 2427 | |
| 2428 | |
| 2429 | class Complaint(db.Model): |
| 2430 | __tablename__ = "complaints" |
| 2431 | |
| 2432 | id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4) |
| 2433 | notification_id = db.Column(UUID(as_uuid=True), index=True, nullable=False) |
| 2434 | service_id = db.Column(UUID(as_uuid=True), db.ForeignKey("services.id"), unique=False, index=True, nullable=False) |
| 2435 | service = db.relationship(Service, backref=db.backref("complaints")) |
| 2436 | ses_feedback_id = db.Column(db.Text, nullable=True) |
| 2437 | complaint_type = db.Column(db.Text, nullable=True) |
| 2438 | complaint_date = db.Column(db.DateTime, nullable=True) |
| 2439 | created_at = db.Column(db.DateTime, nullable=False, default=datetime.datetime.utcnow) |
| 2440 | |
| 2441 | def serialize(self) -> SerializedComplaint: |
| 2442 | return SerializedComplaint( |
| 2443 | id=str(self.id), |
| 2444 | notification_id=str(self.notification_id), |
| 2445 | service_id=str(self.service_id), |
| 2446 | service_name=self.service.name, |
| 2447 | ses_feedback_id=str(self.ses_feedback_id), |
| 2448 | complaint_type=self.complaint_type, |
| 2449 | complaint_date=get_dt_string_or_none(self.complaint_date), |
| 2450 | created_at=self.created_at.strftime(DATETIME_FORMAT), |
| 2451 | ) |
| 2452 |
no outgoing calls