Files
demo-alarms/alerts/models.py
Andros Fenollosa 23ac15664e Initial commit: Django LiveView alert system
Real-time alert system using Django LiveView with WebSocket support.
Features include:
- Real-time alert creation, viewing, and deletion
- Broadcast notifications to all connected users
- SQLite database
- Stimulus.js integration for interactive UI
- Modal dialogs for alert details
- Alert form with validation

Fixed Stimulus controller scope issue by placing data-controller on html element.
2025-12-08 12:27:58 +01:00

20 lines
483 B
Python

from django.db import models
class Alert(models.Model):
ALERT_TYPES = [
('INFO', 'Info'),
('WARNING', 'Warning'),
('CRITICAL', 'Critical'),
]
type = models.CharField(max_length=10, choices=ALERT_TYPES)
description = models.TextField(blank=True, default='')
created_at = models.DateTimeField(auto_now_add=True)
class Meta:
ordering = ['-created_at']
def __str__(self):
return f"{self.type} - {self.created_at}"