| from django.db import models | |
| from django.contrib.auth.models import User | |
| class Notice(models.Model): | |
| PRIORITY_CHOICES = [('low', 'Low'), ('medium', 'Medium'), ('high', 'High'), ('urgent', 'Urgent')] | |
| AUDIENCE_CHOICES = [('all', 'Everyone'), ('students', 'Students'), ('teachers', 'Teachers'), ('parents', 'Parents')] | |
| title = models.CharField(max_length=200) | |
| content = models.TextField() | |
| priority = models.CharField(max_length=10, choices=PRIORITY_CHOICES, default='medium') | |
| audience = models.CharField(max_length=10, choices=AUDIENCE_CHOICES, default='all') | |
| author = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True) | |
| is_active = models.BooleanField(default=True) | |
| created_at = models.DateTimeField(auto_now_add=True) | |
| updated_at = models.DateTimeField(auto_now=True) | |
| def __str__(self): | |
| return self.title | |
| class Meta: | |
| ordering = ['-created_at'] |