feat(favorites): add EventLike model, favorites API, and notifications module
- 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
This commit is contained in:
@@ -58,6 +58,11 @@ class Event(models.Model):
|
||||
is_featured = models.BooleanField(default=False, help_text='Show this event in the featured section')
|
||||
is_top_event = models.BooleanField(default=False, help_text='Show this event in the Top Events section')
|
||||
|
||||
contributed_by = models.CharField(
|
||||
max_length=100, blank=True, null=True,
|
||||
help_text='Eventify ID (EVT-XXXXXXXX) or email of the community contributor',
|
||||
)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.name} ({self.start_date})"
|
||||
|
||||
@@ -71,3 +76,26 @@ class EventImages(models.Model):
|
||||
return f"{self.event_image}"
|
||||
|
||||
|
||||
class EventLike(models.Model):
|
||||
user = models.ForeignKey(
|
||||
'accounts.User',
|
||||
on_delete=models.CASCADE,
|
||||
related_name='event_likes'
|
||||
)
|
||||
event = models.ForeignKey(
|
||||
Event,
|
||||
on_delete=models.CASCADE,
|
||||
related_name='likes'
|
||||
)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
unique_together = ('user', 'event')
|
||||
indexes = [
|
||||
models.Index(fields=['user', '-created_at']),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.user.email} likes {self.event.name}"
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user