From acbcf3f606e0942cd1ba8a14a36cf7ea5ba2d31d Mon Sep 17 00:00:00 2001 From: Benjamin Date: Fri, 17 Feb 2023 16:39:00 +0100 Subject: [PATCH] fixup! Add forms for adding recipes and versions Basic form for adding a version. Still needs: * Check of slug uniqueness * Choose between author user or author name * slug auto-creation * ingredients TODO: * Add recipe --- recipes/forms.py | 9 +++++++++ recipes/templates/add-version.html | 11 +++++++++++ recipes/templates/recipe.html | 2 +- recipes/templates/version.html | 2 +- recipes/urls.py | 1 + recipes/views.py | 21 +++++++++++++++++++++ 6 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 recipes/forms.py create mode 100644 recipes/templates/add-version.html diff --git a/recipes/forms.py b/recipes/forms.py new file mode 100644 index 0000000..1a49779 --- /dev/null +++ b/recipes/forms.py @@ -0,0 +1,9 @@ +from django.forms import ModelForm, BooleanField +from .models import Recipe, Version, Ingredient + +class VersionForm(ModelForm): + class Meta: + model = Version + fields = ['label', 'slug', 'body'] + + # use_author_user = BooleanField(initial=True) diff --git a/recipes/templates/add-version.html b/recipes/templates/add-version.html new file mode 100644 index 0000000..783c5ae --- /dev/null +++ b/recipes/templates/add-version.html @@ -0,0 +1,11 @@ +{% extends "base_main.html" %} +{% block title %}{{ recipe.title }}{% endblock %} +{% block main %} +
+ {% csrf_token %} + + {{ form.as_table }} +
+ +
+ {% endblock %} diff --git a/recipes/templates/recipe.html b/recipes/templates/recipe.html index a500538..0dfa759 100644 --- a/recipes/templates/recipe.html +++ b/recipes/templates/recipe.html @@ -3,7 +3,7 @@ {% block main %}

{{ recipe.title }}

{% if perms.recipes.add_recipe %} -

Add version

+

Add version

{% endif %}