- Auto-fixed 4,496 lint issues (import sorting, modern syntax, etc.) - Added ignore rules for patterns intentional in this codebase: E402 (late imports), E712 (SQLAlchemy filters), B904 (raise from), SIM108/SIM105/SIM117 (readability preferences) - Added per-file ignores for tests and scripts - Excluded broken scripts/rename_terminology.py (has curly quotes) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
55 lines
1.7 KiB
Python
55 lines
1.7 KiB
Python
# app/modules/messaging/models/admin_notification.py
|
|
"""
|
|
Admin notification database model.
|
|
|
|
This model handles admin-specific notifications for system alerts and warnings.
|
|
"""
|
|
|
|
from sqlalchemy import (
|
|
JSON,
|
|
Boolean,
|
|
Column,
|
|
DateTime,
|
|
ForeignKey,
|
|
Integer,
|
|
String,
|
|
Text,
|
|
)
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.core.database import Base
|
|
from models.database.base import TimestampMixin
|
|
|
|
|
|
class AdminNotification(Base, TimestampMixin):
|
|
"""
|
|
Admin-specific notifications for system alerts and warnings.
|
|
|
|
Different from store/customer notifications - these are for platform
|
|
administrators to track system health and issues requiring attention.
|
|
"""
|
|
|
|
__tablename__ = "admin_notifications"
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
type = Column(
|
|
String(50), nullable=False, index=True
|
|
) # system_alert, store_issue, import_failure
|
|
priority = Column(
|
|
String(20), default="normal", index=True
|
|
) # low, normal, high, critical
|
|
title = Column(String(200), nullable=False)
|
|
message = Column(Text, nullable=False)
|
|
is_read = Column(Boolean, default=False, index=True)
|
|
read_at = Column(DateTime, nullable=True)
|
|
read_by_user_id = Column(Integer, ForeignKey("users.id"), nullable=True)
|
|
action_required = Column(Boolean, default=False, index=True)
|
|
action_url = Column(String(500)) # Link to relevant admin page
|
|
notification_metadata = Column(JSON) # Additional contextual data
|
|
|
|
# Relationships
|
|
read_by = relationship("User", foreign_keys=[read_by_user_id])
|
|
|
|
def __repr__(self):
|
|
return f"<AdminNotification(id={self.id}, type='{self.type}', priority='{self.priority}')>"
|