Initial commit: Aurora Moments self-hosted photo/video sharing platform
Django/DRF + PostgreSQL/Redis/Celery backend with accounts, library, moments, and notifications apps; React/TypeScript/Vite frontend with Instagram-style sidebar nav, feed, profiles, nested comment replies, notifications, and photo/video upload with ffmpeg-generated posters. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
from django.conf import settings
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Notification(models.Model):
|
||||
"""Tells `recipient` that `actor` did something (`verb`) involving
|
||||
`moment` (and, for comment/reply verbs, the specific `comment`).
|
||||
Created by signal handlers in signals.py — never directly by API
|
||||
consumers."""
|
||||
|
||||
class Verb(models.TextChoices):
|
||||
LIKE = "like", "Like"
|
||||
COMMENT = "comment", "Comment"
|
||||
REPLY = "reply", "Reply"
|
||||
|
||||
recipient = models.ForeignKey(settings.AUTH_USER_MODEL, related_name="notifications", on_delete=models.CASCADE)
|
||||
actor = models.ForeignKey(settings.AUTH_USER_MODEL, related_name="+", on_delete=models.CASCADE)
|
||||
verb = models.CharField(max_length=10, choices=Verb.choices)
|
||||
moment = models.ForeignKey("moments.Moment", related_name="notifications", on_delete=models.CASCADE)
|
||||
comment = models.ForeignKey(
|
||||
"moments.Comment", null=True, blank=True, related_name="notifications", on_delete=models.CASCADE
|
||||
)
|
||||
is_read = models.BooleanField(default=False)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
|
||||
class Meta:
|
||||
ordering = ["-created_at"]
|
||||
indexes = [models.Index(fields=["recipient", "is_read"])]
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.actor} {self.verb} -> {self.recipient}"
|
||||
Reference in New Issue
Block a user