Make new recipes public by default
New recipes (manual, AI draft and all imports) now start as public; private can still be chosen per recipe. Existing recipes are unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ffb4c0150a
commit
c76fd119cf
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.2.18 on 2026-10-30 22:04
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('recipes', '0002_comment'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='recipe',
|
||||||
|
name='visibility',
|
||||||
|
field=models.CharField(choices=[('private', 'Privat (nur für mich)'), ('public', 'Öffentlich (alle Nutzer)')], default='public', max_length=10, verbose_name='Sichtbarkeit'),
|
||||||
|
),
|
||||||
|
]
|
||||||
+1
-1
@@ -82,7 +82,7 @@ class Recipe(models.Model):
|
|||||||
cook_minutes = models.PositiveSmallIntegerField("Koch-/Backzeit (Min.)", null=True, blank=True)
|
cook_minutes = models.PositiveSmallIntegerField("Koch-/Backzeit (Min.)", null=True, blank=True)
|
||||||
source_url = models.URLField("Quelle (URL)", max_length=1000, blank=True)
|
source_url = models.URLField("Quelle (URL)", max_length=1000, blank=True)
|
||||||
author_notes = models.TextField("Notizen", blank=True)
|
author_notes = models.TextField("Notizen", blank=True)
|
||||||
visibility = models.CharField("Sichtbarkeit", max_length=10, choices=Visibility.choices, default=Visibility.PRIVATE)
|
visibility = models.CharField("Sichtbarkeit", max_length=10, choices=Visibility.choices, default=Visibility.PUBLIC)
|
||||||
tags = models.ManyToManyField(Tag, blank=True, related_name="recipes")
|
tags = models.ManyToManyField(Tag, blank=True, related_name="recipes")
|
||||||
created_at = models.DateTimeField("Erstellt", auto_now_add=True)
|
created_at = models.DateTimeField("Erstellt", auto_now_add=True)
|
||||||
updated_at = models.DateTimeField("Geändert", auto_now=True)
|
updated_at = models.DateTimeField("Geändert", auto_now=True)
|
||||||
|
|||||||
@@ -188,3 +188,19 @@ def test_user_cannot_bulk_delete(user_client, other_user):
|
|||||||
make_recipe(other_user)
|
make_recipe(other_user)
|
||||||
assert user_client.post(reverse("accounts:admin_user_delete_recipes", args=[other_user.pk])).status_code == 403
|
assert user_client.post(reverse("accounts:admin_user_delete_recipes", args=[other_user.pk])).status_code == 403
|
||||||
assert Recipe.objects.exists()
|
assert Recipe.objects.exists()
|
||||||
|
|
||||||
|
|
||||||
|
def test_new_recipe_form_defaults_to_public(user_client):
|
||||||
|
form = user_client.get(reverse("recipes:create")).context["form"]
|
||||||
|
assert form["visibility"].value() == "public"
|
||||||
|
|
||||||
|
|
||||||
|
def test_imported_draft_defaults_to_public(user_client, settings):
|
||||||
|
settings.OPENAI_API_KEY = ""
|
||||||
|
response = user_client.post(reverse("recipes:import_text"), {"text": "200 g Mehl, 2 Eier, verrühren und backen"})
|
||||||
|
assert response.context["form"]["visibility"].value() == "public"
|
||||||
|
|
||||||
|
|
||||||
|
def test_private_can_still_be_chosen(user_client):
|
||||||
|
user_client.post(reverse("recipes:create"), form_data(visibility="private"))
|
||||||
|
assert Recipe.objects.get().visibility == "private"
|
||||||
|
|||||||
Reference in New Issue
Block a user