From adb67386afdd97b8c3d476c3a9f60cb78a415a3b Mon Sep 17 00:00:00 2001 From: Benjamin Date: Sun, 26 Feb 2023 23:23:01 +0100 Subject: [PATCH] fixup! Add forms for adding recipes and versions Add author name option --- recipes/forms.py | 6 ++++-- recipes/templates/add-version.html | 20 ++++++++++++++++++++ recipes/views.py | 6 +++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/recipes/forms.py b/recipes/forms.py index 58df282..81809aa 100644 --- a/recipes/forms.py +++ b/recipes/forms.py @@ -1,12 +1,14 @@ -from django.forms import ModelForm, ValidationError, formset_factory +from django.forms import ModelForm, ValidationError, formset_factory, BooleanField from .models import Recipe, Version, Ingredient class VersionForm(ModelForm): recipe_id: int + use_user_for_author = BooleanField(initial=True, label='I am the author', required=False) + class Meta: model = Version - fields = ['label', 'slug', 'body'] + fields = ['label', 'slug', 'body', 'author_name'] def clean_slug(self): recipe = Recipe.objects.get(id=self.recipe_id) diff --git a/recipes/templates/add-version.html b/recipes/templates/add-version.html index e67d86b..7f8b8f7 100644 --- a/recipes/templates/add-version.html +++ b/recipes/templates/add-version.html @@ -15,6 +15,26 @@