- EventLike model (user × event unique constraint, indexed) - contributed_by field on Event (EVT ID or email of community contributor) - Favorites API endpoints: toggle-like, my-likes, my-liked-events - Notifications app wired into main urls.py at /api/notifications/ - accounts migration 0014_merge_0013 (resolves split 0013 branches) - requirements.txt updated
26 lines
842 B
Python
26 lines
842 B
Python
from django.db import models
|
|
from accounts.models import User
|
|
|
|
|
|
class Notification(models.Model):
|
|
NOTIFICATION_TYPES = [
|
|
('event', 'Event'),
|
|
('promo', 'Promotion'),
|
|
('system', 'System'),
|
|
('booking', 'Booking'),
|
|
]
|
|
|
|
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='notifications')
|
|
title = models.CharField(max_length=255)
|
|
message = models.TextField()
|
|
notification_type = models.CharField(max_length=20, choices=NOTIFICATION_TYPES, default='system')
|
|
is_read = models.BooleanField(default=False)
|
|
action_url = models.URLField(blank=True, null=True)
|
|
created_at = models.DateTimeField(auto_now_add=True)
|
|
|
|
class Meta:
|
|
ordering = ['-created_at']
|
|
|
|
def __str__(self):
|
|
return f"{self.notification_type}: {self.title} → {self.user.email}"
|