Add phase 3: comments and cooking mode

- Comments on visible recipes; author and admin may delete; per-user
  hourly rate limit (COMMENT_RATE_LIMIT_PER_HOUR)
- Cooking mode with large text, tick-off checklists, serving scaling and
  Screen Wake Lock to keep the display on
- Serving calculator auto-submits on change
- Privacy tests cover comment and cooking-mode URLs

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Kyle Dammann
2026-10-30 21:39:15 +01:00
co-authored by Claude Opus 5.5
parent 6f7e4f92ca
commit 9256e94286
14 changed files with 342 additions and 16 deletions
+23
View File
@@ -197,3 +197,26 @@ class Favorite(models.Model):
class Meta:
constraints = [models.UniqueConstraint(fields=["user", "recipe"], name="favorite_unique")]
class CommentQuerySet(models.QuerySet):
def deletable_by(self, user):
if user is None or not user.is_authenticated:
return self.none()
visible = self.filter(recipe__in=Recipe.objects.visible_to(user))
return visible if user.is_admin else visible.filter(author=user)
class Comment(models.Model):
recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE, related_name="comments")
author = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name="comments")
text = models.TextField("Kommentar", max_length=2000)
created_at = models.DateTimeField(auto_now_add=True)
objects = CommentQuerySet.as_manager()
class Meta:
ordering = ["created_at"]
def __str__(self):
return f"Kommentar von {self.author} zu {self.recipe}"